Merge "Line up textfield with WebTextView more often." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
36cb18cf06
@@ -288,6 +288,21 @@ import java.util.ArrayList;
|
|||||||
return ptr == mNodePointer;
|
return ptr == mNodePointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that the underlying textfield is lined up with the WebTextView.
|
||||||
|
*/
|
||||||
|
private void lineUpScroll() {
|
||||||
|
if (mWebView != null) {
|
||||||
|
float maxScrollX = Touch.getMaxScrollX(this, getLayout(), mScrollY);
|
||||||
|
if (DebugFlags.WEB_TEXT_VIEW) {
|
||||||
|
Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y="
|
||||||
|
+ mScrollY + " maxX=" + maxScrollX);
|
||||||
|
}
|
||||||
|
mWebView.scrollFocusedTextInput(maxScrollX > 0 ?
|
||||||
|
mScrollX / maxScrollX : 0, mScrollY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override public InputConnection onCreateInputConnection(
|
@Override public InputConnection onCreateInputConnection(
|
||||||
EditorInfo outAttrs) {
|
EditorInfo outAttrs) {
|
||||||
InputConnection connection = super.onCreateInputConnection(outAttrs);
|
InputConnection connection = super.onCreateInputConnection(outAttrs);
|
||||||
@@ -358,6 +373,12 @@ import java.util.ArrayList;
|
|||||||
mFromFocusChange = false;
|
mFromFocusChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||||
|
super.onScrollChanged(l, t, oldl, oldt);
|
||||||
|
lineUpScroll();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSelectionChanged(int selStart, int selEnd) {
|
protected void onSelectionChanged(int selStart, int selEnd) {
|
||||||
if (mInSetTextAndKeepSelection) return;
|
if (mInSetTextAndKeepSelection) return;
|
||||||
@@ -378,6 +399,7 @@ import java.util.ArrayList;
|
|||||||
+ " selEnd=" + selEnd);
|
+ " selEnd=" + selEnd);
|
||||||
}
|
}
|
||||||
mWebView.setSelection(selStart, selEnd);
|
mWebView.setSelection(selStart, selEnd);
|
||||||
|
lineUpScroll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,16 +503,7 @@ import java.util.ArrayList;
|
|||||||
// to big for the case of a small textfield.
|
// to big for the case of a small textfield.
|
||||||
int smallerSlop = slop/2;
|
int smallerSlop = slop/2;
|
||||||
if (dx > smallerSlop || dy > smallerSlop) {
|
if (dx > smallerSlop || dy > smallerSlop) {
|
||||||
if (mWebView != null) {
|
// Scrolling is handled in onScrollChanged.
|
||||||
float maxScrollX = (float) Touch.getMaxScrollX(this,
|
|
||||||
getLayout(), mScrollY);
|
|
||||||
if (DebugFlags.WEB_TEXT_VIEW) {
|
|
||||||
Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y="
|
|
||||||
+ mScrollY + " maxX=" + maxScrollX);
|
|
||||||
}
|
|
||||||
mWebView.scrollFocusedTextInput(maxScrollX > 0 ?
|
|
||||||
mScrollX / maxScrollX : 0, mScrollY);
|
|
||||||
}
|
|
||||||
mScrolled = true;
|
mScrolled = true;
|
||||||
cancelLongPress();
|
cancelLongPress();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user