Add support for force-enabling zoom
Adds an option in WebSettings that causes WebView to ignore the
user-scalable option on the viewport metatag
Change-Id: Ia850489811a6617a8c17ec6cb17e0a65400f55f0
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 71d6080..3e11197 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -219,6 +219,7 @@
private boolean mAllowContentAccess = true;
private boolean mLoadWithOverviewMode = false;
private boolean mEnableSmoothTransition = false;
+ private boolean mForceUserScalable = false;
// AutoFill Profile data
/**
@@ -1658,6 +1659,23 @@
}
}
+ /**
+ * Returns whether the viewport metatag can disable zooming
+ * @hide
+ */
+ public boolean forceUserScalable() {
+ return mForceUserScalable;
+ }
+
+ /**
+ * Sets whether viewport metatag can disable zooming.
+ * @param flag Whether or not to forceably enable user scalable.
+ * @hide
+ */
+ public synchronized void setForceUserScalable(boolean flag) {
+ mForceUserScalable = flag;
+ }
+
synchronized void setSyntheticLinksEnabled(boolean flag) {
if (mSyntheticLinksEnabled != flag) {
mSyntheticLinksEnabled = flag;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 0271695..09205a5 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2253,6 +2253,27 @@
// set the viewport settings from WebKit
setViewportSettingsFromNative();
+ if (mSettings.forceUserScalable()) {
+ mViewportUserScalable = true;
+ if (mViewportInitialScale > 0) {
+ if (mViewportMinimumScale > 0) {
+ mViewportMinimumScale = Math.min(mViewportMinimumScale,
+ mViewportInitialScale / 2);
+ }
+ if (mViewportMaximumScale > 0) {
+ mViewportMaximumScale = Math.max(mViewportMaximumScale,
+ mViewportInitialScale * 2);
+ }
+ } else {
+ if (mViewportMinimumScale > 0) {
+ mViewportMinimumScale = Math.min(mViewportMinimumScale, 50);
+ }
+ if (mViewportMaximumScale > 0) {
+ mViewportMaximumScale = Math.max(mViewportMaximumScale, 200);
+ }
+ }
+ }
+
// adjust the default scale to match the densityDpi
float adjust = 1.0f;
if (mViewportDensityDpi == -1) {
@@ -2589,11 +2610,11 @@
// called by JNI
private Class<?> getPluginClass(String libName, String clsName) {
-
+
if (mWebView == null) {
return null;
}
-
+
PluginManager pluginManager = PluginManager.getInstance(null);
String pkgName = pluginManager.getPluginsAPKName(libName);
@@ -2601,7 +2622,7 @@
Log.w(LOGTAG, "Unable to resolve " + libName + " to a plugin APK");
return null;
}
-
+
try {
return pluginManager.getPluginClass(pkgName, clsName);
} catch (NameNotFoundException e) {
@@ -2656,7 +2677,7 @@
view.mView = pluginView;
return view;
}
-
+
// called by JNI. PluginWidget functions for creating an embedded View for
// the surface drawing model.
private ViewManager.ChildView addSurface(View pluginView, int x, int y,