summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClara Bayarri <clarabayarri@google.com>2015-06-10 16:50:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-10 16:50:46 +0000
commit89124000c618f24b948505cd79f654aacbdff957 (patch)
treef26dbb110c20144e2d45bbfb4bde4ce31d34bad6
parentc7c8af6726eda245288ab1af720297c60cd1be54 (diff)
parentb71ddddfd3d950a723fc8a3e996e6c32f214fad7 (diff)
downloadframeworks_base-89124000c618f24b948505cd79f654aacbdff957.zip
frameworks_base-89124000c618f24b948505cd79f654aacbdff957.tar.gz
frameworks_base-89124000c618f24b948505cd79f654aacbdff957.tar.bz2
Merge "Fix Floating tool bar flickers after long pressing on empty region." into mnc-dev
-rw-r--r--core/java/android/widget/Editor.java43
-rw-r--r--core/java/android/widget/TextView.java11
2 files changed, 33 insertions, 21 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 17ec567..e43237a 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -262,6 +262,8 @@ public class Editor {
}
};
+ boolean mIsInsertionActionModeStartPending = false;
+
Editor(TextView textView) {
mTextView = textView;
// Synchronize the filter list, which places the undo input filter at the end.
@@ -990,7 +992,7 @@ public class Editor {
}
public boolean performLongClick(boolean handled) {
- // Long press in empty space moves cursor and starts the selection action mode.
+ // Long press in empty space moves cursor and starts the insertion action mode.
if (!handled && !isPositionOnText(mLastDownPositionX, mLastDownPositionY) &&
mInsertionControllerEnabled) {
final int offset = mTextView.getOffsetForPosition(mLastDownPositionX,
@@ -998,7 +1000,7 @@ public class Editor {
stopTextActionMode();
Selection.setSelection((Spannable) mTextView.getText(), offset);
getInsertionController().show();
- startInsertionActionMode();
+ mIsInsertionActionModeStartPending = true;
handled = true;
}
@@ -1710,14 +1712,14 @@ public class Editor {
}
/**
- * @return true if the selection mode was actually started.
+ * Start an Insertion action mode.
*/
- private boolean startInsertionActionMode() {
+ void startInsertionActionMode() {
if (mInsertionActionModeRunnable != null) {
mTextView.removeCallbacks(mInsertionActionModeRunnable);
}
if (extractedTextModeWillBeStarted()) {
- return false;
+ return;
}
stopTextActionMode();
@@ -1725,7 +1727,9 @@ public class Editor {
new TextActionModeCallback(false /* hasSelection */);
mTextActionMode = mTextView.startActionMode(
actionModeCallback, ActionMode.TYPE_FLOATING);
- return mTextActionMode != null;
+ if (mTextActionMode != null && getInsertionController() != null) {
+ getInsertionController().show();
+ }
}
/**
@@ -1796,7 +1800,7 @@ public class Editor {
private boolean startSelectionActionModeInternal() {
if (mTextActionMode != null) {
- // Selection action mode is already started
+ // Text action mode is already started
mTextActionMode.invalidate();
return false;
}
@@ -3873,7 +3877,7 @@ public class Editor {
private static final int DELAY_BEFORE_HANDLE_FADES_OUT = 4000;
private static final int RECENT_CUT_COPY_DURATION = 15 * 1000; // seconds
- // Used to detect taps on the insertion handle, which will affect the selection action mode
+ // Used to detect taps on the insertion handle, which will affect the insertion action mode
private float mDownPositionX, mDownPositionY;
private Runnable mHider;
@@ -3898,17 +3902,20 @@ public class Editor {
// timeout has passed.
if (!mDoubleTap && !isCursorInsideEasyCorrectionSpan()
&& (durationSinceCutOrCopy < RECENT_CUT_COPY_DURATION)) {
- if (mInsertionActionModeRunnable == null) {
- mInsertionActionModeRunnable = new Runnable() {
- public void run() {
- startInsertionActionMode();
- }
- };
+ if (mTextActionMode == null) {
+ if (mInsertionActionModeRunnable == null) {
+ mInsertionActionModeRunnable = new Runnable() {
+ @Override
+ public void run() {
+ startInsertionActionMode();
+ }
+ };
+ }
+ mTextView.postDelayed(
+ mInsertionActionModeRunnable,
+ ViewConfiguration.getDoubleTapTimeout() + 1);
}
- mTextView.postDelayed(
- mInsertionActionModeRunnable,
- ViewConfiguration.getDoubleTapTimeout() + 1);
}
hideAfterDelay();
@@ -3975,7 +3982,7 @@ public class Editor {
final int touchSlop = viewConfiguration.getScaledTouchSlop();
if (distanceSquared < touchSlop * touchSlop) {
- // Tapping on the handle toggles the selection action mode.
+ // Tapping on the handle toggles the insertion action mode.
if (mTextActionMode != null) {
mTextActionMode.finish();
} else {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index b68934b..353901c 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8320,12 +8320,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final boolean superResult = super.onTouchEvent(event);
/*
- * Don't handle the release after a long press, because it will
- * move the selection away from whatever the menu action was
- * trying to affect.
+ * Don't handle the release after a long press, because it will move the selection away from
+ * whatever the menu action was trying to affect. If the long press should have triggered an
+ * insertion action mode, we can now actually show it.
*/
if (mEditor != null && mEditor.mDiscardNextActionUp && action == MotionEvent.ACTION_UP) {
mEditor.mDiscardNextActionUp = false;
+
+ if (mEditor.mIsInsertionActionModeStartPending) {
+ mEditor.startInsertionActionMode();
+ mEditor.mIsInsertionActionModeStartPending = false;
+ }
return superResult;
}