diff options
| -rw-r--r-- | api/current.txt | 3 | ||||
| -rw-r--r-- | api/system-current.txt | 3 | ||||
| -rw-r--r-- | api/test-current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 28 | ||||
| -rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 2 | ||||
| -rw-r--r-- | core/java/android/widget/Editor.java | 5 | ||||
| -rw-r--r-- | core/java/android/widget/ListView.java | 4 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 39 |
8 files changed, 40 insertions, 47 deletions
diff --git a/api/current.txt b/api/current.txt index 051ad92630f8..f134786e56e5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -42274,6 +42274,7 @@ package android.view { method public boolean dispatchDragEvent(android.view.DragEvent); method protected void dispatchDraw(android.graphics.Canvas); method public void dispatchDrawableHotspotChanged(float, float); + method public void dispatchFinishTemporaryDetach(); method protected boolean dispatchGenericFocusedEvent(android.view.MotionEvent); method public boolean dispatchGenericMotionEvent(android.view.MotionEvent); method protected boolean dispatchGenericPointerEvent(android.view.MotionEvent); @@ -42293,6 +42294,7 @@ package android.view { method protected void dispatchSetActivated(boolean); method protected void dispatchSetPressed(boolean); method protected void dispatchSetSelected(boolean); + method public void dispatchStartTemporaryDetach(); method public void dispatchSystemUiVisibilityChanged(int); method public boolean dispatchTouchEvent(android.view.MotionEvent); method public boolean dispatchTrackballEvent(android.view.MotionEvent); @@ -42505,6 +42507,7 @@ package android.view { method public boolean isSelected(); method public boolean isShown(); method public boolean isSoundEffectsEnabled(); + method public final boolean isTemporarilyDetached(); method public boolean isTextAlignmentResolved(); method public boolean isTextDirectionResolved(); method public boolean isVerticalFadingEdgeEnabled(); diff --git a/api/system-current.txt b/api/system-current.txt index 8834461ecadb..6414cd1f8d96 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -45014,6 +45014,7 @@ package android.view { method public boolean dispatchDragEvent(android.view.DragEvent); method protected void dispatchDraw(android.graphics.Canvas); method public void dispatchDrawableHotspotChanged(float, float); + method public void dispatchFinishTemporaryDetach(); method protected boolean dispatchGenericFocusedEvent(android.view.MotionEvent); method public boolean dispatchGenericMotionEvent(android.view.MotionEvent); method protected boolean dispatchGenericPointerEvent(android.view.MotionEvent); @@ -45033,6 +45034,7 @@ package android.view { method protected void dispatchSetActivated(boolean); method protected void dispatchSetPressed(boolean); method protected void dispatchSetSelected(boolean); + method public void dispatchStartTemporaryDetach(); method public void dispatchSystemUiVisibilityChanged(int); method public boolean dispatchTouchEvent(android.view.MotionEvent); method public boolean dispatchTrackballEvent(android.view.MotionEvent); @@ -45245,6 +45247,7 @@ package android.view { method public boolean isSelected(); method public boolean isShown(); method public boolean isSoundEffectsEnabled(); + method public final boolean isTemporarilyDetached(); method public boolean isTextAlignmentResolved(); method public boolean isTextDirectionResolved(); method public boolean isVerticalFadingEdgeEnabled(); diff --git a/api/test-current.txt b/api/test-current.txt index 2165b327f6cf..4d860e8b6a20 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -42348,6 +42348,7 @@ package android.view { method public boolean dispatchDragEvent(android.view.DragEvent); method protected void dispatchDraw(android.graphics.Canvas); method public void dispatchDrawableHotspotChanged(float, float); + method public void dispatchFinishTemporaryDetach(); method protected boolean dispatchGenericFocusedEvent(android.view.MotionEvent); method public boolean dispatchGenericMotionEvent(android.view.MotionEvent); method protected boolean dispatchGenericPointerEvent(android.view.MotionEvent); @@ -42367,6 +42368,7 @@ package android.view { method protected void dispatchSetActivated(boolean); method protected void dispatchSetPressed(boolean); method protected void dispatchSetSelected(boolean); + method public void dispatchStartTemporaryDetach(); method public void dispatchSystemUiVisibilityChanged(int); method public boolean dispatchTouchEvent(android.view.MotionEvent); method public boolean dispatchTrackballEvent(android.view.MotionEvent); @@ -42579,6 +42581,7 @@ package android.view { method public boolean isSelected(); method public boolean isShown(); method public boolean isSoundEffectsEnabled(); + method public final boolean isTemporarilyDetached(); method public boolean isTextAlignmentResolved(); method public boolean isTextDirectionResolved(); method public boolean isVerticalFadingEdgeEnabled(); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 117faf0b61ed..b723ffa83eca 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2434,6 +2434,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * 11111111 PFLAG3_POINTER_ICON_MASK * 1 PFLAG3_OVERLAPPING_RENDERING_FORCED_VALUE * 1 PFLAG3_HAS_OVERLAPPING_RENDERING_FORCED + * 1 PFLAG3_TEMPORARY_DETACH * |-------|-------|-------|-------| */ @@ -2667,6 +2668,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private static final int PFLAG3_HAS_OVERLAPPING_RENDERING_FORCED = 0x1000000; + /** + * Flag indicating that the view is temporarily detached from the parent view. + * + * @see #onStartTemporaryDetach() + * @see #onFinishTemporaryDetach() + */ + static final int PFLAG3_TEMPORARY_DETACH = 0x2000000; + /* End of masks for mPrivateFlags3 */ /** @@ -9736,9 +9745,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * @hide + * @return {@code true} when the View is in the state between {@link #onStartTemporaryDetach()} + * and {@link #onFinishTemporaryDetach()}. + */ + public final boolean isTemporarilyDetached() { + return (mPrivateFlags3 & PFLAG3_TEMPORARY_DETACH) != 0; + } + + /** + * Dispatch {@link #onStartTemporaryDetach()} to this View and its direct children if this is + * a container View. */ + @CallSuper public void dispatchStartTemporaryDetach() { + mPrivateFlags3 |= PFLAG3_TEMPORARY_DETACH; onStartTemporaryDetach(); } @@ -9754,10 +9774,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * @hide + * Dispatch {@link #onFinishTemporaryDetach()} to this View and its direct children if this is + * a container View. */ + @CallSuper public void dispatchFinishTemporaryDetach() { onFinishTemporaryDetach(); + mPrivateFlags3 &= ~PFLAG3_TEMPORARY_DETACH; } /** @@ -15188,6 +15211,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, protected void onDetachedFromWindowInternal() { mPrivateFlags &= ~PFLAG_CANCEL_NEXT_UP_EVENT; mPrivateFlags3 &= ~PFLAG3_IS_LAID_OUT; + mPrivateFlags3 &= ~PFLAG3_TEMPORARY_DETACH; removeUnsetPressCallback(); removeLongPressCallback(); diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 7d57cb83f6df..6a4e36a9a578 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -1116,7 +1116,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(focused, direction, previouslyFocusedRect); - if (mTemporaryDetach) { + if (isTemporarilyDetached()) { // If we are temporarily in the detach state, then do nothing. return; } diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 47b034886ad8..6585fd8b3143 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -218,7 +218,6 @@ public class Editor { boolean mShowSoftInputOnFocus = true; private boolean mPreserveSelection; private boolean mRestartActionModeOnNextRefresh; - boolean mTemporaryDetach; boolean mIsBeingLongClicked; @@ -367,7 +366,6 @@ public class Editor { showError(); mShowErrorAfterAttach = false; } - mTemporaryDetach = false; final ViewTreeObserver observer = mTextView.getViewTreeObserver(); // No need to create the controller. @@ -429,7 +427,6 @@ public class Editor { hideCursorAndSpanControllers(); stopTextActionModeWithPreservingSelection(); - mTemporaryDetach = false; } private void discardTextDisplayLists() { @@ -1212,7 +1209,7 @@ public class Editor { stopTextActionModeWithPreservingSelection(); } else { hideCursorAndSpanControllers(); - if (mTemporaryDetach) { + if (mTextView.isTemporarilyDetached()) { stopTextActionModeWithPreservingSelection(); } else { stopTextActionMode(); diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 7658cc894913..bfc87f297d42 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -1673,7 +1673,7 @@ public class ListView extends AbsListView { focusLayoutRestoreView = findFocus(); if (focusLayoutRestoreView != null) { // Tell it we are going to mess with it. - focusLayoutRestoreView.onStartTemporaryDetach(); + focusLayoutRestoreView.dispatchStartTemporaryDetach(); } } requestFocus(); @@ -1850,7 +1850,7 @@ public class ListView extends AbsListView { // our view hierarchy. if (focusLayoutRestoreView != null && focusLayoutRestoreView.getWindowToken() != null) { - focusLayoutRestoreView.onFinishTemporaryDetach(); + focusLayoutRestoreView.dispatchFinishTemporaryDetach(); } mLayoutMode = LAYOUT_NORMAL; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index da0768e4b604..3b7b16dad216 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -330,10 +330,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private int mCurTextColor; private int mCurHintTextColor; private boolean mFreezesText; - private boolean mDispatchTemporaryDetach; - - /** Whether this view is temporarily detached from the parent view. */ - boolean mTemporaryDetach; private Editable.Factory mEditableFactory = Editable.Factory.getInstance(); private Spannable.Factory mSpannableFactory = Spannable.Factory.getInstance(); @@ -5406,8 +5402,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener protected void onAttachedToWindow() { super.onAttachedToWindow(); - mTemporaryDetach = false; - if (mEditor != null) mEditor.onAttachedToWindow(); if (mPreDrawListenerDetached) { @@ -8366,40 +8360,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } - /** - * @hide - */ - @Override - public void dispatchFinishTemporaryDetach() { - mDispatchTemporaryDetach = true; - super.dispatchFinishTemporaryDetach(); - mDispatchTemporaryDetach = false; - } - - @Override - public void onStartTemporaryDetach() { - super.onStartTemporaryDetach(); - // Only track when onStartTemporaryDetach() is called directly, - // usually because this instance is an editable field in a list - if (!mDispatchTemporaryDetach) mTemporaryDetach = true; - - // Tell the editor that we are temporarily detached. It can use this to preserve - // selection state as needed. - if (mEditor != null) mEditor.mTemporaryDetach = true; - } - - @Override - public void onFinishTemporaryDetach() { - super.onFinishTemporaryDetach(); - // Only track when onStartTemporaryDetach() is called directly, - // usually because this instance is an editable field in a list - if (!mDispatchTemporaryDetach) mTemporaryDetach = false; - if (mEditor != null) mEditor.mTemporaryDetach = false; - } - @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { - if (mTemporaryDetach) { + if (isTemporarilyDetached()) { // If we are temporarily in the detach state, then do nothing. super.onFocusChanged(focused, direction, previouslyFocusedRect); return; |