diff options
| author | John Reck <jreck@google.com> | 2011-04-26 16:57:46 -0700 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2011-04-26 17:59:12 -0700 |
| commit | 7818aaa14a04661bdfd7019bdd1904c4383cd40f (patch) | |
| tree | 40b904363ae9bebbc30489446a157dfb1d08db96 | |
| parent | 2d039219adbeaad1a481267bca021b1a8645b481 (diff) | |
| download | frameworks_base-7818aaa14a04661bdfd7019bdd1904c4383cd40f.zip frameworks_base-7818aaa14a04661bdfd7019bdd1904c4383cd40f.tar.gz frameworks_base-7818aaa14a04661bdfd7019bdd1904c4383cd40f.tar.bz2 | |
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
| -rw-r--r-- | core/java/android/webkit/WebSettings.java | 18 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 29 |
2 files changed, 43 insertions, 4 deletions
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 @@ public class WebSettings { private boolean mAllowContentAccess = true; private boolean mLoadWithOverviewMode = false; private boolean mEnableSmoothTransition = false; + private boolean mForceUserScalable = false; // AutoFill Profile data /** @@ -1658,6 +1659,23 @@ public class WebSettings { } } + /** + * 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 @@ final class WebViewCore { // 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 @@ final class WebViewCore { // 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 @@ final class WebViewCore { 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 @@ final class WebViewCore { 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, |
