Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d37a5aa5 authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

SysUI: Fix coloring of frame and bolt

This patch should address issues with the frame and bolt being
incorrectly colored in dark/light scenarios.  We also keep track
of the darkness intensity level so that it can be set when changing
meter modes.

Change-Id: Iaec8b88d39bbb7f6dbcbbf078c91d20b54ab29c8
parent 5953be01
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -20,9 +20,10 @@
    android:viewportWidth="24"
    android:viewportHeight="24">

    <!-- Path will be tinted based on light/dark modes -->
    <path
        android:name="frame"
        android:strokeColor="@color/batterymeter_frame_color"
        android:strokeColor="#000000"
        android:strokeLineJoin="round"
        android:strokeWidth="3"
        android:pathData="@string/battery_circle_path"/>
+2 −1
Original line number Diff line number Diff line
@@ -24,8 +24,9 @@
        android:name="mask"
        android:pathData="@string/battery_landscape_clip_path" />

    <!-- Path will be tinted based on light/dark modes -->
    <path
        android:name="frame"
        android:fillColor="@color/batterymeter_frame_color"
        android:fillColor="#000000"
        android:pathData="M 1 4 H 25 V 20 H 1 V 4 Z" />
</vector>
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -24,9 +24,10 @@
        android:name="mask"
        android:pathData="@string/battery_portrait_clip_path" />

    <!-- Path will be tinted based on light/dark modes -->
    <path
        android:name="frame"
        android:fillColor="@color/batterymeter_frame_color"
        android:fillColor="#000000"
        android:pathData="M19,2v19H5V2H19z" />

</vector>
 No newline at end of file
+15 −4
Original line number Diff line number Diff line
@@ -94,6 +94,9 @@ public class BatteryMeterView extends View implements DemoMode,
    private BatteryMeterDrawable mBatteryMeterDrawable;
    private int mIconTint = Color.WHITE;

    private int mCurrentBackgroundColor = 0;
    private int mCurrentFillColor = 0;

    protected class BatteryTracker extends BroadcastReceiver {
        public static final int UNKNOWN_LEVEL = -1;

@@ -395,9 +398,9 @@ public class BatteryMeterView extends View implements DemoMode,

    public void setDarkIntensity(float darkIntensity) {
        if (mBatteryMeterDrawable != null) {
            int backgroundColor = getBackgroundColor(darkIntensity);
            int fillColor = getFillColor(darkIntensity);
            mBatteryMeterDrawable.setDarkIntensity(backgroundColor, fillColor);
            mCurrentBackgroundColor = getBackgroundColor(darkIntensity);
            mCurrentFillColor = getFillColor(darkIntensity);
            mBatteryMeterDrawable.setDarkIntensity(mCurrentBackgroundColor, mCurrentFillColor);
        }
    }

@@ -511,6 +514,9 @@ public class BatteryMeterView extends View implements DemoMode,
            mTextAndBoltPaint.setTypeface(font);
            mTextAndBoltPaint.setTextAlign(getPaintAlignmentFromGravity(mTextGravity));
            mTextAndBoltPaint.setXfermode(new PorterDuffXfermode(xferMode));
            mTextAndBoltPaint.setColor(mCurrentFillColor != 0
                    ? mCurrentFillColor
                    : res.getColor(R.color.batterymeter_bolt_color));

            mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
            mWarningTextPaint.setColor(mColors[1]);
@@ -544,7 +550,9 @@ public class BatteryMeterView extends View implements DemoMode,
        @Override
        public void setDarkIntensity(int backgroundColor, int fillColor) {
            mIconTint = fillColor;
            mBoltDrawable.setTint(fillColor);
            // Make bolt fully opaque for increased visibility
            mBoltDrawable.setTint(0xff000000 | fillColor);
            mFrameDrawable.setTint(backgroundColor);
            updateBoltDrawableLayer(mBatteryDrawable, mBoltDrawable);
            invalidate();
        }
@@ -628,6 +636,9 @@ public class BatteryMeterView extends View implements DemoMode,
            int drawableResId = getBatteryDrawableResourceForMode(mode);
            mBatteryDrawable = (LayerDrawable) res.getDrawable(drawableResId);
            mFrameDrawable = mBatteryDrawable.findDrawableByLayerId(R.id.battery_frame);
            mFrameDrawable.setTint(mCurrentBackgroundColor != 0
                    ? mCurrentBackgroundColor
                    : res.getColor(R.color.batterymeter_frame_color));
            // set the animated vector drawable we will be stop animating
            Drawable levelDrawable = mBatteryDrawable.findDrawableByLayerId(R.id.battery_fill);
            mLevelDrawable = new StopMotionVectorDrawable(levelDrawable);