Merge "Fix the status icon colors in QS" into oc-dev
This commit is contained in:
@@ -639,6 +639,11 @@ public abstract class LayoutInflater {
|
||||
}
|
||||
}
|
||||
|
||||
Object lastContext = mConstructorArgs[0];
|
||||
if (mConstructorArgs[0] == null) {
|
||||
// Fill in the context if not already within inflation.
|
||||
mConstructorArgs[0] = mContext;
|
||||
}
|
||||
Object[] args = mConstructorArgs;
|
||||
args[1] = attrs;
|
||||
|
||||
@@ -648,6 +653,7 @@ public abstract class LayoutInflater {
|
||||
final ViewStub viewStub = (ViewStub) view;
|
||||
viewStub.setLayoutInflater(cloneInContext((Context) args[0]));
|
||||
}
|
||||
mConstructorArgs[0] = lastContext;
|
||||
return view;
|
||||
|
||||
} catch (NoSuchMethodException e) {
|
||||
|
||||
@@ -204,6 +204,13 @@ public class Utils {
|
||||
return colorAccent;
|
||||
}
|
||||
|
||||
public static int getThemeAttr(Context context, int attr) {
|
||||
TypedArray ta = context.obtainStyledAttributes(new int[]{attr});
|
||||
int theme = ta.getResourceId(0, 0);
|
||||
ta.recycle();
|
||||
return theme;
|
||||
}
|
||||
|
||||
public static Drawable getDrawable(Context context, int attr) {
|
||||
TypedArray ta = context.obtainStyledAttributes(new int[]{attr});
|
||||
Drawable drawable = ta.getDrawable(0);
|
||||
|
||||
@@ -88,12 +88,6 @@ public class BatteryMeterDrawableBase extends Drawable {
|
||||
private final Path mClipPath = new Path();
|
||||
private final Path mTextPath = new Path();
|
||||
|
||||
private int mDarkModeBackgroundColor;
|
||||
private int mDarkModeFillColor;
|
||||
|
||||
private int mLightModeBackgroundColor;
|
||||
private int mLightModeFillColor;
|
||||
|
||||
public BatteryMeterDrawableBase(Context context, int frameColor) {
|
||||
mContext = context;
|
||||
final Resources res = context.getResources();
|
||||
@@ -156,15 +150,6 @@ public class BatteryMeterDrawableBase extends Drawable {
|
||||
mPlusPaint = new Paint(mBoltPaint);
|
||||
mPlusPoints = loadPoints(res, R.array.batterymeter_plus_points);
|
||||
|
||||
mDarkModeBackgroundColor =
|
||||
Utils.getDefaultColor(mContext, R.color.dark_mode_icon_color_dual_tone_background);
|
||||
mDarkModeFillColor =
|
||||
Utils.getDefaultColor(mContext, R.color.dark_mode_icon_color_dual_tone_fill);
|
||||
mLightModeBackgroundColor =
|
||||
Utils.getDefaultColor(mContext, R.color.light_mode_icon_color_dual_tone_background);
|
||||
mLightModeFillColor =
|
||||
Utils.getDefaultColor(mContext, R.color.light_mode_icon_color_dual_tone_fill);
|
||||
|
||||
mIntrinsicWidth = context.getResources().getDimensionPixelSize(R.dimen.battery_width);
|
||||
mIntrinsicHeight = context.getResources().getDimensionPixelSize(R.dimen.battery_height);
|
||||
}
|
||||
@@ -259,16 +244,6 @@ public class BatteryMeterDrawableBase extends Drawable {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setDarkIntensity(float darkIntensity) {
|
||||
if (darkIntensity == mOldDarkIntensity) {
|
||||
return;
|
||||
}
|
||||
int backgroundColor = getBackgroundColor(darkIntensity);
|
||||
int fillColor = getFillColor(darkIntensity);
|
||||
setColors(fillColor, backgroundColor);
|
||||
mOldDarkIntensity = darkIntensity;
|
||||
}
|
||||
|
||||
public void setColors(int fillColor, int backgroundColor) {
|
||||
mIconTint = fillColor;
|
||||
mFramePaint.setColor(backgroundColor);
|
||||
@@ -277,20 +252,6 @@ public class BatteryMeterDrawableBase extends Drawable {
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
private int getBackgroundColor(float darkIntensity) {
|
||||
return getColorForDarkIntensity(
|
||||
darkIntensity, mLightModeBackgroundColor, mDarkModeBackgroundColor);
|
||||
}
|
||||
|
||||
private int getFillColor(float darkIntensity) {
|
||||
return getColorForDarkIntensity(
|
||||
darkIntensity, mLightModeFillColor, mDarkModeFillColor);
|
||||
}
|
||||
|
||||
private int getColorForDarkIntensity(float darkIntensity, int lightColor, int darkColor) {
|
||||
return (int) ArgbEvaluator.getInstance().evaluate(darkIntensity, lightColor, darkColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas c) {
|
||||
final int level = mLevel;
|
||||
|
||||
@@ -40,13 +40,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
>
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:theme="@style/DualToneLightTheme"
|
||||
android:theme="?attr/lightIconTheme"
|
||||
android:id="@+id/ethernet"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
/>
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:theme="@style/DualToneDarkTheme"
|
||||
android:theme="?attr/darkIconTheme"
|
||||
android:id="@+id/ethernet_dark"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -79,13 +79,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
>
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:theme="@style/DualToneLightTheme"
|
||||
android:theme="?attr/lightIconTheme"
|
||||
android:id="@+id/wifi_signal"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
/>
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:theme="@style/DualToneDarkTheme"
|
||||
android:theme="?attr/darkIconTheme"
|
||||
android:id="@+id/wifi_signal_dark"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -120,14 +120,14 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:contentDescription="@string/accessibility_no_sims">
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:theme="@style/DualToneLightTheme"
|
||||
android:theme="?attr/lightIconTheme"
|
||||
android:id="@+id/no_sims"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/stat_sys_no_sims"
|
||||
/>
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:theme="@style/DualToneDarkTheme"
|
||||
android:theme="?attr/darkIconTheme"
|
||||
android:id="@+id/no_sims_dark"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -128,5 +128,8 @@
|
||||
<!-- The initial color for the scrim. -->
|
||||
<attr name="scrimColor" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<attr name="lightIconTheme" format="reference" />
|
||||
<attr name="darkIconTheme" format="reference" />
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -290,7 +290,14 @@
|
||||
<style name="Animation.StatusBar">
|
||||
</style>
|
||||
|
||||
<style name="systemui_theme" parent="@*android:style/Theme.DeviceDefault.QuickSettings" />
|
||||
<style name="systemui_theme" parent="@*android:style/Theme.DeviceDefault.QuickSettings">
|
||||
<item name="lightIconTheme">@style/DualToneLightTheme</item>
|
||||
<item name="darkIconTheme">@style/DualToneDarkTheme</item>
|
||||
</style>
|
||||
<style name="qs_theme" parent="systemui_theme">
|
||||
<item name="lightIconTheme">@style/QSIconTheme</item>
|
||||
<item name="darkIconTheme">@style/QSIconTheme</item>
|
||||
</style>
|
||||
|
||||
<style name="systemui_theme_remote_input" parent="@android:style/Theme.DeviceDefault.Light">
|
||||
<item name="android:colorAccent">@color/remote_input_accent</item>
|
||||
@@ -346,6 +353,11 @@
|
||||
<item name="fillColor">@color/dark_mode_icon_color_dual_tone_fill</item>
|
||||
<item name="singleToneColor">@color/dark_mode_icon_color_single_tone</item>
|
||||
</style>
|
||||
<style name="QSIconTheme">
|
||||
<item name="backgroundColor">?android:attr/textColorHint</item>
|
||||
<item name="fillColor">?android:attr/textColorPrimary</item>
|
||||
<item name="singleToneColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Volume">
|
||||
<item name="android:textStyle">normal</item>
|
||||
|
||||
@@ -17,25 +17,28 @@ package com.android.systemui;
|
||||
|
||||
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 @@ public class BatteryMeterView extends LinearLayout implements
|
||||
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 @@ public class BatteryMeterView extends LinearLayout implements
|
||||
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 @@ public class BatteryMeterView extends LinearLayout implements
|
||||
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 @@ public class BatteryMeterView extends LinearLayout implements
|
||||
private void updatePercentText() {
|
||||
if (mBatteryPercentView != null) {
|
||||
mBatteryPercentView.setText(
|
||||
NumberFormat.getPercentInstance().format(mLevel/100f));
|
||||
NumberFormat.getPercentInstance().format(mLevel / 100f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,8 +238,13 @@ public class BatteryMeterView extends LinearLayout implements
|
||||
|
||||
@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 class BatteryMeterView extends LinearLayout implements
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.graphics.Rect;
|
||||
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 android.widget.FrameLayout.LayoutParams;
|
||||
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 @@ public class QSFragment extends Fragment implements QS {
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,16 +36,15 @@ import android.util.Log;
|
||||
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 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user