android.widget.ZoomButtonsController Java Examples

The following examples show how to use android.widget.ZoomButtonsController. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrowserFragment.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: BrowserDelegateOption.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: BaseDetailFragment.java    From Cotable with Apache License 2.0 6 votes vote down vote up
@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);
    }

}
 
Example #4
Source File: UIHelper.java    From KJFrameForAndroid with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #5
Source File: ViewImageDialog.java    From yiim_v2 with GNU General Public License v2.0 6 votes vote down vote up
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();
				}
			});
}
 
Example #6
Source File: NonLeakingWebView.java    From coolreader with MIT License 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example #7
Source File: AwZoomControls.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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);
    }
}
 
Example #8
Source File: AwZoomControls.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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);
    }
}
 
Example #9
Source File: CustWebView.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
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();
    }
}
 
Example #10
Source File: ZoomButtonsActivity.java    From Rocko-Android-Demos with Apache License 2.0 5 votes vote down vote up
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);
        }
    });
}
 
Example #11
Source File: AwZoomControls.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invokeZoomPicker() {
    ZoomButtonsController zoomController = getZoomController();
    if (zoomController != null) {
        zoomController.setVisible(true);
    }
}
 
Example #12
Source File: AwZoomControls.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void dismissZoomPicker() {
    ZoomButtonsController zoomController = getZoomController();
    if (zoomController != null) {
        zoomController.setVisible(false);
    }
}
 
Example #13
Source File: AwZoomControls.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invokeZoomPicker() {
    ZoomButtonsController zoomController = getZoomController();
    if (zoomController != null) {
        zoomController.setVisible(true);
    }
}
 
Example #14
Source File: AwZoomControls.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void dismissZoomPicker() {
    ZoomButtonsController zoomController = getZoomController();
    if (zoomController != null) {
        zoomController.setVisible(false);
    }
}
 
Example #15
Source File: AppbarActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example #16
Source File: MapView.java    From android_frameworks_mapsv1 with Apache License 2.0 4 votes vote down vote up
@OriginalApi
public ZoomButtonsController getZoomButtonsController() {
    return zoomButtonsController;
}