diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/BatteryMeterView.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/BatteryMeterView.java | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 200679432200..592b6039d69d 100644 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -46,7 +46,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.android.settingslib.Utils; -import com.android.settingslib.graph.BatteryMeterDrawableBase; +import com.android.settingslib.graph.ThemedBatteryDrawable; import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver; import com.android.systemui.settings.CurrentUserTracker; @@ -76,7 +76,7 @@ public class BatteryMeterView extends LinearLayout implements public static final int MODE_OFF = 2; public static final int MODE_ESTIMATE = 3; - private final BatteryMeterDrawableBase mDrawable; + private final ThemedBatteryDrawable mDrawable; private final String mSlotBattery; private final ImageView mBatteryIconView; private final CurrentUserTracker mUserTracker; @@ -94,9 +94,11 @@ public class BatteryMeterView extends LinearLayout implements private boolean mIsSubscribedForTunerUpdates; private boolean mCharging; + private int mDarkModeSingleToneColor; private int mDarkModeBackgroundColor; private int mDarkModeFillColor; + private int mLightModeSingleToneColor; private int mLightModeBackgroundColor; private int mLightModeFillColor; private int mUser; @@ -106,6 +108,7 @@ public class BatteryMeterView extends LinearLayout implements */ private boolean mUseWallpaperTextColors; + private int mNonAdaptedSingleToneColor; private int mNonAdaptedForegroundColor; private int mNonAdaptedBackgroundColor; @@ -127,7 +130,7 @@ public class BatteryMeterView extends LinearLayout implements defStyle, 0); final int frameColor = atts.getColor(R.styleable.BatteryMeterView_frameColor, context.getColor(R.color.meter_background_color)); - mDrawable = new BatteryMeterDrawableBase(context, frameColor); + mDrawable = new ThemedBatteryDrawable(context, frameColor); atts.recycle(); mSettingObserver = new SettingObserver(new Handler(context.getMainLooper())); @@ -169,6 +172,10 @@ public class BatteryMeterView extends LinearLayout implements setClipChildren(false); setClipToPadding(false); Dependency.get(ConfigurationController.class).observe(viewAttachLifecycle(this), this); + + // Needed for PorderDuff.Mode.CLEAR operations to work properly, but redraws don't happen + // enough to justify a hardware layer. + setLayerType(LAYER_TYPE_SOFTWARE, null); } public void setForceShowPercent(boolean show) { @@ -243,9 +250,11 @@ public class BatteryMeterView extends LinearLayout implements if (mUseWallpaperTextColors) { updateColors( Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColor), - Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColorSecondary)); + Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColorSecondary), + Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColor)); } else { - updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor); + updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor, + mNonAdaptedSingleToneColor); } } @@ -258,10 +267,14 @@ public class BatteryMeterView extends LinearLayout implements Utils.getThemeAttr(context, R.attr.darkIconTheme)); Context dualToneLightTheme = new ContextThemeWrapper(context, Utils.getThemeAttr(context, R.attr.lightIconTheme)); + mDarkModeSingleToneColor = Utils.getColorAttrDefaultColor(dualToneDarkTheme, + R.attr.singleToneColor); mDarkModeBackgroundColor = Utils.getColorAttrDefaultColor(dualToneDarkTheme, R.attr.backgroundColor); mDarkModeFillColor = Utils.getColorAttrDefaultColor(dualToneDarkTheme, R.attr.fillColor); + mLightModeSingleToneColor = Utils.getColorAttrDefaultColor(dualToneLightTheme, + R.attr.singleToneColor); mLightModeBackgroundColor = Utils.getColorAttrDefaultColor(dualToneLightTheme, R.attr.backgroundColor); mLightModeFillColor = Utils.getColorAttrDefaultColor(dualToneLightTheme, R.attr.fillColor); @@ -303,8 +316,8 @@ public class BatteryMeterView extends LinearLayout implements @Override public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { - mDrawable.setBatteryLevel(level); mDrawable.setCharging(pluggedIn); + mDrawable.setBatteryLevel(level); mCharging = pluggedIn; mLevel = level; updatePercentText(); @@ -315,7 +328,7 @@ public class BatteryMeterView extends LinearLayout implements @Override public void onPowerSaveChanged(boolean isPowerSave) { - mDrawable.setPowerSave(isPowerSave); + mDrawable.setPowerSaveEnabled(isPowerSave); } private TextView loadPercentView() { @@ -406,21 +419,24 @@ public class BatteryMeterView extends LinearLayout implements @Override public void onDarkChanged(Rect area, float darkIntensity, int tint) { float intensity = DarkIconDispatcher.isInArea(area, this) ? darkIntensity : 0; + mNonAdaptedSingleToneColor = getColorForDarkIntensity( + intensity, mLightModeSingleToneColor, mDarkModeSingleToneColor); mNonAdaptedForegroundColor = getColorForDarkIntensity( intensity, mLightModeFillColor, mDarkModeFillColor); mNonAdaptedBackgroundColor = getColorForDarkIntensity( intensity, mLightModeBackgroundColor,mDarkModeBackgroundColor); if (!mUseWallpaperTextColors) { - updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor); + updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor, + mNonAdaptedSingleToneColor); } } - private void updateColors(int foregroundColor, int backgroundColor) { - mDrawable.setColors(foregroundColor, backgroundColor); - mTextColor = foregroundColor; + private void updateColors(int foregroundColor, int backgroundColor, int singleToneColor) { + mDrawable.setColors(foregroundColor, backgroundColor, singleToneColor); + mTextColor = singleToneColor; if (mBatteryPercentView != null) { - mBatteryPercentView.setTextColor(foregroundColor); + mBatteryPercentView.setTextColor(singleToneColor); } } @@ -429,7 +445,7 @@ public class BatteryMeterView extends LinearLayout implements } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - String powerSave = mDrawable == null ? null : mDrawable.getPowerSave() + ""; + String powerSave = mDrawable == null ? null : mDrawable.getPowerSaveEnabled() + ""; CharSequence percent = mBatteryPercentView == null ? null : mBatteryPercentView.getText(); pw.println(" BatteryMeterView:"); pw.println(" mDrawable.getPowerSave: " + powerSave); |