Fix toolbar flickering in ExtractedMode when longpressing.
onPreDraw starts an action mode in extract mode only which does not consider the type of motion event and since extracted mode never gets the focus event it never hides so it does not need to show again. Stop starting an action mode onPreDraw in extracted mode and let the onTouchEvent handle starting the mode. Also re-enabled dragging and dropping for ExtractedMode (most of the issues were caused by starting the action mode onPreDraw). Bug: 25102276 Change-Id: I90d8e9f42f395b6b529e4d023ba6939e0dfb147f
This commit is contained in:
@@ -16,12 +16,6 @@
|
||||
|
||||
package android.widget;
|
||||
|
||||
import java.text.BreakIterator;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import android.R;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.PendingIntent;
|
||||
@@ -112,6 +106,12 @@ import com.android.internal.util.GrowingArrayUtils;
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.internal.widget.EditableInputConnection;
|
||||
|
||||
import java.text.BreakIterator;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Helper class used by TextView to handle editable text views.
|
||||
@@ -1004,8 +1004,7 @@ public class Editor {
|
||||
}
|
||||
|
||||
if (!handled && mTextActionMode != null) {
|
||||
// TODO: Fix dragging in extracted mode.
|
||||
if (touchPositionIsInSelection() && !mTextView.isInExtractedMode()) {
|
||||
if (touchPositionIsInSelection()) {
|
||||
// Start a drag
|
||||
final int start = mTextView.getSelectionStart();
|
||||
final int end = mTextView.getSelectionEnd();
|
||||
@@ -4860,9 +4859,8 @@ public class Editor {
|
||||
mEndHandle.showAtLocation(endOffset);
|
||||
|
||||
// No longer the first dragging motion, reset.
|
||||
if (!(mTextView.isInExtractedMode())) {
|
||||
startSelectionActionMode();
|
||||
}
|
||||
startSelectionActionMode();
|
||||
|
||||
mDragAcceleratorActive = false;
|
||||
mStartOffset = -1;
|
||||
mSwitchedLines = false;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.widget;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
|
||||
|
||||
import android.R;
|
||||
import android.annotation.ColorInt;
|
||||
import android.annotation.DrawableRes;
|
||||
@@ -115,14 +117,14 @@ import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.view.ViewStructure;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewRootImpl;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.ViewHierarchyEncoder;
|
||||
import android.view.ViewParent;
|
||||
import android.view.ViewRootImpl;
|
||||
import android.view.ViewStructure;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
@@ -149,8 +151,6 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
|
||||
|
||||
/**
|
||||
* Displays text to the user and optionally allows them to edit it. A TextView
|
||||
* is a complete text editor, however the basic class is configured to not
|
||||
@@ -5243,14 +5243,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
mEditor.mCreatedWithASelection = false;
|
||||
}
|
||||
|
||||
// Phone specific code (there is no ExtractEditText on tablets).
|
||||
// ExtractEditText does not call onFocus when it is displayed, and mHasSelectionOnFocus can
|
||||
// not be set. Do the test here instead.
|
||||
if (isInExtractedMode() && hasSelection() && mEditor != null
|
||||
&& mEditor.mTextActionMode == null && isShown() && hasWindowFocus()) {
|
||||
mEditor.startSelectionActionMode();
|
||||
}
|
||||
|
||||
unregisterForPreDraw();
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user