diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java index 196bbd7aff62f..3c43fd15a2a86 100644 --- a/core/java/android/webkit/WebSettings.java +++ b/core/java/android/webkit/WebSettings.java @@ -17,6 +17,7 @@ package android.webkit; import android.content.Context; +import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Build; import android.os.Handler; @@ -193,12 +194,20 @@ public class WebSettings { // with Google' and the browser. static GoogleLocationSettingManager sGoogleLocationSettingManager; + // private WebSettings, not accessible by the host activity + private int mDoubleTapToastCount = 3; + + private static final String PREF_FILE = "WebViewSettings"; + private static final String DOUBLE_TAP_TOAST_COUNT = "double_tap_toast_count"; + // Class to handle messages before WebCore is ready. private class EventHandler { // Message id for syncing static final int SYNC = 0; // Message id for setting priority static final int PRIORITY = 1; + // Message id for writing double-tap toast count + static final int SET_DOUBLE_TAP_TOAST_COUNT = 2; // Actual WebCore thread handler private Handler mHandler; @@ -224,6 +233,16 @@ public class WebSettings { setRenderPriority(); break; } + + case SET_DOUBLE_TAP_TOAST_COUNT: { + SharedPreferences.Editor editor = mContext + .getSharedPreferences(PREF_FILE, + Context.MODE_PRIVATE).edit(); + editor.putInt(DOUBLE_TAP_TOAST_COUNT, + mDoubleTapToastCount); + editor.commit(); + break; + } } } }; @@ -1311,6 +1330,19 @@ public class WebSettings { } } + int getDoubleTapToastCount() { + return mDoubleTapToastCount; + } + + void setDoubleTapToastCount(int count) { + if (mDoubleTapToastCount != count) { + mDoubleTapToastCount = count; + // write the settings in the non-UI thread + mEventHandler.sendMessage(Message.obtain(null, + EventHandler.SET_DOUBLE_TAP_TOAST_COUNT)); + } + } + /** * Transfer messages from the queue to the new WebCoreThread. Called from * WebCore thread. @@ -1323,6 +1355,10 @@ public class WebSettings { } sGoogleLocationSettingManager = new GoogleLocationSettingManager(mContext); sGoogleLocationSettingManager.start(); + SharedPreferences sp = mContext.getSharedPreferences(PREF_FILE, + Context.MODE_PRIVATE); + mDoubleTapToastCount = sp.getInt(DOUBLE_TAP_TOAST_COUNT, + mDoubleTapToastCount); nativeSync(frame.mNativeFrame); mSyncPending = false; mEventHandler.createHandler(); diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 2a92e05bca6ea..910157818779b 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3750,6 +3750,13 @@ public class WebView extends AbsoluteLayout && !mZoomButtonsController.isVisible() && mMinZoomScale < mMaxZoomScale) { mZoomButtonsController.setVisible(true); + int count = settings.getDoubleTapToastCount(); + if (mInZoomOverview && count > 0) { + settings.setDoubleTapToastCount(count--); + Toast.makeText(mContext, + com.android.internal.R.string.double_tap_toast, + Toast.LENGTH_SHORT).show(); + } } } @@ -4522,7 +4529,8 @@ public class WebView extends AbsoluteLayout mZoomCenterY = mLastTouchY; mInZoomOverview = !mInZoomOverview; // remove the zoom control after double tap - if (getSettings().getBuiltInZoomControls()) { + WebSettings settings = getSettings(); + if (settings.getBuiltInZoomControls()) { if (mZoomButtonsController.isVisible()) { mZoomButtonsController.setVisible(false); } @@ -4534,6 +4542,7 @@ public class WebView extends AbsoluteLayout mZoomControls.hide(); } } + settings.setDoubleTapToastCount(0); if (mInZoomOverview) { // Force the titlebar fully reveal in overview mode if (mScrollY < getTitleHeight()) mScrollY = 0; diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index bd79c752fc495..a1a010203c976 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1391,6 +1391,9 @@ Confirm + + Tip: double-tap to zoom in and out. + read Browser\'s history and bookmarks