From 3f12992231c445e879cbd457ba13532d91beb1e7 Mon Sep 17 00:00:00 2001 From: Beverly Date: Wed, 21 Mar 2018 10:10:33 -0400 Subject: [PATCH] Tweaks to wireless charging animation Animation is white when dozing Bug: 74946337 Fixes: 76201223 Test: manual Change-Id: I9408b38cd624e8599eb4689b04d1973ef8f0c61f --- .../res/layout/wireless_charging_layout.xml | 2 +- packages/SystemUI/res/values/dimens.xml | 12 +++++----- .../charging/WirelessChargingAnimation.java | 14 +++++------ .../charging/WirelessChargingLayout.java | 24 ++++++++++++------- .../charging/WirelessChargingView.java | 4 ++++ .../systemui/statusbar/phone/StatusBar.java | 4 ++-- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/packages/SystemUI/res/layout/wireless_charging_layout.xml b/packages/SystemUI/res/layout/wireless_charging_layout.xml index 85a325a0e4cb2..e8489016811cf 100644 --- a/packages/SystemUI/res/layout/wireless_charging_layout.xml +++ b/packages/SystemUI/res/layout/wireless_charging_layout.xml @@ -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"/> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index d65e42bc4e40d..d1e803c846bdd 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -929,14 +929,14 @@ 0dp 4dp 28dp - 92dp + 84dp 20 83 - 20 - - 0dp - - 14dp + 16 + + 0 + + 24 80 diff --git a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java index afc9629eceded..e11fe4e2c5232 100644 --- a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java +++ b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java index 9887533721300..c8e83dea2958c 100644 --- a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java +++ b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java @@ -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% diff --git a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingView.java b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingView.java index 19c6dc1ceb1f6..9c411d6cb1af9 100644 --- a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingView.java +++ b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingView.java @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index feb7dc360ad65..b78c3d07f3544 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -2488,11 +2488,11 @@ public class StatusBar extends SystemUI implements DemoMode, public void onAnimationEnded() { CrossFadeHelper.fadeIn(mNotificationPanel); } - }).show(); + }, mDozing).show(); } else { // workspace WirelessChargingAnimation.makeWirelessChargingAnimation(mContext, null, - batteryLevel, null).show(); + batteryLevel, null, false).show(); } }