Loading core/java/android/widget/Editor.java +24 −4 Original line number Diff line number Diff line Loading @@ -226,6 +226,8 @@ public class Editor { final UndoInputFilter mUndoInputFilter = new UndoInputFilter(this); boolean mAllowUndo = true; private int mLastToolType = MotionEvent.TOOL_TYPE_UNKNOWN; private final MetricsLogger mMetricsLogger = new MetricsLogger(); // Cursor Controllers. Loading Loading @@ -1732,6 +1734,9 @@ public class Editor { @VisibleForTesting public void onTouchEvent(MotionEvent event) { final boolean filterOutEvent = shouldFilterOutTouchEvent(event); mLastToolType = event.getToolType(event.getActionIndex()); mLastButtonState = event.getButtonState(); if (filterOutEvent) { if (event.getActionMasked() == MotionEvent.ACTION_UP) { Loading Loading @@ -1784,7 +1789,7 @@ public class Editor { } private void showFloatingToolbar() { if (mTextActionMode != null) { if (mTextActionMode != null && showUIForFingerInput()) { // Delay "show" so it doesn't interfere with click confirmations // or double-clicks that could "dismiss" the floating toolbar. int delay = ViewConfiguration.getDoubleTapTimeout(); Loading Loading @@ -1864,7 +1869,8 @@ public class Editor { final CursorController cursorController = mTextView.hasSelection() ? getSelectionController() : getInsertionController(); if (cursorController != null && !cursorController.isActive() && !cursorController.isCursorBeingModified()) { && !cursorController.isCursorBeingModified() && showUIForFingerInput()) { cursorController.show(); } } Loading Loading @@ -2515,6 +2521,10 @@ public class Editor { return false; } if (!showUIForFingerInput()) { return false; } ActionMode.Callback actionModeCallback = new TextActionModeCallback(actionMode); mTextActionMode = mTextView.startActionMode(actionModeCallback, ActionMode.TYPE_FLOATING); registerOnBackInvokedCallback(); Loading Loading @@ -2667,7 +2677,7 @@ public class Editor { mTextView.postDelayed(mShowSuggestionRunnable, ViewConfiguration.getDoubleTapTimeout()); } else if (hasInsertionController()) { if (shouldInsertCursor) { if (shouldInsertCursor && showUIForFingerInput()) { getInsertionController().show(); } else { getInsertionController().hide(); Loading Loading @@ -5397,7 +5407,8 @@ public class Editor { final PointF showPosInView = new PointF(); final boolean shouldShow = checkForTransforms() /*check not rotated and compute scale*/ && !tooLargeTextForMagnifier() && obtainMagnifierShowCoordinates(event, showPosInView); && obtainMagnifierShowCoordinates(event, showPosInView) && showUIForFingerInput(); if (shouldShow) { // Make the cursor visible and stop blinking. mRenderCursorRegardlessTiming = true; Loading Loading @@ -6343,6 +6354,15 @@ 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 showUIForFingerInput() { return mLastToolType != MotionEvent.TOOL_TYPE_MOUSE; } /** Controller for the insertion cursor. */ @VisibleForTesting public class InsertionPointCursorController implements CursorController { Loading core/java/android/widget/SelectionActionModeHelper.java +5 −1 Original line number Diff line number Diff line Loading @@ -301,7 +301,11 @@ public final class SelectionActionModeHelper { final SelectionModifierCursorController controller = mEditor.getSelectionController(); if (controller != null && (mTextView.isTextSelectable() || mTextView.isTextEditable())) { if (mEditor.showUIForFingerInput()) { controller.show(); } else { controller.hide(); } } if (result != null) { switch (actionMode) { Loading Loading
core/java/android/widget/Editor.java +24 −4 Original line number Diff line number Diff line Loading @@ -226,6 +226,8 @@ public class Editor { final UndoInputFilter mUndoInputFilter = new UndoInputFilter(this); boolean mAllowUndo = true; private int mLastToolType = MotionEvent.TOOL_TYPE_UNKNOWN; private final MetricsLogger mMetricsLogger = new MetricsLogger(); // Cursor Controllers. Loading Loading @@ -1732,6 +1734,9 @@ public class Editor { @VisibleForTesting public void onTouchEvent(MotionEvent event) { final boolean filterOutEvent = shouldFilterOutTouchEvent(event); mLastToolType = event.getToolType(event.getActionIndex()); mLastButtonState = event.getButtonState(); if (filterOutEvent) { if (event.getActionMasked() == MotionEvent.ACTION_UP) { Loading Loading @@ -1784,7 +1789,7 @@ public class Editor { } private void showFloatingToolbar() { if (mTextActionMode != null) { if (mTextActionMode != null && showUIForFingerInput()) { // Delay "show" so it doesn't interfere with click confirmations // or double-clicks that could "dismiss" the floating toolbar. int delay = ViewConfiguration.getDoubleTapTimeout(); Loading Loading @@ -1864,7 +1869,8 @@ public class Editor { final CursorController cursorController = mTextView.hasSelection() ? getSelectionController() : getInsertionController(); if (cursorController != null && !cursorController.isActive() && !cursorController.isCursorBeingModified()) { && !cursorController.isCursorBeingModified() && showUIForFingerInput()) { cursorController.show(); } } Loading Loading @@ -2515,6 +2521,10 @@ public class Editor { return false; } if (!showUIForFingerInput()) { return false; } ActionMode.Callback actionModeCallback = new TextActionModeCallback(actionMode); mTextActionMode = mTextView.startActionMode(actionModeCallback, ActionMode.TYPE_FLOATING); registerOnBackInvokedCallback(); Loading Loading @@ -2667,7 +2677,7 @@ public class Editor { mTextView.postDelayed(mShowSuggestionRunnable, ViewConfiguration.getDoubleTapTimeout()); } else if (hasInsertionController()) { if (shouldInsertCursor) { if (shouldInsertCursor && showUIForFingerInput()) { getInsertionController().show(); } else { getInsertionController().hide(); Loading Loading @@ -5397,7 +5407,8 @@ public class Editor { final PointF showPosInView = new PointF(); final boolean shouldShow = checkForTransforms() /*check not rotated and compute scale*/ && !tooLargeTextForMagnifier() && obtainMagnifierShowCoordinates(event, showPosInView); && obtainMagnifierShowCoordinates(event, showPosInView) && showUIForFingerInput(); if (shouldShow) { // Make the cursor visible and stop blinking. mRenderCursorRegardlessTiming = true; Loading Loading @@ -6343,6 +6354,15 @@ 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 showUIForFingerInput() { return mLastToolType != MotionEvent.TOOL_TYPE_MOUSE; } /** Controller for the insertion cursor. */ @VisibleForTesting public class InsertionPointCursorController implements CursorController { Loading
core/java/android/widget/SelectionActionModeHelper.java +5 −1 Original line number Diff line number Diff line Loading @@ -301,7 +301,11 @@ public final class SelectionActionModeHelper { final SelectionModifierCursorController controller = mEditor.getSelectionController(); if (controller != null && (mTextView.isTextSelectable() || mTextView.isTextEditable())) { if (mEditor.showUIForFingerInput()) { controller.show(); } else { controller.hide(); } } if (result != null) { switch (actionMode) { Loading