Add a tip toast for double tap.

Fix http://b/issue?id=2059934
This commit is contained in:
Grace Kloba
2009-09-20 15:57:49 -07:00
parent d5ffa12dea
commit f8d8b46a2c
3 changed files with 49 additions and 1 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -1391,6 +1391,9 @@
<!-- Title of the WebView save password dialog. If the user enters a password in a form on a website, a dialog will come up asking if they want to save the password. -->
<string name="save_password_label">Confirm</string>
<!-- Toast for double-tap -->
<string name="double_tap_toast">Tip: double-tap to zoom in and out.</string>
<!-- Title of an application permission, listed so the user can choose whether
they want to allow the application to do this. -->
<string name="permlab_readHistoryBookmarks">read Browser\'s history and bookmarks</string>