summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Leon Scroggins <scroggo@google.com> 2009-11-19 13:47:46 -0500
committer Leon Scroggins <scroggo@google.com> 2009-11-24 09:21:48 -0500
commitecfc0eba609f88579ea5b70c57e6763ee3a28e5d (patch)
tree429b7d3268790245334020b559e66d202bdfb1b2
parent1e914ac7fce9523b5a932389798589eba91ca4dd (diff)
Fix soft keyboard dismissing itself when zooming into a textfield in browser.
We remove the WebTextView while zooming. If the WebTextView ended up offscreen, we remove it completely, thus hiding the IME. In some cases, however, the WebTextView is only offscreen because the IME overlapped it. Check to see if the IME is showing, and if so, adjust the WebTextView and let it get scrolled into view. Also perform the removal/change in text size inside the method, so it happens in both places. Lastly, do not call didUpdateTextViewBounds if there is no WebTextView. Fix for http://b/issue?id=2266066
-rw-r--r--core/java/android/webkit/WebView.java46
1 files changed, 26 insertions, 20 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 8dc2ce63e196..77943d859b49 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2923,12 +2923,27 @@ public class WebView extends AbsoluteLayout
Rect vBox = contentToViewRect(contentBounds);
Rect visibleRect = new Rect();
calcOurVisibleRect(visibleRect);
- if (allowIntersect ? Rect.intersects(visibleRect, vBox) :
- visibleRect.contains(vBox)) {
+ // The IME may have shown, resulting in the textfield being offscreen.
+ // If so, the textfield will be scrolled on screen, so treat it as
+ // though it is on screen. If it is on screen, place the WebTextView in
+ // its new place, accounting for our new scroll/zoom values.
+ InputMethodManager imm = InputMethodManager.peekInstance();
+ if ((imm != null && imm.isActive(mWebTextView))
+ || (allowIntersect ? Rect.intersects(visibleRect, vBox)
+ : visibleRect.contains(vBox))) {
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(),
vBox.height());
+ mWebTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
+ contentToViewDimension(
+ nativeFocusCandidateTextSize()));
return true;
} else {
+ // The textfield is now off screen. The user probably
+ // was not zooming to see the textfield better. Remove
+ // the WebTextView. If the user types a key, and the
+ // textfield is still in focus, we will reconstruct
+ // the WebTextView and scroll it back on screen.
+ mWebTextView.remove();
return false;
}
}
@@ -2974,25 +2989,11 @@ public class WebView extends AbsoluteLayout
invalidate();
if (mNeedToAdjustWebTextView) {
mNeedToAdjustWebTextView = false;
- // As a result of the zoom, the textfield is now on
- // screen. Place the WebTextView in its new place,
- // accounting for our new scroll/zoom values.
- if (didUpdateTextViewBounds(false)) {
- mWebTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- contentToViewDimension(
- nativeFocusCandidateTextSize()));
+ if (didUpdateTextViewBounds(false)
+ && nativeFocusCandidateIsPassword()) {
// If it is a password field, start drawing the
// WebTextView once again.
- if (nativeFocusCandidateIsPassword()) {
- mWebTextView.setInPassword(true);
- }
- } else {
- // The textfield is now off screen. The user probably
- // was not zooming to see the textfield better. Remove
- // the WebTextView. If the user types a key, and the
- // textfield is still in focus, we will reconstruct
- // the WebTextView and scroll it back on screen.
- mWebTextView.remove();
+ mWebTextView.setInPassword(true);
}
}
}
@@ -3059,7 +3060,12 @@ public class WebView extends AbsoluteLayout
}
if (mFocusSizeChanged) {
mFocusSizeChanged = false;
- didUpdateTextViewBounds(true);
+ // If we are zooming, this will get handled above, when the zoom
+ // finishes. We also do not need to do this unless the WebTextView
+ // is showing.
+ if (!animateZoom && inEditingMode()) {
+ didUpdateTextViewBounds(true);
+ }
}
}