diff options
author | Adam Powell <adamp@google.com> | 2014-05-07 00:35:31 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-07 00:35:31 +0000 |
commit | bfbddcad6004b7d178fb777c3a2b8b8a3dfe53ad (patch) | |
tree | 09bd710ba7ab3e77086606fe9d0a08f7c3e4eaf9 | |
parent | 6827949fc63699106b7fdc0c399b3fad8e015a79 (diff) | |
parent | 4f295fe8c66ef2878d93be420f73745d88422e35 (diff) | |
download | frameworks_base-bfbddcad6004b7d178fb777c3a2b8b8a3dfe53ad.zip frameworks_base-bfbddcad6004b7d178fb777c3a2b8b8a3dfe53ad.tar.gz frameworks_base-bfbddcad6004b7d178fb777c3a2b8b8a3dfe53ad.tar.bz2 |
am 4f295fe8: Merge "Clean up WindowInsets API for release" into klp-modular-dev
* commit '4f295fe8c66ef2878d93be420f73745d88422e35':
Clean up WindowInsets API for release
-rw-r--r-- | api/current.txt | 15 | ||||
-rw-r--r-- | core/java/android/view/View.java | 4 | ||||
-rw-r--r-- | core/java/android/view/WindowInsets.java | 54 |
3 files changed, 52 insertions, 21 deletions
diff --git a/api/current.txt b/api/current.txt index e1e148a..ef7aa0a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28775,26 +28775,17 @@ package android.view { method public abstract void onFocusLost(android.view.WindowId); } - public class WindowInsets { + public final class WindowInsets { ctor public WindowInsets(android.view.WindowInsets); - method public android.view.WindowInsets cloneWithSystemWindowInsets(int, int, int, int); - method public android.view.WindowInsets cloneWithSystemWindowInsetsConsumed(); - method public android.view.WindowInsets cloneWithSystemWindowInsetsConsumed(boolean, boolean, boolean, boolean); - method public android.view.WindowInsets cloneWithWindowDecorInsets(int, int, int, int); - method public android.view.WindowInsets cloneWithWindowDecorInsetsConsumed(); - method public android.view.WindowInsets cloneWithWindowDecorInsetsConsumed(boolean, boolean, boolean, boolean); + method public android.view.WindowInsets consumeSystemWindowInsets(); method public int getSystemWindowInsetBottom(); method public int getSystemWindowInsetLeft(); method public int getSystemWindowInsetRight(); method public int getSystemWindowInsetTop(); - method public int getWindowDecorInsetBottom(); - method public int getWindowDecorInsetLeft(); - method public int getWindowDecorInsetRight(); - method public int getWindowDecorInsetTop(); method public boolean hasInsets(); method public boolean hasSystemWindowInsets(); - method public boolean hasWindowDecorInsets(); method public boolean isRound(); + method public android.view.WindowInsets replaceSystemWindowInsets(int, int, int, int); } public abstract interface WindowManager implements android.view.ViewManager { diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index eb7f45e..77d0887 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5989,12 +5989,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // call into it as a fallback in case we're in a class that overrides it // and has logic to perform. if (fitSystemWindows(insets.getSystemWindowInsets())) { - return insets.cloneWithSystemWindowInsetsConsumed(); + return insets.consumeSystemWindowInsets(); } } else { // We were called from within a direct call to fitSystemWindows. if (fitSystemWindowsInt(insets.getSystemWindowInsets())) { - return insets.cloneWithSystemWindowInsetsConsumed(); + return insets.consumeSystemWindowInsets(); } } return insets; diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java index 2160efe..294f472 100644 --- a/core/java/android/view/WindowInsets.java +++ b/core/java/android/view/WindowInsets.java @@ -29,7 +29,7 @@ import android.graphics.Rect; * @see View.OnApplyWindowInsetsListener * @see View#onApplyWindowInsets(WindowInsets) */ -public class WindowInsets { +public final class WindowInsets { private Rect mSystemWindowInsets; private Rect mWindowDecorInsets; private Rect mTempRect; @@ -151,6 +151,7 @@ public class WindowInsets { * This can include action bars, title bars, toolbars, etc.</p> * * @return The left window decor inset + * @hide pending API */ public int getWindowDecorInsetLeft() { return mWindowDecorInsets.left; @@ -164,6 +165,7 @@ public class WindowInsets { * This can include action bars, title bars, toolbars, etc.</p> * * @return The top window decor inset + * @hide pending API */ public int getWindowDecorInsetTop() { return mWindowDecorInsets.top; @@ -177,6 +179,7 @@ public class WindowInsets { * This can include action bars, title bars, toolbars, etc.</p> * * @return The right window decor inset + * @hide pending API */ public int getWindowDecorInsetRight() { return mWindowDecorInsets.right; @@ -190,6 +193,7 @@ public class WindowInsets { * This can include action bars, title bars, toolbars, etc.</p> * * @return The bottom window decor inset + * @hide pending API */ public int getWindowDecorInsetBottom() { return mWindowDecorInsets.bottom; @@ -217,6 +221,7 @@ public class WindowInsets { * This can include action bars, title bars, toolbars, etc.</p> * * @return true if any of the window decor inset values are nonzero + * @hide pending API */ public boolean hasWindowDecorInsets() { return mWindowDecorInsets.left != 0 || mWindowDecorInsets.top != 0 || @@ -246,13 +251,28 @@ public class WindowInsets { return mIsRound; } - public WindowInsets cloneWithSystemWindowInsetsConsumed() { + /** + * Returns a copy of this WindowInsets with the system window insets fully consumed. + * + * @return A modified copy of this WindowInsets + */ + public WindowInsets consumeSystemWindowInsets() { final WindowInsets result = new WindowInsets(this); result.mSystemWindowInsets = new Rect(0, 0, 0, 0); return result; } - public WindowInsets cloneWithSystemWindowInsetsConsumed(boolean left, boolean top, + /** + * Returns a copy of this WindowInsets with selected system window insets fully consumed. + * + * @param left true to consume the left system window inset + * @param top true to consume the top system window inset + * @param right true to consume the right system window inset + * @param bottom true to consume the bottom system window inset + * @return A modified copy of this WindowInsets + * @hide pending API + */ + public WindowInsets consumeSystemWindowInsets(boolean left, boolean top, boolean right, boolean bottom) { if (left || top || right || bottom) { final WindowInsets result = new WindowInsets(this); @@ -265,19 +285,36 @@ public class WindowInsets { return this; } - public WindowInsets cloneWithSystemWindowInsets(int left, int top, int right, int bottom) { + /** + * Returns a copy of this WindowInsets with selected system window insets replaced + * with new values. + * + * @param left New left inset in pixels + * @param top New top inset in pixels + * @param right New right inset in pixels + * @param bottom New bottom inset in pixels + * @return A modified copy of this WindowInsets + */ + public WindowInsets replaceSystemWindowInsets(int left, int top, + int right, int bottom) { final WindowInsets result = new WindowInsets(this); result.mSystemWindowInsets = new Rect(left, top, right, bottom); return result; } - public WindowInsets cloneWithWindowDecorInsetsConsumed() { + /** + * @hide + */ + public WindowInsets consumeWindowDecorInsets() { final WindowInsets result = new WindowInsets(this); result.mWindowDecorInsets.set(0, 0, 0, 0); return result; } - public WindowInsets cloneWithWindowDecorInsetsConsumed(boolean left, boolean top, + /** + * @hide + */ + public WindowInsets consumeWindowDecorInsets(boolean left, boolean top, boolean right, boolean bottom) { if (left || top || right || bottom) { final WindowInsets result = new WindowInsets(this); @@ -290,7 +327,10 @@ public class WindowInsets { return this; } - public WindowInsets cloneWithWindowDecorInsets(int left, int top, int right, int bottom) { + /** + * @hide + */ + public WindowInsets replaceWindowDecorInsets(int left, int top, int right, int bottom) { final WindowInsets result = new WindowInsets(this); result.mWindowDecorInsets = new Rect(left, top, right, bottom); return result; |