summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2014-09-13 00:22:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-13 00:22:29 +0000
commit2642357b8223b417019cf072e59257d2c65c3292 (patch)
tree9482ab713193cd78d2562822f07a04cd4f49f26d
parent76466c7be315e4e8f473e63b7403ba2c508983c1 (diff)
parentd72068b38ec4e5732dde6093e39b2602babc27a3 (diff)
downloadframeworks_base-2642357b8223b417019cf072e59257d2c65c3292.zip
frameworks_base-2642357b8223b417019cf072e59257d2c65c3292.tar.gz
frameworks_base-2642357b8223b417019cf072e59257d2c65c3292.tar.bz2
Merge "Provide a public API for View#computeFitSystemWindows" into lmp-dev
-rw-r--r--api/current.txt2
-rw-r--r--core/java/android/view/View.java22
-rw-r--r--core/java/android/view/WindowInsets.java15
3 files changed, 39 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 6aa5180..69f55fb 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -33653,6 +33653,7 @@ package android.view {
method protected int computeHorizontalScrollOffset();
method protected int computeHorizontalScrollRange();
method public void computeScroll();
+ method public android.view.WindowInsets computeSystemWindowInsets(android.view.WindowInsets, android.graphics.Rect);
method protected int computeVerticalScrollExtent();
method protected int computeVerticalScrollOffset();
method protected int computeVerticalScrollRange();
@@ -34978,6 +34979,7 @@ package android.view {
method public boolean isConsumed();
method public boolean isRound();
method public android.view.WindowInsets replaceSystemWindowInsets(int, int, int, int);
+ method public android.view.WindowInsets replaceSystemWindowInsets(android.graphics.Rect);
}
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 eb8f3bf..ac00667 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6525,6 +6525,28 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
/**
+ * Compute insets that should be consumed by this view and the ones that should propagate
+ * to those under it.
+ *
+ * @param in Insets currently being processed by this View, likely received as a parameter
+ * to {@link #onApplyWindowInsets(WindowInsets)}.
+ * @param outLocalInsets A Rect that will receive the insets that should be consumed
+ * by this view
+ * @return Insets that should be passed along to views under this one
+ */
+ public WindowInsets computeSystemWindowInsets(WindowInsets in, Rect outLocalInsets) {
+ if ((mViewFlags & OPTIONAL_FITS_SYSTEM_WINDOWS) == 0
+ || mAttachInfo == null
+ || (mAttachInfo.mSystemUiVisibility & SYSTEM_UI_LAYOUT_FLAGS) == 0) {
+ outLocalInsets.set(in.getSystemWindowInsets());
+ return in.consumeSystemWindowInsets();
+ } else {
+ outLocalInsets.set(0, 0, 0, 0);
+ return in;
+ }
+ }
+
+ /**
* Sets whether or not this view should account for system screen decorations
* such as the status bar and inset its content; that is, controlling whether
* the default implementation of {@link #fitSystemWindows(Rect)} will be
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index 24c3c1a..2bfe3b4 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -341,6 +341,21 @@ public final class WindowInsets {
}
/**
+ * Returns a copy of this WindowInsets with selected system window insets replaced
+ * with new values.
+ *
+ * @param systemWindowInsets New system window insets. Each field is the inset in pixels
+ * for that edge
+ * @return A modified copy of this WindowInsets
+ */
+ public WindowInsets replaceSystemWindowInsets(Rect systemWindowInsets) {
+ final WindowInsets result = new WindowInsets(this);
+ result.mSystemWindowInsets = new Rect(systemWindowInsets);
+ result.mSystemWindowInsetsConsumed = !hasSystemWindowInsets();
+ return result;
+ }
+
+ /**
* @hide
*/
public WindowInsets consumeWindowDecorInsets() {