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
This commit is contained in:
Leon Scroggins
2009-11-19 13:47:46 -05:00
parent 1e914ac7fc
commit ecfc0eba60

View File

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