summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2009-08-13 15:34:06 -0400
committerLeon Scroggins <scroggo@google.com>2009-08-14 13:53:20 -0400
commitc392af2ca70a7d05329c3297cac75f6c64ebcfea (patch)
treef0a7666233e9b8d2f117de8a0f9f5454fa94004b /core
parent1718c45d797f739780733d3f52aa6fcd9db956d9 (diff)
downloadframeworks_base-c392af2ca70a7d05329c3297cac75f6c64ebcfea.zip
frameworks_base-c392af2ca70a7d05329c3297cac75f6c64ebcfea.tar.gz
frameworks_base-c392af2ca70a7d05329c3297cac75f6c64ebcfea.tar.bz2
Hide the title bar when zoomed in.
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/CallbackProxy.java43
-rw-r--r--core/java/android/webkit/WebChromeClient.java9
-rw-r--r--core/java/android/webkit/WebView.java10
3 files changed, 62 insertions, 0 deletions
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java
index 96bf46e..e77d29b 100644
--- a/core/java/android/webkit/CallbackProxy.java
+++ b/core/java/android/webkit/CallbackProxy.java
@@ -70,6 +70,9 @@ class CallbackProxy extends Handler {
private final WebBackForwardList mBackForwardList;
// Used to call startActivity during url override.
private final Context mContext;
+ // Stores the URL being loaded and the viewing mode to switch into when
+ // the URL finishes loading.
+ private ChangeViewModeOnFinishedLoad mChange;
// Message Ids
private static final int PAGE_STARTED = 100;
@@ -177,6 +180,37 @@ class CallbackProxy extends Handler {
}
/**
+ * Tell the host application that the WebView has changed viewing modes.
+ * @param toZoomedOut If true, the WebView has zoomed out so that the page
+ * fits the screen. If false, it is zoomed to the setting
+ * specified by the user.
+ */
+ /* package */ void uiOnChangeViewingMode(boolean toZoomOverview) {
+ if (mWebChromeClient != null) {
+ mWebChromeClient.onChangeViewingMode(toZoomOverview);
+ }
+ }
+
+ private static class ChangeViewModeOnFinishedLoad {
+ boolean mToZoomOverView;
+ String mOriginalUrl;
+ ChangeViewModeOnFinishedLoad(boolean toZoomOverview,
+ String originalUrl) {
+ mToZoomOverView = toZoomOverview;
+ mOriginalUrl = originalUrl;
+ }
+ }
+
+ /**
+ * Keep track of the url and the viewing mode to change into. If/when that
+ * url finishes loading, this will change the viewing mode.
+ */
+ /* package */ void uiChangeViewingModeOnFinishedLoad(
+ boolean toZoomOverview, String originalUrl) {
+ if (mWebChromeClient == null) return;
+ mChange = new ChangeViewModeOnFinishedLoad(toZoomOverview, originalUrl);
+ }
+ /**
* Called by the UI side. Calling overrideUrlLoading from the WebCore
* side will post a message to call this method.
*/
@@ -237,6 +271,15 @@ class CallbackProxy extends Handler {
if (mWebViewClient != null) {
mWebViewClient.onPageFinished(mWebView, (String) msg.obj);
}
+ if (mChange != null) {
+ if (mWebView.getOriginalUrl().equals(mChange.mOriginalUrl)) {
+ uiOnChangeViewingMode(mChange.mToZoomOverView);
+ } else {
+ // The user has gone to a different page, so there is
+ // no need to hang on to the old object.
+ mChange = null;
+ }
+ }
break;
case RECEIVED_ICON:
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index c10bc97..e1c8d4d 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -23,6 +23,15 @@ import android.view.View;
public class WebChromeClient {
/**
+ * Tell the host application that the WebView has changed viewing modes.
+ * @param toZoomedOut If true, the WebView has zoomed out so that the page
+ * fits the screen. If false, it is zoomed to the setting
+ * specified by the user.
+ * @hide
+ */
+ public void onChangeViewingMode(boolean toZoomedOut) {}
+
+ /**
* Tell the host application the current progress of loading a page.
* @param view The WebView that initiated the callback.
* @param newProgress Current page loading progress, represented by
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index be9daa5..7468aef 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -521,6 +521,7 @@ public class WebView extends AbsoluteLayout
// follow the links. Double tap will toggle between zoom overview mode and
// the last zoom scale.
boolean mInZoomOverview = false;
+
// ideally mZoomOverviewWidth should be mContentWidth. But sites like espn,
// engadget always have wider mContentWidth no matter what viewport size is.
int mZoomOverviewWidth = WebViewCore.DEFAULT_VIEWPORT_WIDTH;
@@ -4687,6 +4688,7 @@ public class WebView extends AbsoluteLayout
mZoomCenterX = mLastTouchX;
mZoomCenterY = mLastTouchY;
mInZoomOverview = !mInZoomOverview;
+ mCallbackProxy.uiOnChangeViewingMode(mInZoomOverview);
if (mInZoomOverview) {
if (getSettings().getBuiltInZoomControls()) {
if (mZoomButtonsController.isVisible()) {
@@ -5034,6 +5036,14 @@ public class WebView extends AbsoluteLayout
mInZoomOverview = ENABLE_DOUBLETAP_ZOOM
&& settings.getLoadWithOverviewMode();
}
+ mCallbackProxy.uiOnChangeViewingMode(true);
+ if (!mInZoomOverview) {
+ // We are going to start zoomed in. However, we
+ // truly want to show the title bar, and then hide
+ // it once the page has loaded
+ mCallbackProxy.uiChangeViewingModeOnFinishedLoad(
+ false, getOriginalUrl());
+ }
setNewZoomScale(mLastScale, false);
setContentScrollTo(restoreState.mScrollX,
restoreState.mScrollY);