Fix the status icon colors in QS
Requires lots of theming magic
Test: visual
Change-Id: I1cd28b570f30989b496065c0e06a5aca461deb41
Fixes: 37619734
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
index 911ef24..9dd39d4 100644
--- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
+++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
@@ -17,25 +17,28 @@
import static android.provider.Settings.System.SHOW_BATTERY_PERCENT;
+import android.animation.ArgbEvaluator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.graphics.Rect;
-import android.util.ArraySet;
-import android.util.AttributeSet;
-import android.util.TypedValue;
import android.database.ContentObserver;
+import android.graphics.Rect;
import android.net.Uri;
import android.os.Handler;
import android.provider.Settings;
+import android.util.ArraySet;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
-
import android.widget.TextView;
+
+import com.android.settingslib.Utils;
import com.android.settingslib.graph.BatteryMeterDrawableBase;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -63,6 +66,12 @@
private int mLevel;
private boolean mForceShowPercent;
+ private int mDarkModeBackgroundColor;
+ private int mDarkModeFillColor;
+
+ private int mLightModeBackgroundColor;
+ private int mLightModeFillColor;
+
public BatteryMeterView(Context context) {
this(context, null, 0);
}
@@ -98,6 +107,16 @@
addView(mBatteryIconView, mlp);
updateShowPercent();
+
+ Context dualToneDarkTheme = new ContextThemeWrapper(context,
+ Utils.getThemeAttr(context, R.attr.darkIconTheme));
+ Context dualToneLightTheme = new ContextThemeWrapper(context,
+ Utils.getThemeAttr(context, R.attr.lightIconTheme));
+ mDarkModeBackgroundColor = Utils.getColorAttr(dualToneDarkTheme, R.attr.backgroundColor);
+ mDarkModeFillColor = Utils.getColorAttr(dualToneDarkTheme, R.attr.fillColor);
+ mLightModeBackgroundColor = Utils.getColorAttr(dualToneLightTheme, R.attr.backgroundColor);
+ mLightModeFillColor = Utils.getColorAttr(dualToneLightTheme, R.attr.fillColor);
+
// Init to not dark at all.
onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
}
@@ -107,11 +126,6 @@
updateShowPercent();
}
- // StatusBarIconController reaches in here and adjusts the layout parameters of the icon
- public ImageView getBatteryIconView() {
- return mBatteryIconView;
- }
-
@Override
public boolean hasOverlappingRendering() {
return false;
@@ -170,7 +184,7 @@
private void updatePercentText() {
if (mBatteryPercentView != null) {
mBatteryPercentView.setText(
- NumberFormat.getPercentInstance().format(mLevel/100f));
+ NumberFormat.getPercentInstance().format(mLevel / 100f));
}
}
@@ -224,8 +238,13 @@
@Override
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
- mDrawable.setDarkIntensity(DarkIconDispatcher.isInArea(area, this) ? darkIntensity : 0);
- setTextColor(DarkIconDispatcher.getTint(area, this, tint));
+ float intensity = DarkIconDispatcher.isInArea(area, this) ? darkIntensity : 0;
+ int foreground = getColorForDarkIntensity(intensity, mLightModeFillColor,
+ mDarkModeFillColor);
+ int background = getColorForDarkIntensity(intensity, mLightModeBackgroundColor,
+ mDarkModeBackgroundColor);
+ mDrawable.setColors(foreground, background);
+ setTextColor(foreground);
}
public void setTextColor(int color) {
@@ -235,8 +254,8 @@
}
}
- public void setRawColors(int fgColor, int bgColor) {
- mDrawable.setColors(fgColor, bgColor);
+ private int getColorForDarkIntensity(float darkIntensity, int lightColor, int darkColor) {
+ return (int) ArgbEvaluator.getInstance().evaluate(darkIntensity, lightColor, darkColor);
}
private final class SettingObserver extends ContentObserver {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
index 5cf049a..3f090f8 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
@@ -23,6 +23,7 @@
import android.os.Bundle;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
+import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -33,6 +34,7 @@
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.R.id;
+import com.android.systemui.R.style;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
@@ -67,6 +69,7 @@
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
Bundle savedInstanceState) {
+ inflater =inflater.cloneInContext(new ContextThemeWrapper(getContext(), R.style.qs_theme));
return inflater.inflate(R.layout.qs_panel, container, false);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 1fd329c..8d9d461 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -36,16 +36,15 @@
import android.util.SparseArray;
import android.view.ContextThemeWrapper;
import android.view.Display;
-import android.view.IDockedStackListener.Stub;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.view.WindowManagerGlobal;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
+import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.DockedStackExistsListener;
import com.android.systemui.R;
@@ -336,8 +335,10 @@
mAccessibilityIcon = getDrawable(ctx, R.drawable.ic_sysbar_accessibility_button,
R.drawable.ic_sysbar_accessibility_button_dark);
- Context darkContext = new ContextThemeWrapper(ctx, R.style.DualToneDarkTheme);
- Context lightContext = new ContextThemeWrapper(ctx, R.style.DualToneLightTheme);
+ 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);
mImeIcon = getDrawable(darkContext, lightContext,
R.drawable.ic_ime_switcher_default, R.drawable.ic_ime_switcher_default);