Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -43430,6 +43430,7 @@ package android.view { method public static int resolveSize(int, int); method public static int resolveSizeAndState(int, int, int); method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public boolean restoreLastFocus(); method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); method public void scrollBy(int, int); api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -46605,6 +46605,7 @@ package android.view { method public static int resolveSize(int, int); method public static int resolveSizeAndState(int, int, int); method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public boolean restoreLastFocus(); method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); method public void scrollBy(int, int); api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -43720,6 +43720,7 @@ package android.view { method public static int resolveSize(int, int); method public static int resolveSizeAndState(int, int, int); method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public boolean restoreLastFocus(); method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); method public void scrollBy(int, int); core/java/android/view/View.java +15 −0 Original line number Diff line number Diff line Loading @@ -6106,6 +6106,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (mParent != null) { mParent.requestChildFocus(this, this); if (!isKeyboardNavigationCluster() && mParent instanceof ViewGroup) { ((ViewGroup) mParent).saveFocus(); } } if (mAttachInfo != null) { Loading Loading @@ -9440,6 +9443,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return requestFocus(View.FOCUS_DOWN); } /** * Gives focus to the last focused view in the view hierarchy that has this view as a root. * If the last focused view cannot be found, fall back to calling {@link #requestFocus()}. * Nested keyboard navigation clusters are excluded from the hierarchy considered for saving the * last focus. * * @return Whether this view or one of its descendants actually took focus. */ public boolean restoreLastFocus() { return requestFocus(); } /** * Call this to try to give focus to a specific view or to one of its * descendants and give it a hint about what direction focus is heading. Loading core/java/android/view/ViewGroup.java +46 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // The view contained within this ViewGroup that has or contains focus. private View mFocused; // The last view contained within this ViewGroup (excluding nested keyboard navigation clusters) // that had or contained focus. private View mLastFocused; /** * A Transformation used when drawing children, to Loading Loading @@ -719,6 +722,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (mFocused != null) { mFocused.unFocus(this); mFocused = null; mLastFocused = null; } super.handleFocusGainInternal(direction, previouslyFocusedRect); } Loading Loading @@ -748,6 +752,20 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } } /** * Saves the current focus as the last focus for this view and all its ancestors. * If the view is inside a keyboard navigation cluster, stops at the root of the cluster since * the cluster forms a separate keyboard navigation hierarchy from the focus saving point of * view. */ void saveFocus() { mLastFocused = mFocused; if (!isKeyboardNavigationCluster() && mParent instanceof ViewGroup) { ((ViewGroup) mParent).saveFocus(); } } @Override public void focusableViewAvailable(View v) { if (mParent != null Loading Loading @@ -3045,6 +3063,17 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return false; } @Override public boolean restoreLastFocus() { if (mLastFocused != null && !mLastFocused.isKeyboardNavigationCluster() && getDescendantFocusability() != FOCUS_BLOCK_DESCENDANTS && (mLastFocused.mViewFlags & VISIBILITY_MASK) == VISIBLE && mLastFocused.restoreLastFocus()) { return true; } return super.restoreLastFocus(); } /** * {@inheritDoc} * Loading Loading @@ -4897,6 +4926,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager view.unFocus(null); clearChildFocus = true; } if (view == mLastFocused) { mLastFocused = null; } view.clearAccessibilityFocus(); Loading Loading @@ -5007,6 +5039,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager view.unFocus(null); clearChildFocus = true; } if (view == mLastFocused) { mLastFocused = null; } view.clearAccessibilityFocus(); Loading Loading @@ -5080,6 +5115,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager boolean clearChildFocus = false; needGlobalAttributesUpdate(false); mLastFocused = null; for (int i = count - 1; i >= 0; i--) { final View view = children[i]; Loading Loading @@ -5151,6 +5187,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (child == mFocused) { child.clearFocus(); } if (child == mLastFocused) { mLastFocused = null; } child.clearAccessibilityFocus(); Loading Loading @@ -6153,6 +6192,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager output = debugIndent(depth); output += "mFocused"; Log.d(VIEW_LOG_TAG, output); mFocused.debug(depth + 1); } if (mLastFocused != null) { output = debugIndent(depth); output += "mLastFocused"; Log.d(VIEW_LOG_TAG, output); mLastFocused.debug(depth + 1); } if (mChildrenCount != 0) { output = debugIndent(depth); Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -43430,6 +43430,7 @@ package android.view { method public static int resolveSize(int, int); method public static int resolveSizeAndState(int, int, int); method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public boolean restoreLastFocus(); method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); method public void scrollBy(int, int);
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -46605,6 +46605,7 @@ package android.view { method public static int resolveSize(int, int); method public static int resolveSizeAndState(int, int, int); method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public boolean restoreLastFocus(); method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); method public void scrollBy(int, int);
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -43720,6 +43720,7 @@ package android.view { method public static int resolveSize(int, int); method public static int resolveSizeAndState(int, int, int); method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public boolean restoreLastFocus(); method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); method public void scrollBy(int, int);
core/java/android/view/View.java +15 −0 Original line number Diff line number Diff line Loading @@ -6106,6 +6106,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (mParent != null) { mParent.requestChildFocus(this, this); if (!isKeyboardNavigationCluster() && mParent instanceof ViewGroup) { ((ViewGroup) mParent).saveFocus(); } } if (mAttachInfo != null) { Loading Loading @@ -9440,6 +9443,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return requestFocus(View.FOCUS_DOWN); } /** * Gives focus to the last focused view in the view hierarchy that has this view as a root. * If the last focused view cannot be found, fall back to calling {@link #requestFocus()}. * Nested keyboard navigation clusters are excluded from the hierarchy considered for saving the * last focus. * * @return Whether this view or one of its descendants actually took focus. */ public boolean restoreLastFocus() { return requestFocus(); } /** * Call this to try to give focus to a specific view or to one of its * descendants and give it a hint about what direction focus is heading. Loading
core/java/android/view/ViewGroup.java +46 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // The view contained within this ViewGroup that has or contains focus. private View mFocused; // The last view contained within this ViewGroup (excluding nested keyboard navigation clusters) // that had or contained focus. private View mLastFocused; /** * A Transformation used when drawing children, to Loading Loading @@ -719,6 +722,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (mFocused != null) { mFocused.unFocus(this); mFocused = null; mLastFocused = null; } super.handleFocusGainInternal(direction, previouslyFocusedRect); } Loading Loading @@ -748,6 +752,20 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } } /** * Saves the current focus as the last focus for this view and all its ancestors. * If the view is inside a keyboard navigation cluster, stops at the root of the cluster since * the cluster forms a separate keyboard navigation hierarchy from the focus saving point of * view. */ void saveFocus() { mLastFocused = mFocused; if (!isKeyboardNavigationCluster() && mParent instanceof ViewGroup) { ((ViewGroup) mParent).saveFocus(); } } @Override public void focusableViewAvailable(View v) { if (mParent != null Loading Loading @@ -3045,6 +3063,17 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return false; } @Override public boolean restoreLastFocus() { if (mLastFocused != null && !mLastFocused.isKeyboardNavigationCluster() && getDescendantFocusability() != FOCUS_BLOCK_DESCENDANTS && (mLastFocused.mViewFlags & VISIBILITY_MASK) == VISIBLE && mLastFocused.restoreLastFocus()) { return true; } return super.restoreLastFocus(); } /** * {@inheritDoc} * Loading Loading @@ -4897,6 +4926,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager view.unFocus(null); clearChildFocus = true; } if (view == mLastFocused) { mLastFocused = null; } view.clearAccessibilityFocus(); Loading Loading @@ -5007,6 +5039,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager view.unFocus(null); clearChildFocus = true; } if (view == mLastFocused) { mLastFocused = null; } view.clearAccessibilityFocus(); Loading Loading @@ -5080,6 +5115,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager boolean clearChildFocus = false; needGlobalAttributesUpdate(false); mLastFocused = null; for (int i = count - 1; i >= 0; i--) { final View view = children[i]; Loading Loading @@ -5151,6 +5187,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (child == mFocused) { child.clearFocus(); } if (child == mLastFocused) { mLastFocused = null; } child.clearAccessibilityFocus(); Loading Loading @@ -6153,6 +6192,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager output = debugIndent(depth); output += "mFocused"; Log.d(VIEW_LOG_TAG, output); mFocused.debug(depth + 1); } if (mLastFocused != null) { output = debugIndent(depth); output += "mLastFocused"; Log.d(VIEW_LOG_TAG, output); mLastFocused.debug(depth + 1); } if (mChildrenCount != 0) { output = debugIndent(depth); Loading