Fix right-most navbar icon tinting mismatch

Rotate, a11y navbar buttons didn't match the color of the home,
back and recents buttons.

Change-Id: I7337b0a7091d7d42b0ae45cb0c29b96c5d5b126c
Fixes: 77286278
Test: manual comparison of color in screenshots
This commit is contained in:
Mike Digman
2018-03-30 11:22:05 -07:00
parent cb903343f0
commit e3909de258
13 changed files with 42 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M20.5,6c-2.61,0.7 -5.67,1 -8.5,1S6.11,6.7 3.5,6L3,8c1.86,0.5 4,0.83 6,1v13h2v-6h2v6h2V9c2,-0.17 4.14,-0.5 6,-1L20.5,6zM12,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2s-2,0.9 -2,2S10.9,6 12,6z"
android:fillColor="?attr/singleToneColor"/>
</vector>

View File

@@ -424,13 +424,16 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
mRecentIcon = getDrawable(ctx,
R.drawable.ic_sysbar_recent, R.drawable.ic_sysbar_recent_dark);
mMenuIcon = getDrawable(ctx, R.drawable.ic_sysbar_menu, R.drawable.ic_sysbar_menu_dark);
mAccessibilityIcon = getDrawable(ctx, R.drawable.ic_sysbar_accessibility_button,
R.drawable.ic_sysbar_accessibility_button_dark);
int dualToneDarkTheme = Utils.getThemeAttr(ctx, R.attr.darkIconTheme);
int dualToneLightTheme = Utils.getThemeAttr(ctx, R.attr.lightIconTheme);
Context darkContext = new ContextThemeWrapper(ctx, dualToneDarkTheme);
Context lightContext = new ContextThemeWrapper(ctx, dualToneLightTheme);
mAccessibilityIcon = getDrawable(darkContext, lightContext,
R.drawable.ic_sysbar_accessibility_button,
R.drawable.ic_sysbar_accessibility_button);
mImeIcon = getDrawable(darkContext, lightContext,
R.drawable.ic_ime_switcher_default, R.drawable.ic_ime_switcher_default);

View File

@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.policy;
import android.annotation.ColorInt;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import com.android.internal.graphics.ColorUtils;
@@ -49,16 +50,21 @@ public class TintedKeyButtonDrawable extends KeyButtonDrawable {
public void setDarkIntensity(float intensity) {
// Duplicate intensity scaling from KeyButtonDrawable
mDarkIntensity = intensity;
int intermediateColor = ColorUtils.compositeColors(
setAlphaFloat(mDarkColor, intensity),
setAlphaFloat(mLightColor,1f - intensity));
// Dark and light colors may have an alpha component
final int intermediateColor = ColorUtils.compositeColors(
blendAlpha(mDarkColor, intensity),
blendAlpha(mLightColor, (1f - intensity)));
getDrawable(0).setTint(intermediateColor);
invalidateSelf();
}
private int setAlphaFloat(int color, float alpha) {
private int blendAlpha(int color, float alpha) {
final float newAlpha = alpha < 0f ? 0f : (alpha > 1f ? 1f : alpha);
final float colorAlpha = Color.alpha(color) / 255f;
final int alphaInt = (int) (255 * newAlpha * colorAlpha); // Blend by multiplying
// Ensure alpha is clamped [0-255] or ColorUtils will crash
final int alphaInt = alpha > 1f ? 255 : (alpha < 0f ? 0 : ((int) alpha*255));
return ColorUtils.setAlphaComponent(color, alphaInt);
}