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

Commit 42f8ade5 authored by Beverly Tai's avatar Beverly Tai Committed by android-build-merger
Browse files

Merge "Tweaks to wireless charging animation" into pi-dev

am: 361b809e

Change-Id: I3efc3212fb6ba2cbdd3b3927954c2dbed3fa5a29
parents d3cc889f 361b809e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="32sp"
            android:textSize="24sp"
            android:textColor="?attr/wallpaperTextColor"/>
    </LinearLayout>

+6 −6
Original line number Diff line number Diff line
@@ -929,14 +929,14 @@
    <dimen name="wireless_charging_dots_radius_start">0dp</dimen>
    <dimen name="wireless_charging_dots_radius_end">4dp</dimen>
    <dimen name="wireless_charging_circle_radius_start">28dp</dimen>
    <dimen name="wireless_charging_circle_radius_end">92dp</dimen>
    <dimen name="wireless_charging_circle_radius_end">84dp</dimen>
    <integer name="wireless_charging_angle_offset">20</integer>
    <integer name="wireless_charging_scale_dots_duration">83</integer>
    <integer name="wireless_charging_num_dots">20</integer>
    <!-- Starting text size in dp of batteryLevel for wireless charging animation -->
    <dimen name="wireless_charging_anim_battery_level_text_size_start">0dp</dimen>
    <!-- Ending text size in dp of batteryLevel for wireless charging animation -->
    <dimen name="wireless_charging_anim_battery_level_text_size_end">14dp</dimen>
    <integer name="wireless_charging_num_dots">16</integer>
    <!-- Starting text size in sp of batteryLevel for wireless charging animation -->
    <item name="wireless_charging_anim_battery_level_text_size_start" format="float" type="dimen">0</item>
    <!-- Ending text size in sp of batteryLevel for wireless charging animation -->
    <item name="wireless_charging_anim_battery_level_text_size_end" format="float" type="dimen">24</item>
    <!-- time until battery info is at full opacity-->
    <integer name="wireless_charging_anim_opacity_offset">80</integer>
    <!-- duration batteryLevel opacity goes from 0 to 1 duration -->
+7 −7
Original line number Diff line number Diff line
@@ -55,9 +55,9 @@ public class WirelessChargingAnimation {
     * @hide
     */
    public WirelessChargingAnimation(@NonNull Context context, @Nullable Looper looper, int
            batteryLevel, Callback callback) {
            batteryLevel, Callback callback, boolean isDozing) {
        mCurrentWirelessChargingView = new WirelessChargingView(context, looper,
                batteryLevel, callback);
                batteryLevel, callback, isDozing);
    }

    /**
@@ -65,8 +65,8 @@ public class WirelessChargingAnimation {
     * @hide
     */
    public static WirelessChargingAnimation makeWirelessChargingAnimation(@NonNull Context context,
            @Nullable Looper looper, int batteryLevel, Callback callback) {
        return new WirelessChargingAnimation(context, looper, batteryLevel, callback);
            @Nullable Looper looper, int batteryLevel, Callback callback, boolean isDozing) {
        return new WirelessChargingAnimation(context, looper, batteryLevel, callback, isDozing);
    }

    /**
@@ -102,14 +102,14 @@ public class WirelessChargingAnimation {
        private Callback mCallback;

        public WirelessChargingView(Context context, @Nullable Looper looper, int batteryLevel,
                Callback callback) {
                Callback callback, boolean isDozing) {
            mCallback = callback;
            mNextView = new WirelessChargingLayout(context, batteryLevel);
            mNextView = new WirelessChargingLayout(context, batteryLevel, isDozing);
            mGravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER;

            final WindowManager.LayoutParams params = mParams;
            params.height = WindowManager.LayoutParams.WRAP_CONTENT;
            params.width = WindowManager.LayoutParams.WRAP_CONTENT;
            params.width = WindowManager.LayoutParams.MATCH_PARENT;
            params.format = PixelFormat.TRANSLUCENT;

            params.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
+15 −9
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.animation.PathInterpolator;
import android.widget.FrameLayout;
@@ -38,24 +39,24 @@ public class WirelessChargingLayout extends FrameLayout {

    public WirelessChargingLayout(Context context) {
        super(context);
        init(context, null);
        init(context, null, false);
    }

    public WirelessChargingLayout(Context context, int batterylLevel) {
    public WirelessChargingLayout(Context context, int batteryLevel, boolean isDozing) {
        super(context);
        init(context, null, batterylLevel);
        init(context, null, batteryLevel, isDozing);
    }

    public WirelessChargingLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
        init(context, attrs, false);
    }

    private void init(Context c, AttributeSet attrs) {
        init(c, attrs, -1);
    private void init(Context c, AttributeSet attrs, boolean isDozing) {
        init(c, attrs, -1, false);
    }

    private void init(Context context, AttributeSet attrs, int batteryLevel) {
    private void init(Context context, AttributeSet attrs, int batteryLevel, boolean isDozing) {
        final int mBatteryLevel = batteryLevel;
        inflate(context, R.layout.wireless_charging_layout, this);

@@ -65,6 +66,11 @@ public class WirelessChargingLayout extends FrameLayout {
        // amount of battery:
        final TextView mPercentage = findViewById(R.id.wireless_charging_percentage);

        if (isDozing) {
            mChargingView.setPaintColor(Color.WHITE);
            mPercentage.setTextColor(Color.WHITE);
        }

        if (batteryLevel != UNKNOWN_BATTERY_LEVEL) {
            mPercentage.setText(NumberFormat.getPercentInstance().format(mBatteryLevel / 100f));
            mPercentage.setAlpha(0);
@@ -74,9 +80,9 @@ public class WirelessChargingLayout extends FrameLayout {
                R.integer.wireless_charging_fade_offset);
        final long chargingAnimationFadeDuration = (long) context.getResources().getInteger(
                R.integer.wireless_charging_fade_duration);
        final int batteryLevelTextSizeStart = context.getResources().getDimensionPixelSize(
        final float batteryLevelTextSizeStart = context.getResources().getFloat(
                R.dimen.wireless_charging_anim_battery_level_text_size_start);
        final int batteryLevelTextSizeEnd = context.getResources().getDimensionPixelSize(
        final float batteryLevelTextSizeEnd = context.getResources().getFloat(
                R.dimen.wireless_charging_anim_battery_level_text_size_end);

        // Animation Scale: battery percentage text scales from 0% to 100%
+4 −0
Original line number Diff line number Diff line
@@ -98,6 +98,10 @@ final class WirelessChargingView extends View {
        mPaint.setColor(Utils.getColorAttr(mContext, R.attr.wallpaperTextColor));
    }

    public void setPaintColor(int color) {
        mPaint.setColor(color);
    }

    @Override
    protected void onDraw(final Canvas canvas) {
        super.onDraw(canvas);
Loading