summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/widget/Editor.java24
-rw-r--r--core/java/android/widget/SelectionActionModeHelper.java2
-rw-r--r--core/java/android/widget/TextView.java17
3 files changed, 23 insertions, 20 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 6825f034f5b3..f93b8b7c1b5f 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -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 {
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index 4ccd77b2713e..be6b08fbddae 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -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();
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 28b83b2068ba..f53dd0c53ef5 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -973,6 +973,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).
*/
public static final int AUTO_SIZE_TEXT_TYPE_NONE = 0;
@@ -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)) {
@@ -11654,6 +11660,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
/**
+ * 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
* the dialog UI, Autofill will pop up a fill dialog. The dialog will take up a larger area