Merge "Move mLastInputSource member to TextView from Editor"
This commit is contained in:
@@ -226,8 +226,6 @@ public class Editor {
|
||||
final UndoInputFilter mUndoInputFilter = new UndoInputFilter(this);
|
||||
boolean mAllowUndo = true;
|
||||
|
||||
private int mLastInputSource = InputDevice.SOURCE_UNKNOWN;
|
||||
|
||||
private final MetricsLogger mMetricsLogger = new MetricsLogger();
|
||||
|
||||
// Cursor Controllers.
|
||||
@@ -1735,8 +1733,6 @@ public class Editor {
|
||||
public void onTouchEvent(MotionEvent event) {
|
||||
final boolean filterOutEvent = shouldFilterOutTouchEvent(event);
|
||||
|
||||
mLastInputSource = event.getSource();
|
||||
|
||||
mLastButtonState = event.getButtonState();
|
||||
if (filterOutEvent) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
|
||||
@@ -1789,7 +1785,7 @@ public class Editor {
|
||||
}
|
||||
|
||||
private void showFloatingToolbar() {
|
||||
if (mTextActionMode != null && showUIForTouchScreen()) {
|
||||
if (mTextActionMode != null && mTextView.showUIForTouchScreen()) {
|
||||
// Delay "show" so it doesn't interfere with click confirmations
|
||||
// or double-clicks that could "dismiss" the floating toolbar.
|
||||
int delay = ViewConfiguration.getDoubleTapTimeout();
|
||||
@@ -1870,7 +1866,7 @@ public class Editor {
|
||||
? getSelectionController() : getInsertionController();
|
||||
if (cursorController != null && !cursorController.isActive()
|
||||
&& !cursorController.isCursorBeingModified()
|
||||
&& showUIForTouchScreen()) {
|
||||
&& mTextView.showUIForTouchScreen()) {
|
||||
cursorController.show();
|
||||
}
|
||||
}
|
||||
@@ -2521,7 +2517,7 @@ public class Editor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!showUIForTouchScreen()) {
|
||||
if (!mTextView.showUIForTouchScreen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2677,7 +2673,7 @@ public class Editor {
|
||||
mTextView.postDelayed(mShowSuggestionRunnable,
|
||||
ViewConfiguration.getDoubleTapTimeout());
|
||||
} else if (hasInsertionController()) {
|
||||
if (shouldInsertCursor && showUIForTouchScreen()) {
|
||||
if (shouldInsertCursor && mTextView.showUIForTouchScreen()) {
|
||||
getInsertionController().show();
|
||||
} else {
|
||||
getInsertionController().hide();
|
||||
@@ -5408,7 +5404,7 @@ public class Editor {
|
||||
final boolean shouldShow = checkForTransforms() /*check not rotated and compute scale*/
|
||||
&& !tooLargeTextForMagnifier()
|
||||
&& obtainMagnifierShowCoordinates(event, showPosInView)
|
||||
&& showUIForTouchScreen();
|
||||
&& mTextView.showUIForTouchScreen();
|
||||
if (shouldShow) {
|
||||
// Make the cursor visible and stop blinking.
|
||||
mRenderCursorRegardlessTiming = true;
|
||||
@@ -6354,16 +6350,6 @@ public class Editor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when need to show UIs, e.g. floating toolbar, etc, for finger based interaction.
|
||||
*
|
||||
* @return true if UIs need to show for finger interaciton. false if UIs are not necessary.
|
||||
*/
|
||||
public boolean showUIForTouchScreen() {
|
||||
return (mLastInputSource & InputDevice.SOURCE_TOUCHSCREEN)
|
||||
== InputDevice.SOURCE_TOUCHSCREEN;
|
||||
}
|
||||
|
||||
/** Controller for the insertion cursor. */
|
||||
@VisibleForTesting
|
||||
public class InsertionPointCursorController implements CursorController {
|
||||
|
||||
@@ -301,7 +301,7 @@ public final class SelectionActionModeHelper {
|
||||
final SelectionModifierCursorController controller = mEditor.getSelectionController();
|
||||
if (controller != null
|
||||
&& (mTextView.isTextSelectable() || mTextView.isTextEditable())) {
|
||||
if (mEditor.showUIForTouchScreen()) {
|
||||
if (mTextView.showUIForTouchScreen()) {
|
||||
controller.show();
|
||||
} else {
|
||||
controller.hide();
|
||||
|
||||
@@ -972,6 +972,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
*/
|
||||
private int mDeviceProvisionedState = DEVICE_PROVISIONED_UNKNOWN;
|
||||
|
||||
/**
|
||||
* The last input source on this TextView.
|
||||
*/
|
||||
private int mLastInputSource = InputDevice.SOURCE_UNKNOWN;
|
||||
|
||||
/**
|
||||
* The TextView does not auto-size text (default).
|
||||
*/
|
||||
@@ -11565,6 +11570,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
MotionEvent.actionToString(event.getActionMasked()),
|
||||
event.getX(), event.getY());
|
||||
}
|
||||
mLastInputSource = event.getSource();
|
||||
final int action = event.getActionMasked();
|
||||
if (mEditor != null) {
|
||||
if (!isFromPrimePointer(event, false)) {
|
||||
@@ -11653,6 +11659,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
return superResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when need to show UIs, e.g. floating toolbar, etc, for finger based interaction.
|
||||
*
|
||||
* @return true if UIs need to show for finger interaciton. false if UIs are not necessary.
|
||||
* @hide
|
||||
*/
|
||||
public final boolean showUIForTouchScreen() {
|
||||
return (mLastInputSource & InputDevice.SOURCE_TOUCHSCREEN)
|
||||
== InputDevice.SOURCE_TOUCHSCREEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* The fill dialog UI is a more conspicuous and efficient interface than dropdown UI.
|
||||
* If autofill suggestions are available when the user clicks on a field that supports filling
|
||||
|
||||
Reference in New Issue
Block a user