diff options
| author | Jason Monk <jmonk@google.com> | 2017-09-08 20:35:52 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-09-08 20:35:52 +0000 |
| commit | d6af052a35e6d8dc718b83aff6a2abd1cb909313 (patch) | |
| tree | 8d29e2b11ffde67c5f9335c49b5b8b4a471ee146 /core/java | |
| parent | 7121c28e7ff584ed5d86e35eb53eb92f3b9c9c9f (diff) | |
| parent | 9555ed12e61235666b95d5eafccfa66903c805a0 (diff) | |
Merge "Make settings themed apps have light nav DO NOT MERGE" into oc-mr1-dev
am: 9555ed12e6
Change-Id: I7658ab52ff09923b991da2f9aaac239ceb9e805d
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/policy/DecorView.java | 44 | ||||
| -rw-r--r-- | core/java/com/android/internal/policy/PhoneWindow.java | 3 |
2 files changed, 41 insertions, 6 deletions
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java index 969608b25255..4e06577e3588 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -17,6 +17,9 @@ package com.android.internal.policy; import android.graphics.Outline; +import android.graphics.drawable.InsetDrawable; +import android.graphics.drawable.LayerDrawable; +import android.util.Pair; import android.view.ViewOutlineProvider; import android.view.accessibility.AccessibilityNodeInfo; import com.android.internal.R; @@ -1103,8 +1106,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind boolean navBarToLeftEdge = isNavBarToLeftEdge(mLastBottomInset, mLastLeftInset); int navBarSize = getNavBarSize(mLastBottomInset, mLastRightInset, mLastLeftInset); updateColorViewInt(mNavigationColorViewState, sysUiVisibility, - mWindow.mNavigationBarColor, navBarSize, navBarToRightEdge || navBarToLeftEdge, - navBarToLeftEdge, + mWindow.mNavigationBarColor, mWindow.mNavigationBarDividerColor, navBarSize, + navBarToRightEdge || navBarToLeftEdge, navBarToLeftEdge, 0 /* sideInset */, animate && !disallowAnimate, false /* force */); boolean statusBarNeedsRightInset = navBarToRightEdge @@ -1114,7 +1117,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind int statusBarSideInset = statusBarNeedsRightInset ? mLastRightInset : statusBarNeedsLeftInset ? mLastLeftInset : 0; updateColorViewInt(mStatusColorViewState, sysUiVisibility, - calculateStatusBarColor(), mLastTopInset, + calculateStatusBarColor(), 0, mLastTopInset, false /* matchVertical */, statusBarNeedsLeftInset, statusBarSideInset, animate && !disallowAnimate, mForceWindowDrawsStatusBarBackground); @@ -1201,6 +1204,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind * @param state the color view to update. * @param sysUiVis the current systemUiVisibility to apply. * @param color the current color to apply. + * @param dividerColor the current divider color to apply. * @param size the current size in the non-parent-matching dimension. * @param verticalBar if true the view is attached to a vertical edge, otherwise to a * horizontal edge, @@ -1208,7 +1212,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind * @param animate if true, the change will be animated. */ private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color, - int size, boolean verticalBar, boolean seascape, int sideMargin, + int dividerColor, int size, boolean verticalBar, boolean seascape, int sideMargin, boolean animate, boolean force) { state.present = state.attributes.isPresent(sysUiVis, mWindow.getAttributes().flags, force); boolean show = state.attributes.isVisible(state.present, color, @@ -1227,7 +1231,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind if (view == null) { if (showView) { state.view = view = new View(mContext); - view.setBackgroundColor(color); + setColor(view, color, dividerColor, verticalBar, seascape); view.setTransitionName(state.attributes.transitionName); view.setId(state.attributes.id); visibilityChanged = true; @@ -1262,7 +1266,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind view.setLayoutParams(lp); } if (showView) { - view.setBackgroundColor(color); + setColor(view, color, dividerColor, verticalBar, seascape); } } if (visibilityChanged) { @@ -1295,6 +1299,34 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind state.color = color; } + private static void setColor(View v, int color, int dividerColor, boolean verticalBar, + boolean seascape) { + if (dividerColor != 0) { + final Pair<Boolean, Boolean> dir = (Pair<Boolean, Boolean>) v.getTag(); + if (dir == null || dir.first != verticalBar || dir.second != seascape) { + final int size = Math.round( + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, + v.getContext().getResources().getDisplayMetrics())); + // Use an inset to make the divider line on the side that faces the app. + final InsetDrawable d = new InsetDrawable(new ColorDrawable(color), + verticalBar && !seascape ? size : 0, + !verticalBar ? size : 0, + verticalBar && seascape ? size : 0, 0); + v.setBackground(new LayerDrawable(new Drawable[] { + new ColorDrawable(dividerColor), d })); + v.setTag(new Pair<>(verticalBar, seascape)); + } else { + final LayerDrawable d = (LayerDrawable) v.getBackground(); + final InsetDrawable inset = ((InsetDrawable) d.getDrawable(1)); + ((ColorDrawable) inset.getDrawable()).setColor(color); + ((ColorDrawable) d.getDrawable(0)).setColor(dividerColor); + } + } else { + v.setTag(null); + v.setBackgroundColor(color); + } + } + private void updateColorViewTranslations() { // Put the color views back in place when they get moved off the screen // due to the the ViewRootImpl panning. diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 57b0a730c86e..5f1932c9cfff 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -233,6 +233,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private int mTextColor = 0; int mStatusBarColor = 0; int mNavigationBarColor = 0; + int mNavigationBarDividerColor = 0; private boolean mForcedStatusBarColor = false; private boolean mForcedNavigationBarColor = false; @@ -2432,6 +2433,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } if (!mForcedNavigationBarColor) { mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000); + mNavigationBarDividerColor = a.getColor(R.styleable.Window_navigationBarDividerColor, + 0x00000000); } WindowManager.LayoutParams params = getAttributes(); |
