Java 类android.widget.ZoomButtonsController 实例源码
项目:OSchina_resources_android
文件:UIHelper.java
@SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled"})
public static void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(14);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
//webView.setWebViewClient(UiUtil.getWebViewClient());
}
项目:CoreModule
文件:BrowserFragment.java
@SuppressLint({"SetJavaScriptEnabled"})
public static void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 19) {
webView.getSettings().setLoadsImagesAutomatically(true);
} else {
webView.getSettings().setLoadsImagesAutomatically(false);
}
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
addWebImageShow(webView.getContext(), webView);
}
项目:CoreModule
文件:BrowserDelegateOption.java
@SuppressLint({"SetJavaScriptEnabled"})
public static void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 19) {
webView.getSettings().setLoadsImagesAutomatically(true);
} else {
webView.getSettings().setLoadsImagesAutomatically(false);
}
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
addWebImageShow(webView.getContext(), webView);
}
项目:Cotable
文件:BaseDetailFragment.java
@SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"})
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
}
项目:TinyTravelTracker
文件:ViewImage.java
private void setupZoomButtonController(final View ownerView) {
mZoomButtonsController = new ZoomButtonsController(ownerView);
mZoomButtonsController.setAutoDismissed(false);
mZoomButtonsController.setZoomSpeed(100);
mZoomButtonsController.setOnZoomListener(
new ZoomButtonsController.OnZoomListener() {
public void onVisibilityChanged(boolean visible) {
if (visible) {
updateZoomButtonsEnabled();
}
}
public void onZoom(boolean zoomIn) {
if (zoomIn) {
mImageView.zoomIn();
} else {
mImageView.zoomOut();
}
mZoomButtonsController.setVisible(true);
updateZoomButtonsEnabled();
}
});
}
项目:KJBlog
文件:UIHelper.java
@SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" })
public static void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
webView.setWebViewClient(UIHelper.getWebViewClient());
}
项目:Redpin
文件:ZoomAndScrollImageView.java
/**
* Initializes the view
*
* @param context
* {@link Context}
*/
private void init(Context context) {
setFocusable(true);
scroller = new Scroller(context);
gestureDetector = new GestureDetector(context, this);
scaleGestureDetector = new ScaleGestureDetector(context, this);
zoomController = new ZoomButtonsController(this);
zoomController.setOnZoomListener(this);
matrix = new Matrix();
destination = new float[2];
// setVerticalScrollBarEnabled(true);
// setHorizontalScrollBarEnabled(true);
}
项目:oschina-app
文件:TweetDetailFragment.java
@SuppressLint("SetJavaScriptEnabled")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(20);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
UIHelper.addWebImageShow(getActivity(), webView);
}
项目:oschina-app
文件:BaseDetailFragment.java
@SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"})
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
UIHelper.addWebImageShow(getActivity(), webView);
}
项目:KJFrameForAndroid
文件:UIHelper.java
@SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" })
public static void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
webView.setWebViewClient(UIHelper.getWebViewClient());
}
项目:yiim_v2
文件:ViewImageDialog.java
private void setupZoomButtonController(final View ownerView) {
mZoomButtonsController = new ZoomButtonsController(ownerView);
mZoomButtonsController.setAutoDismissed(false);
mZoomButtonsController.setZoomSpeed(100);
mZoomButtonsController
.setOnZoomListener(new ZoomButtonsController.OnZoomListener() {
public void onVisibilityChanged(boolean visible) {
if (visible) {
updateZoomButtonsEnabled();
}
}
public void onZoom(boolean zoomIn) {
if (zoomIn) {
mImageView.zoomIn();
} else {
mImageView.zoomOut();
}
mZoomButtonsController.setVisible(true);
updateZoomButtonsEnabled();
}
});
}
项目:andRoc
文件:ActLevel.java
@Override
public boolean onTouchEvent(MotionEvent event) {
if (m_RocrailService.Prefs.Zoom && levelView.zoomButtonsController == null) {
levelView.zoomButtonsController = new ZoomButtonsController(getWindow().getDecorView());
levelView.zoomButtonsController.setOnZoomListener(this);
levelView.zoomButtonsController.setZoomInEnabled(m_RocrailService.Prefs.Size < 64 );
levelView.zoomButtonsController.setZoomOutEnabled(m_RocrailService.Prefs.Size > 8 );
}
switch (event.getAction()) {
case MotionEvent.ACTION_UP:
System.out.println("uptime="+SystemClock.uptimeMillis()+" downtime="+event.getDownTime());
if (m_RocrailService.Prefs.Zoom && (SystemClock.uptimeMillis() - event.getDownTime()) > 1000 && levelView.zoomButtonsController != null) {
levelView.zoomButtonsController.setVisible(true);
levelView.zoomButtonsController.setFocusable(true);
levelView.zoomButtonsController.getZoomControls().setFocusable(true);
levelView.zoomButtonsController.getZoomControls().setFocusableInTouchMode(true);
levelView.zoomButtonsController.getZoomControls().requestFocus();
return true;
}
}
return levelView.onTouchEvent(event);
}
项目:coolreader
文件:NonLeakingWebView.java
/**
* Set option to display zoom control
* http://stackoverflow.com/a/11901948
*
* @param show
*/
@SuppressLint("NewApi")
public void setDisplayZoomControl(boolean show) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
this.getSettings().setDisplayZoomControls(show);
} else {
// get the control
try {
Class webview = Class.forName("android.webkit.WebView");
Method method = webview.getMethod("getZoomButtonsController");
zoom_controll = (ZoomButtonsController) method.invoke(this, null);
showZoom = show;
} catch (Exception e) {
Log.e(TAG, "Error when getting zoom control", e);
}
}
}
项目:ima_intellj
文件:TweetDetailFragment.java
@SuppressLint("SetJavaScriptEnabled")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(20);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
UIHelper.addWebImageShow(getActivity(), webView);
}
项目:ima_intellj
文件:BaseDetailFragment.java
@SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface" })
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
UIHelper.addWebImageShow(getActivity(), webView);
}
项目:indoorlib
文件:MapScrollView.java
/**
* @param context
* @param zoomController
*/
private void makeZoomLabel(Context context, ZoomButtonsController zoomController) {
ViewGroup container = zoomController.getContainer();
View controls = zoomController.getZoomControls();
LayoutParams p0 = controls.getLayoutParams();
container.removeView(controls);
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
mZoomLabel = new TextView(context);
mZoomLabel.setPadding(12, 0, 12, 0);
mZoomLabel.setTypeface(Typeface.DEFAULT_BOLD);
mZoomLabel.setTextColor(0xff000000);
PaintDrawable d = new PaintDrawable(0xeeffffff);
d.setCornerRadius(6);
mZoomLabel.setBackgroundDrawable(d);
mZoomLabel.setTextSize(20);
mZoomLabel.setGravity(Gravity.CENTER_HORIZONTAL);
LinearLayout.LayoutParams p1 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
p1.gravity = Gravity.CENTER_HORIZONTAL;
layout.addView(mZoomLabel, p1);
layout.addView(controls);
container.addView(layout, p0);
}
项目:chromium_webview
文件:AwZoomControls.java
@Override
public void updateZoomControls() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController == null) {
return;
}
boolean canZoomIn = mAwContents.canZoomIn();
boolean canZoomOut = mAwContents.canZoomOut();
if (!canZoomIn && !canZoomOut) {
// Hide the zoom in and out buttons if the page cannot zoom
zoomController.getZoomControls().setVisibility(View.GONE);
} else {
// Set each one individually, as a page may be able to zoom in or out
zoomController.setZoomInEnabled(canZoomIn);
zoomController.setZoomOutEnabled(canZoomOut);
}
}
项目:UPMCarte
文件:ZoomAndScrollImageView.java
/**
* Initializes the view
*
* @param context
* {@link Context}
*/
private void init(Context context) {
setFocusable(true);
scroller = new Scroller(context);
gestureDetector = new GestureDetector(context, this);
scaleGestureDetector = new ScaleGestureDetector(context, this);
zoomController = new ZoomButtonsController(this);
zoomController.setOnZoomListener(this);
matrix = new Matrix();
destination = new float[2];
// setVerticalScrollBarEnabled(true);
// setHorizontalScrollBarEnabled(true);
}
项目:cordova-android-chromium
文件:AwZoomControls.java
@Override
public void updateZoomControls() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController == null) {
return;
}
boolean canZoomIn = mAwContents.canZoomIn();
boolean canZoomOut = mAwContents.canZoomOut();
if (!canZoomIn && !canZoomOut) {
// Hide the zoom in and out buttons if the page cannot zoom
zoomController.getZoomControls().setVisibility(View.GONE);
} else {
// Set each one individually, as a page may be able to zoom in or out
zoomController.setZoomInEnabled(canZoomIn);
zoomController.setZoomOutEnabled(canZoomOut);
}
}
项目:WhiteRead
文件:MMWebView.java
private void getController(boolean tag) {
try {
Class webView = Class.forName("android.webkit.WebView");
Method method = webView.getMethod("getZoomButtonsController");
ZoomButtonsController zoomController = (ZoomButtonsController) method.invoke(this, new Object[]{});
if (zoomController != null) {
zoomController.setVisible(tag);
}
} catch (Exception e) {
e.printStackTrace();
}
}
项目:AndroidBase
文件:CustWebView.java
private void getControlls() {
try {
Class<?> webview = Class.forName("android.webkit.WebView");
Method method = webview.getMethod("getZoomButtonsController");
ZoomButtonsController zoomController = (ZoomButtonsController) method.invoke(this);
} catch (Exception e) {
e.printStackTrace();
}
}
项目:Rocko-Android-Demos
文件:ZoomButtonsActivity.java
private void inti() {
textView = (TextView) findViewById(R.id.textview);
scrollView = (ScrollView) findViewById(R.id.scroll_view);
zoomButtonsController = new ZoomButtonsController(scrollView);
textView.setOnTouchListener(zoomButtonsController);
// zoomButtonsController.setAutoDismissed(false);
zoomButtonsController.setZoomInEnabled(true);
zoomButtonsController.setZoomOutEnabled(true);
zoomButtonsController.setFocusable(true);
zoomTextSize = textView.getTextSize();
zoomButtonsController.setOnZoomListener(new ZoomButtonsController.OnZoomListener() {
@Override
public void onVisibilityChanged(boolean visible) {
}
@Override
public void onZoom(boolean zoomIn) {
if (zoomIn) {
zoomTextSize = zoomTextSize + 1.0f;
} else {
zoomTextSize = zoomTextSize - 1.0f;
}
textView.setTextSize(zoomTextSize);
}
});
}
项目:SimpleKiwixWikivoyage
文件:KiwixWebView.java
private void getZoomControlls() {
try {
Class webview = Class.forName("android.webkit.WebView");
Method method = webview.getMethod("getZoomButtonsController");
zoomControll = (ZoomButtonsController) method.invoke(this, null);
} catch (Exception e) {
e.printStackTrace();
}
}
项目:indoorlib
文件:MapScrollView.java
/**
* @param context
* @param attrs
*/
public MapScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
mScroller = new Scroller(context);
mGestureDetector = new GestureDetector(this);
mScale = 1;
mZoomButtonsController = new ZoomButtonsController(this);
mZoomButtonsController.setAutoDismissed(true);
mZoomButtonsController.setOnZoomListener(this);
mZoomButtonsController.setZoomSpeed(25);
mZoomButtonsController.setZoomInEnabled(mScale < MAX_ZOOM);
mZoomButtonsController.setZoomOutEnabled(mScale > MIN_ZOOM);
makeZoomLabel(context, mZoomButtonsController);
mZoomFormat = NumberFormat.getPercentInstance();
mZoomLabel.setText("Zoom: " + mZoomFormat.format(mScale));
setVerticalScrollBarEnabled(true);
setHorizontalScrollBarEnabled(true);
TypedArray a = context.obtainStyledAttributes(R.styleable.Scroll);
initializeScrollbars(a);
a.recycle();
mMatrix = new Matrix();
mDst = new float[2];
mZoomAnimation = new ZoomAnimation();
mPaths = new Path[2];
mPathPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPathPaint.setStyle(Style.STROKE);
mPathPaint.setStrokeCap(Cap.SQUARE);
}
项目:chromium_webview
文件:AwZoomControls.java
@Override
public void invokeZoomPicker() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController != null) {
zoomController.setVisible(true);
}
}
项目:chromium_webview
文件:AwZoomControls.java
@Override
public void dismissZoomPicker() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController != null) {
zoomController.setVisible(false);
}
}
项目:pickncrop
文件:MainActivity.java
public void createZoomControls() {
ZoomButtonsController zoomButtonsController = new ZoomButtonsController(
imageView);
zoomButtonsController.setVisible(true);
zoomButtonsController.setAutoDismissed(false);
zoomButtonsController.setOnZoomListener(new OnZoomListener() {
public void onZoom(boolean zoomIn) {
matrix = imageView.getImageMatrix();
if (zoomIn) {
matrix.postScale(1.05f, 1.05f, 0.5f * size, 0.5f * size);
imageView.setImageMatrix(matrix);
} else {
matrix.postScale(0.95f, 0.95f, 0.5f * size, 0.5f * size);
imageView.setImageMatrix(matrix);
}
imageView.invalidate();
}
public void onVisibilityChanged(boolean visible) {
}
});
RelativeLayout.LayoutParams zoomLayoutParams = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
zoomLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
zoomLayoutParams.addRule(RelativeLayout.BELOW, R.id.imageViewCrop);
viewManager.addView(zoomButtonsController.getContainer(),
zoomLayoutParams);
}
项目:cordova-android-chromium
文件:AwZoomControls.java
@Override
public void invokeZoomPicker() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController != null) {
zoomController.setVisible(true);
}
}
项目:cordova-android-chromium
文件:AwZoomControls.java
@Override
public void dismissZoomPicker() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController != null) {
zoomController.setVisible(false);
}
}
项目:letv
文件:AppbarActivity.java
private void initViews() {
Method method;
WebSettings settings = this.mWebView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setUserAgentString(settings.getUserAgentString() + "/" + UA_PREFIX + this.jsBridge.getVersion() + "/sdk");
settings.setJavaScriptEnabled(true);
Class cls = settings.getClass();
try {
method = cls.getMethod("setPluginsEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(settings, new Object[]{Boolean.valueOf(true)});
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (Throwable th) {
th.printStackTrace();
}
try {
method = cls.getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(settings, new Object[]{Boolean.valueOf(true)});
}
} catch (SecurityException e2) {
e2.printStackTrace();
} catch (NoSuchMethodException e3) {
} catch (IllegalArgumentException e4) {
} catch (IllegalAccessException e5) {
} catch (InvocationTargetException e6) {
}
settings.setAppCachePath(getWebViewCacheDir());
settings.setDatabasePath(getWebViewCacheDir());
settings.setDatabaseEnabled(true);
settings.setAppCacheEnabled(true);
if (supportWebViewFullScreen()) {
settings.setUseWideViewPort(true);
if (VERSION.SDK_INT >= 7) {
try {
cls.getMethod("setLoadWithOverviewMode", new Class[]{Boolean.TYPE}).invoke(settings, new Object[]{Boolean.valueOf(true)});
} catch (Exception e7) {
}
}
if (SystemUtils.isSupportMultiTouch()) {
if (SystemUtils.getAndroidSDKVersion() < 11) {
try {
Field declaredField = WebView.class.getDeclaredField("mZoomButtonsController");
declaredField.setAccessible(true);
ZoomButtonsController zoomButtonsController = new ZoomButtonsController(this.mWebView);
zoomButtonsController.getZoomControls().setVisibility(8);
declaredField.set(this.mWebView, zoomButtonsController);
} catch (Exception e8) {
}
} else {
try {
this.mWebView.getSettings().getClass().getMethod("setDisplayZoomControls", new Class[]{Boolean.TYPE}).invoke(this.mWebView.getSettings(), new Object[]{Boolean.valueOf(false)});
} catch (Exception e9) {
}
}
}
}
this.mWebView.setWebViewClient(new d());
this.mWebView.setWebChromeClient(new c());
this.mWebView.setDownloadListener(this.mDownloadListener);
this.mWebView.loadUrl(this.url);
}
项目:FullRobolectricTestSample
文件:ShadowMapView.java
public ShadowMapView(MapView mapView) {
realMapView = mapView;
zoomButtonsController = new ZoomButtonsController(mapView);
}
项目:FullRobolectricTestSample
文件:ShadowMapView.java
@Implementation
public ZoomButtonsController getZoomButtonsController() {
return zoomButtonsController;
}
项目:FullRobolectricTestSample
文件:ShadowZoomButtonsController.java
@Implementation
public void setOnZoomListener(ZoomButtonsController.OnZoomListener listener) {
this.listener = listener;
}
项目:FullRobolectricTestSample
文件:Robolectric.java
public static ShadowZoomButtonsController shadowOf(ZoomButtonsController instance) {
return (ShadowZoomButtonsController) shadowOf_(instance);
}
项目:android_frameworks_mapsv1
文件:MapView.java
@OriginalApi
public ZoomButtonsController getZoomButtonsController() {
return zoomButtonsController;
}