Loading packages/SystemUI/res/values/dimens.xml +7 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,13 @@ <dimen name="navigation_handle_radius">1dp</dimen> <dimen name="navigation_handle_bottom">6dp</dimen> <dimen name="navigation_handle_horizontal_margin">30dp</dimen> <dimen name="navigation_home_handle_width">280dp</dimen> <dimen name="navigation_handle_sample_horizontal_margin">10dp</dimen> <dimen name="navigation_home_handle_width">72dp</dimen> <!-- Luminance threshold to determine black/white contrast for the navigation affordances --> <item name="navigation_luminance_threshold" type="dimen" format="float">0.5</item> <!-- Luminance change threshold that allows applying new value if difference was exceeded --> <item name="navigation_luminance_change_threshold" type="dimen" format="float">0.05</item> <!-- Height of notification icons in the status bar --> <dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen> Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavBarTintController.java +39 −14 Original line number Diff line number Diff line Loading @@ -19,11 +19,14 @@ package com.android.systemui.statusbar.phone; import static android.view.Display.DEFAULT_DISPLAY; import android.content.Context; import android.content.res.Resources; import android.graphics.Point; import android.graphics.Rect; import android.os.Handler; import android.view.CompositionSamplingListener; import android.view.View; import com.android.systemui.R; import com.android.systemui.shared.system.QuickStepContract; import java.io.PrintWriter; Loading @@ -37,9 +40,6 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, public static final int MIN_COLOR_ADAPT_TRANSITION_TIME = 400; public static final int DEFAULT_COLOR_ADAPT_TRANSITION_TIME = 1700; // Passing the threshold of this luminance value will make the button black otherwise white private static final float LUMINANCE_THRESHOLD = 0.3f; private final Handler mHandler = new Handler(); private final NavigationBarView mNavigationBarView; private final LightBarTransitionsController mLightBarController; Loading @@ -50,9 +50,17 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, private boolean mSamplingEnabled = false; private boolean mSamplingListenerRegistered = false; private float mLastMediaLuma; private float mLastMedianLuma; private float mCurrentMedianLuma; private boolean mUpdateOnNextDraw; private final int mNavBarHeight; private final int mNavColorSampleMargin; // Passing the threshold of this luminance value will make the button black otherwise white private final float mLuminanceThreshold; private final float mLuminanceChangeThreshold; public NavBarTintController(NavigationBarView navigationBarView, LightBarTransitionsController lightBarController) { mSamplingListener = new CompositionSamplingListener( Loading @@ -66,6 +74,13 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, mNavigationBarView.addOnAttachStateChangeListener(this); mNavigationBarView.addOnLayoutChangeListener(this); mLightBarController = lightBarController; final Resources res = navigationBarView.getResources(); mNavBarHeight = res.getDimensionPixelSize(R.dimen.navigation_bar_height); mNavColorSampleMargin = res.getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin); mLuminanceThreshold = res.getFloat(R.dimen.navigation_luminance_threshold); mLuminanceChangeThreshold = res.getFloat(R.dimen.navigation_luminance_change_threshold); } void onDraw() { Loading Loading @@ -109,8 +124,11 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, if (view != null) { int[] pos = new int[2]; view.getLocationOnScreen(pos); final Rect samplingBounds = new Rect(pos[0], pos[1], pos[0] + view.getWidth(), pos[1] + view.getHeight()); Point displaySize = new Point(); view.getContext().getDisplay().getRealSize(displaySize); final Rect samplingBounds = new Rect(pos[0] - mNavColorSampleMargin, displaySize.y - mNavBarHeight, pos[0] + view.getWidth() + mNavColorSampleMargin, displaySize.y); if (!samplingBounds.equals(mSamplingBounds)) { mSamplingBounds.set(samplingBounds); requestUpdateSamplingListener(); Loading Loading @@ -144,14 +162,20 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, } private void updateTint(float medianLuma) { mLastMediaLuma = medianLuma; if (medianLuma > LUMINANCE_THRESHOLD) { mLastMedianLuma = medianLuma; // If the difference between the new luma and the current luma is larger than threshold // then apply the current luma, this is to prevent small changes causing colors to flicker if (Math.abs(mCurrentMedianLuma - mLastMedianLuma) > mLuminanceChangeThreshold) { if (medianLuma > mLuminanceThreshold) { // Black mLightBarController.setIconsDark(true /* dark */, true /* animate */); } else { // White mLightBarController.setIconsDark(false /* dark */, true /* animate */); } mCurrentMedianLuma = medianLuma; } } void dump(PrintWriter pw) { Loading @@ -162,7 +186,8 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, : "false")); pw.println(" mSamplingListenerRegistered: " + mSamplingListenerRegistered); pw.println(" mSamplingBounds: " + mSamplingBounds); pw.println(" mLastMediaLuma: " + mLastMediaLuma); pw.println(" mLastMedianLuma: " + mLastMedianLuma); pw.println(" mCurrentMedianLuma: " + mCurrentMedianLuma); } public static boolean isEnabled(Context context) { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationHandle.java +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public class NavigationHandle extends View implements ButtonInterface { int height = mRadius * 2; int width = getWidth(); int y = (navHeight - mBottom - height); canvas.drawRoundRect(mRadius, y, width - mRadius, y + height, mRadius, mRadius, mPaint); canvas.drawRoundRect(0, y, width, y + height, mRadius, mRadius, mPaint); } @Override Loading Loading
packages/SystemUI/res/values/dimens.xml +7 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,13 @@ <dimen name="navigation_handle_radius">1dp</dimen> <dimen name="navigation_handle_bottom">6dp</dimen> <dimen name="navigation_handle_horizontal_margin">30dp</dimen> <dimen name="navigation_home_handle_width">280dp</dimen> <dimen name="navigation_handle_sample_horizontal_margin">10dp</dimen> <dimen name="navigation_home_handle_width">72dp</dimen> <!-- Luminance threshold to determine black/white contrast for the navigation affordances --> <item name="navigation_luminance_threshold" type="dimen" format="float">0.5</item> <!-- Luminance change threshold that allows applying new value if difference was exceeded --> <item name="navigation_luminance_change_threshold" type="dimen" format="float">0.05</item> <!-- Height of notification icons in the status bar --> <dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen> Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavBarTintController.java +39 −14 Original line number Diff line number Diff line Loading @@ -19,11 +19,14 @@ package com.android.systemui.statusbar.phone; import static android.view.Display.DEFAULT_DISPLAY; import android.content.Context; import android.content.res.Resources; import android.graphics.Point; import android.graphics.Rect; import android.os.Handler; import android.view.CompositionSamplingListener; import android.view.View; import com.android.systemui.R; import com.android.systemui.shared.system.QuickStepContract; import java.io.PrintWriter; Loading @@ -37,9 +40,6 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, public static final int MIN_COLOR_ADAPT_TRANSITION_TIME = 400; public static final int DEFAULT_COLOR_ADAPT_TRANSITION_TIME = 1700; // Passing the threshold of this luminance value will make the button black otherwise white private static final float LUMINANCE_THRESHOLD = 0.3f; private final Handler mHandler = new Handler(); private final NavigationBarView mNavigationBarView; private final LightBarTransitionsController mLightBarController; Loading @@ -50,9 +50,17 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, private boolean mSamplingEnabled = false; private boolean mSamplingListenerRegistered = false; private float mLastMediaLuma; private float mLastMedianLuma; private float mCurrentMedianLuma; private boolean mUpdateOnNextDraw; private final int mNavBarHeight; private final int mNavColorSampleMargin; // Passing the threshold of this luminance value will make the button black otherwise white private final float mLuminanceThreshold; private final float mLuminanceChangeThreshold; public NavBarTintController(NavigationBarView navigationBarView, LightBarTransitionsController lightBarController) { mSamplingListener = new CompositionSamplingListener( Loading @@ -66,6 +74,13 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, mNavigationBarView.addOnAttachStateChangeListener(this); mNavigationBarView.addOnLayoutChangeListener(this); mLightBarController = lightBarController; final Resources res = navigationBarView.getResources(); mNavBarHeight = res.getDimensionPixelSize(R.dimen.navigation_bar_height); mNavColorSampleMargin = res.getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin); mLuminanceThreshold = res.getFloat(R.dimen.navigation_luminance_threshold); mLuminanceChangeThreshold = res.getFloat(R.dimen.navigation_luminance_change_threshold); } void onDraw() { Loading Loading @@ -109,8 +124,11 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, if (view != null) { int[] pos = new int[2]; view.getLocationOnScreen(pos); final Rect samplingBounds = new Rect(pos[0], pos[1], pos[0] + view.getWidth(), pos[1] + view.getHeight()); Point displaySize = new Point(); view.getContext().getDisplay().getRealSize(displaySize); final Rect samplingBounds = new Rect(pos[0] - mNavColorSampleMargin, displaySize.y - mNavBarHeight, pos[0] + view.getWidth() + mNavColorSampleMargin, displaySize.y); if (!samplingBounds.equals(mSamplingBounds)) { mSamplingBounds.set(samplingBounds); requestUpdateSamplingListener(); Loading Loading @@ -144,14 +162,20 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, } private void updateTint(float medianLuma) { mLastMediaLuma = medianLuma; if (medianLuma > LUMINANCE_THRESHOLD) { mLastMedianLuma = medianLuma; // If the difference between the new luma and the current luma is larger than threshold // then apply the current luma, this is to prevent small changes causing colors to flicker if (Math.abs(mCurrentMedianLuma - mLastMedianLuma) > mLuminanceChangeThreshold) { if (medianLuma > mLuminanceThreshold) { // Black mLightBarController.setIconsDark(true /* dark */, true /* animate */); } else { // White mLightBarController.setIconsDark(false /* dark */, true /* animate */); } mCurrentMedianLuma = medianLuma; } } void dump(PrintWriter pw) { Loading @@ -162,7 +186,8 @@ public class NavBarTintController implements View.OnAttachStateChangeListener, : "false")); pw.println(" mSamplingListenerRegistered: " + mSamplingListenerRegistered); pw.println(" mSamplingBounds: " + mSamplingBounds); pw.println(" mLastMediaLuma: " + mLastMediaLuma); pw.println(" mLastMedianLuma: " + mLastMedianLuma); pw.println(" mCurrentMedianLuma: " + mCurrentMedianLuma); } public static boolean isEnabled(Context context) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationHandle.java +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public class NavigationHandle extends View implements ButtonInterface { int height = mRadius * 2; int width = getWidth(); int y = (navHeight - mBottom - height); canvas.drawRoundRect(mRadius, y, width - mRadius, y + height, mRadius, mRadius, mPaint); canvas.drawRoundRect(0, y, width, y + height, mRadius, mRadius, mPaint); } @Override Loading