summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michael Kolb <kolby@google.com> 2011-02-05 13:53:14 -0800
committer Michael Kolb <kolby@google.com> 2011-02-10 15:51:20 -0800
commitc4ca53fedf6cd08103033b646d242b0a11f9e5a9 (patch)
tree1b4b15cda609c47c5d4b5e803390e3c2a04caa7a
parented6d936eca072b729b1a52204dca1dcecdfc8f66 (diff)
Add title bar gravity
Enable rendering of the embedded title bar at the top of the page or at the top of the screen Change-Id: Ic979b641c8cc80acb83eeab49c4f700fc5c50e72
-rw-r--r--core/java/android/webkit/WebView.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index de263b133618..18870a2077f0 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -1187,7 +1187,7 @@ public class WebView extends AbsoluteLayout
if (AccessibilityManager.getInstance(mContext).isEnabled()
&& getSettings().getJavaScriptEnabled()) {
// exposing the TTS for now ...
- mTextToSpeech = new TextToSpeech(getContext(), null);
+ mTextToSpeech = new TextToSpeech(getContext(), null);
addJavascriptInterface(mTextToSpeech, ALIAS_ACCESSIBILITY_JS_INTERFACE);
}
}
@@ -2323,6 +2323,11 @@ public class WebView extends AbsoluteLayout
private View mTitleBar;
/**
+ * the title bar rendering gravity
+ */
+ private int mTitleGravity;
+
+ /**
* Add or remove a title bar to be embedded into the WebView, and scroll
* along with it vertically, while remaining in view horizontally. Pass
* null to remove the title bar from the WebView, and return to drawing
@@ -2343,6 +2348,16 @@ public class WebView extends AbsoluteLayout
}
/**
+ * Set where to render the embedded title bar
+ * NO_GRAVITY at the top of the page
+ * TOP at the top of the screen
+ * @hide
+ */
+ public void setTitleBarGravity(int gravity) {
+ mTitleGravity = gravity;
+ }
+
+ /**
* Given a distance in view space, convert it to content space. Note: this
* does not reflect translation, just scaling, so this should not be called
* with coordinates, but should be called for dimensions like width or
@@ -3683,7 +3698,12 @@ public class WebView extends AbsoluteLayout
// When drawing the title bar, move it horizontally to always show
// at the top of the WebView.
mTitleBar.offsetLeftAndRight(mScrollX - mTitleBar.getLeft());
- int newTop = Math.min(0, mScrollY);
+ int newTop = 0;
+ if (mTitleGravity == Gravity.NO_GRAVITY) {
+ newTop = Math.min(0, mScrollY);
+ } else if (mTitleGravity == Gravity.TOP) {
+ newTop = mScrollY;
+ }
mTitleBar.setBottom(newTop + getTitleHeight());
mTitleBar.setTop(newTop);
}
@@ -3842,7 +3862,7 @@ public class WebView extends AbsoluteLayout
if (detector != null && detector.isInProgress()) {
return false;
}
-
+
if (mNativeClass != 0 && nativeCursorIsTextInput()) {
// Send the click so that the textfield is in focus
centerKeyPressOnTextField();