From 1817f066ec3dc30e3438966d58a043ab1c396317 Mon Sep 17 00:00:00 2001 From: mxyyiyi Date: Wed, 8 Nov 2023 16:52:48 +0800 Subject: [PATCH] Update Power Anomaly UI. For Settings tip & app anomaly banner: - update app anomaly hint color in dark/light theme [Banner card] - update icons to GM3 style - update text font and button text color - update button style from outlined to filled. [Chart view] - update warning icon size - update percentage label alignment Screenshots: - [Settings] [light] https://screenshot.googleplex.com/ERWkD7TmDsLaxdG [dark] https://screenshot.googleplex.com/6JKvL5vEQTZtJfd - [App] [light] https://screenshot.googleplex.com/3YoncDhGTzUcAZA https://screenshot.googleplex.com/3hbGmqoYWSy9H9U [dark] https://screenshot.googleplex.com/9XKs8tXmRKL2jJP https://screenshot.googleplex.com/SU4LTJYWXvpd42r - [RTL+L10N][Arabic] [Settings] https://screenshot.googleplex.com/V9HJkPcsoBJmsW8 [Apps] https://screenshot.googleplex.com/B49VKy2jaZYisWK https://screenshot.googleplex.com/6VZQ2gESRes8RMH - [Force RTL][EN] [Settings] https://screenshot.googleplex.com/4V7coyLf5ueUcGv [Apps] https://screenshot.googleplex.com/9UaERwDmrpitqdq https://screenshot.googleplex.com/3JDfcXi8pmz5Mew Bug: 309569299 Test: manual Change-Id: I8bee7f86d602112e0cbbd936b439330aaff7275c --- color-check-baseline.xml | 606 +++++++++--------- ..._battery_anomaly_app_warning_selector.xml} | 2 +- res/drawable/ic_battery_tips_lightbulb.xml | 6 +- res/drawable/ic_battery_tips_warning_icon.xml | 8 +- res/layout/battery_tips_card.xml | 129 ++-- res/values-night/colors.xml | 3 + res/values/arrays.xml | 2 +- res/values/colors.xml | 4 + res/values/dimens.xml | 2 +- res/values/strings.xml | 3 + .../batteryusage/AnomalyEventWrapper.java | 2 +- .../batteryusage/BatteryChartView.java | 8 +- .../BatteryTipsCardPreference.java | 48 +- .../BatteryTipsControllerTest.java | 11 +- 14 files changed, 394 insertions(+), 440 deletions(-) rename res/color/{color_battery_anomaly_yellow_selector.xml => color_battery_anomaly_app_warning_selector.xml} (91%) diff --git a/color-check-baseline.xml b/color-check-baseline.xml index 7a5e80d0a8a..5a0e98ef9be 100644 --- a/color-check-baseline.xml +++ b/color-check-baseline.xml @@ -1,18 +1,6 @@ - - - - + errorLine1=" android:textColor="@color/power_anomaly_primary_button_text_color"" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + file="res/layout/battery_tips_card.xml" + line="57" + column="13"/> + errorLine1=" android:textColor="@color/power_anomaly_primary_button_text_color"" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + file="res/layout/battery_tips_card.xml" + line="57" + column="13"/> + errorLine1=" <color name="homepage_accessibility_background">#783BE5</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + - - - - + errorLine1=" <color name="notification_importance_button_unselected">#5F6368</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -797,22 +785,6 @@ column="5"/> - - - - + + + + + errorLine1=" <color name="message_bubble_incoming">#52534D</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -965,11 +953,11 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="message_bubble_incoming">#52534D</color>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="biometric_enroll_intro_color_bar">#5bb974</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -989,6 +977,22 @@ column="5"/> + + + + + errorLine1=" <color name="biometric_enroll_intro_color_outline">#5e5e5e</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="fingerprint_enrollment_finish_color_outline">#669df6</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - + + + + + + + + + errorLine1=" <color name="sfps_enrollment_progress_bar_fill_color">#669df6</color> <!-- Blue 400 -->" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="sfps_enrollment_progress_bar_error_color">#ee675c</color> <!-- Red 400 -->" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - + + + + + + + + - - - - + errorLine1=" <color name="udfps_enroll_icon">#7DA7F1</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="udfps_moving_target_fill">#475670</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1445,11 +1433,11 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="udfps_moving_target_fill_error">#80475670</color>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="homepage_system_background">#9E9E9E</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1477,8 +1465,8 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="udfps_enroll_progress">#7DA7F1</color>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="udfps_moving_target_fill_error">#80475670</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="udfps_enroll_progress">#7DA7F1</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="udfps_enroll_progress_help">#607DA7F1</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + - - - - - - - - @@ -1625,7 +1597,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1641,7 +1613,23 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + @@ -1657,7 +1645,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1673,7 +1661,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1689,7 +1677,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1705,7 +1693,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1721,7 +1709,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1737,7 +1725,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1753,7 +1741,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1769,7 +1757,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1785,7 +1773,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1801,7 +1789,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1817,7 +1805,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1833,7 +1821,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1849,7 +1837,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1865,7 +1853,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1881,7 +1869,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1897,7 +1885,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1913,7 +1901,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1929,7 +1917,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1945,7 +1933,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1961,7 +1949,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1977,7 +1965,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1993,7 +1981,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2009,7 +1997,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2025,7 +2013,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2041,7 +2029,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2057,7 +2045,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2073,7 +2061,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2089,7 +2077,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2105,7 +2093,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2121,7 +2109,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2137,7 +2125,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2153,7 +2141,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2169,7 +2157,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2185,7 +2173,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2201,7 +2189,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2217,7 +2205,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2233,7 +2221,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2249,7 +2237,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2265,7 +2253,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2281,7 +2269,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2297,7 +2285,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2313,7 +2301,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2329,7 +2317,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2345,7 +2333,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2361,7 +2349,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2377,7 +2365,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2393,7 +2381,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2409,7 +2397,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2425,7 +2413,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2441,7 +2429,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2457,7 +2445,39 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + + + + + @@ -4581,12 +4601,12 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" android:tint="#4F8438"" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" android:tint="#4F8438"" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~"> + line="45" + column="17"/> @@ -6121,7 +6141,7 @@ errorLine2=" ^"> @@ -6137,7 +6157,7 @@ errorLine2=" ^"> @@ -6153,7 +6173,7 @@ errorLine2=" ^"> @@ -6169,7 +6189,7 @@ errorLine2=" ^"> @@ -6185,7 +6205,7 @@ errorLine2=" ^"> @@ -6201,7 +6221,7 @@ errorLine2=" ^"> @@ -6217,7 +6237,7 @@ errorLine2=" ^"> @@ -6233,7 +6253,7 @@ errorLine2=" ^"> @@ -6249,7 +6269,7 @@ errorLine2=" ^"> @@ -6265,7 +6285,7 @@ errorLine2=" ^"> @@ -6281,7 +6301,7 @@ errorLine2=" ^"> @@ -6349,38 +6369,6 @@ column="41"/> - - - - - - - - @@ -6409,7 +6397,7 @@ errorLine2=" ^"> @@ -6425,7 +6413,7 @@ errorLine2=" ^"> @@ -6441,7 +6429,7 @@ errorLine2=" ^"> @@ -6457,7 +6445,7 @@ errorLine2=" ^"> @@ -6473,7 +6461,7 @@ errorLine2=" ^"> diff --git a/res/color/color_battery_anomaly_yellow_selector.xml b/res/color/color_battery_anomaly_app_warning_selector.xml similarity index 91% rename from res/color/color_battery_anomaly_yellow_selector.xml rename to res/color/color_battery_anomaly_app_warning_selector.xml index 0dd79c2fb84..4ad78e6784e 100644 --- a/res/color/color_battery_anomaly_yellow_selector.xml +++ b/res/color/color_battery_anomaly_app_warning_selector.xml @@ -14,5 +14,5 @@ limitations under the License. --> - + diff --git a/res/drawable/ic_battery_tips_lightbulb.xml b/res/drawable/ic_battery_tips_lightbulb.xml index 6fffefc8119..19b6ab890ac 100644 --- a/res/drawable/ic_battery_tips_lightbulb.xml +++ b/res/drawable/ic_battery_tips_lightbulb.xml @@ -17,9 +17,9 @@ + android:viewportWidth="960" + android:viewportHeight="960"> + android:pathData="M176,680Q114,643 77,580Q40,517 40,440Q40,323 121.5,241.5Q203,160 320,160Q437,160 518.5,241.5Q600,323 600,440Q600,517 563,580Q526,643 464,680L176,680ZM200,600L440,600Q478,571 499,529.5Q520,488 520,440Q520,357 461.5,298.5Q403,240 320,240Q237,240 178.5,298.5Q120,357 120,440Q120,488 141,529.5Q162,571 200,600ZM176,800L176,720L464,720L464,800L176,800ZM320,920Q287,920 263.5,896.5Q240,873 240,840L400,840Q400,873 376.5,896.5Q353,920 320,920ZM740,401Q740,326 687,273Q634,220 559,220Q634,220 687,167.5Q740,115 740,40Q740,115 792.5,167.5Q845,220 920,220Q845,220 792.5,273Q740,326 740,401ZM320,600Q320,600 320,600Q320,600 320,600Q320,600 320,600Q320,600 320,600Q320,600 320,600Q320,600 320,600Q320,600 320,600Q320,600 320,600L320,600Z"/> \ No newline at end of file diff --git a/res/drawable/ic_battery_tips_warning_icon.xml b/res/drawable/ic_battery_tips_warning_icon.xml index c5df8a8856d..0dcfa6d3bd3 100644 --- a/res/drawable/ic_battery_tips_warning_icon.xml +++ b/res/drawable/ic_battery_tips_warning_icon.xml @@ -17,9 +17,9 @@ + android:viewportWidth="960" + android:viewportHeight="960"> + android:fillColor="@color/color_battery_anomaly_app_warning_selector" + android:pathData="M40,840L480,80L920,840L40,840ZM178,760L782,760L480,240L178,760ZM480,720Q497,720 508.5,708.5Q520,697 520,680Q520,663 508.5,651.5Q497,640 480,640Q463,640 451.5,651.5Q440,663 440,680Q440,697 451.5,708.5Q463,720 480,720ZM440,600L520,600L520,400L440,400L440,600ZM480,500L480,500L480,500L480,500Z"/> \ No newline at end of file diff --git a/res/layout/battery_tips_card.xml b/res/layout/battery_tips_card.xml index c9a00bc6ab9..1a121ba34ea 100644 --- a/res/layout/battery_tips_card.xml +++ b/res/layout/battery_tips_card.xml @@ -4,109 +4,58 @@ android:id="@+id/battery_tips_card" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginStart="?android:attr/listPreferredItemPaddingStart" + android:layout_marginEnd="?android:attr/listPreferredItemPaddingEnd" + android:background="@drawable/battery_tips_all_rounded_bg_ripple" android:orientation="vertical" - android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> + android:padding="20dp"> - + + - - - - - - - - - - - - - - + android:layout_marginTop="8dp" + android:textAlignment="viewStart" + android:textAppearance="@style/TextAppearance.Material3.TitleMedium" + android:textColor="?android:attr/textColorPrimary" /> + android:layout_marginTop="8dp" + android:gravity="end" + android:orientation="horizontal"> - - - + android:layout_gravity="end|center_vertical" + android:layout_marginEnd="8dp" + android:paddingHorizontal="16dp" + android:text="@string/battery_tips_card_dismiss_button" + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2" + android:textColor="@color/color_accent_selector" /> - + android:layout_gravity="end|center_vertical" + android:paddingHorizontal="16dp" + android:text="@string/battery_tips_card_action_button" + android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2" + android:textColor="@color/power_anomaly_primary_button_text_color" + app:backgroundTint="@color/color_accent_selector" /> \ No newline at end of file diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml index b83b2fa869e..9334d19e1d2 100644 --- a/res/values-night/colors.xml +++ b/res/values-night/colors.xml @@ -56,6 +56,9 @@ @android:color/white + + #FDD663 + #2E3300 #7DA7F1 diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 484af0aa562..7283be24415 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -1417,7 +1417,7 @@ color_accent_selector - color_battery_anomaly_yellow_selector + color_battery_anomaly_app_warning_selector diff --git a/res/values/colors.xml b/res/values/colors.xml index ae979458acc..f76f46ec108 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -169,6 +169,10 @@ ?android:attr/textColorPrimary + + #D56E0C + #FFFFFF + #699FF3 #C2D7F7 diff --git a/res/values/dimens.xml b/res/values/dimens.xml index aed72dcd74d..643f110ce5b 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -389,7 +389,7 @@ 4dp 4dp 4dp - 12dp + 18dp 2dp 12dp 182dp diff --git a/res/values/strings.xml b/res/values/strings.xml index 808ddc4bd4e..37b9eb335d2 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10007,6 +10007,9 @@ %1$s used more battery than usual while in the foreground + + Battery usage anomaly + High battery usage diff --git a/src/com/android/settings/fuelgauge/batteryusage/AnomalyEventWrapper.java b/src/com/android/settings/fuelgauge/batteryusage/AnomalyEventWrapper.java index 13c8a91472e..8658fba772c 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/AnomalyEventWrapper.java +++ b/src/com/android/settings/fuelgauge/batteryusage/AnomalyEventWrapper.java @@ -234,7 +234,7 @@ final class AnomalyEventWrapper { } preference.setTitle(titleString); preference.setIconResourceId(getIconResId()); - preference.setMainButtonStrokeColorResourceId(getColorResId()); + preference.setButtonColorResourceId(getColorResId()); preference.setMainButtonLabel(getMainBtnString()); preference.setDismissButtonLabel(getDismissBtnString()); return true; diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java index ad5d4203842..6ff52a2bc1d 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java +++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java @@ -378,7 +378,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick mTransomTop = resources.getDimensionPixelSize(R.dimen.chartview_transom_padding_top); mTransomLineDefaultColor = Utils.getDisabled(mContext, DIVIDER_COLOR); mTransomLineSelectedColor = - resources.getColor(R.color.color_battery_anomaly_yellow_selector); + resources.getColor(R.color.color_battery_anomaly_app_warning_selector); final int slotHighlightColor = Utils.getDisabled(mContext, mTransomLineSelectedColor); mTransomIconSize = resources.getDimensionPixelSize(R.dimen.chartview_transom_icon_size); mTransomLinePaint = new Paint(); @@ -419,11 +419,13 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick private void drawPercentage(Canvas canvas, int index, float offsetY) { if (mTextPaint != null) { - mTextPaint.setTextAlign(Paint.Align.RIGHT); + mTextPaint.setTextAlign(isRTL() ? Paint.Align.RIGHT : Paint.Align.LEFT); mTextPaint.setColor(mDefaultTextColor); canvas.drawText( mPercentages[index], - isRTL() ? mIndent.left - mTextPadding : getWidth(), + isRTL() + ? mIndent.left - mTextPadding + : getWidth() - mIndent.width() + mTextPadding, offsetY + mPercentageBounds[index].height() * .5f, mTextPaint); } diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsCardPreference.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsCardPreference.java index 7eec8167bd4..bbd10997509 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsCardPreference.java +++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsCardPreference.java @@ -29,8 +29,6 @@ import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; import com.android.settings.R; -import com.android.settings.overlay.FeatureFactory; -import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.google.android.material.button.MaterialButton; @@ -47,11 +45,10 @@ public class BatteryTipsCardPreference extends Preference implements View.OnClic void onReject(); } - private final MetricsFeatureProvider mMetricsFeatureProvider; private OnConfirmListener mOnConfirmListener; private OnRejectListener mOnRejectListener; private int mIconResourceId = 0; - private int mMainButtonStrokeColorResourceId = 0; + private int mButtonColorResourceId = 0; @VisibleForTesting CharSequence mMainButtonLabel; @VisibleForTesting CharSequence mDismissButtonLabel; @@ -59,9 +56,8 @@ public class BatteryTipsCardPreference extends Preference implements View.OnClic public BatteryTipsCardPreference(Context context, AttributeSet attrs) { super(context, attrs); setLayoutResource(R.layout.battery_tips_card); + setViewId(R.id.battery_tips_card); setSelectable(false); - final FeatureFactory featureFactory = FeatureFactory.getFeatureFactory(); - mMetricsFeatureProvider = featureFactory.getMetricsFeatureProvider(); } public void setOnConfirmListener(OnConfirmListener listener) { @@ -72,7 +68,9 @@ public class BatteryTipsCardPreference extends Preference implements View.OnClic mOnRejectListener = listener; } - /** Sets the icon in tips card. */ + /** + * Sets the icon in tips card. + */ public void setIconResourceId(int resourceId) { if (mIconResourceId != resourceId) { mIconResourceId = resourceId; @@ -80,15 +78,19 @@ public class BatteryTipsCardPreference extends Preference implements View.OnClic } } - /** Sets the stroke color of main button in tips card. */ - public void setMainButtonStrokeColorResourceId(int resourceId) { - if (mMainButtonStrokeColorResourceId != resourceId) { - mMainButtonStrokeColorResourceId = resourceId; + /** + * Sets the background color for main button and the text color for dismiss button. + */ + public void setButtonColorResourceId(int resourceId) { + if (mButtonColorResourceId != resourceId) { + mButtonColorResourceId = resourceId; notifyChanged(); } } - /** Sets the label of main button in tips card. */ + /** + * Sets the label of main button in tips card. + */ public void setMainButtonLabel(CharSequence label) { if (!TextUtils.equals(mMainButtonLabel, label)) { mMainButtonLabel = label; @@ -96,7 +98,9 @@ public class BatteryTipsCardPreference extends Preference implements View.OnClic } } - /** Sets the label of dismiss button in tips card. */ + /** + * Sets the label of dismiss button in tips card. + */ public void setDismissButtonLabel(CharSequence label) { if (!TextUtils.equals(mDismissButtonLabel, label)) { mDismissButtonLabel = label; @@ -107,7 +111,7 @@ public class BatteryTipsCardPreference extends Preference implements View.OnClic @Override public void onClick(View view) { final int viewId = view.getId(); - if (viewId == R.id.main_button || viewId == R.id.tips_card) { + if (viewId == R.id.main_button || viewId == R.id.battery_tips_card) { if (mOnConfirmListener != null) { mOnConfirmListener.onConfirm(); } @@ -124,17 +128,21 @@ public class BatteryTipsCardPreference extends Preference implements View.OnClic ((TextView) view.findViewById(R.id.title)).setText(getTitle()); - LinearLayout tipsCard = (LinearLayout) view.findViewById(R.id.tips_card); + final LinearLayout tipsCard = (LinearLayout) view.findViewById(R.id.battery_tips_card); tipsCard.setOnClickListener(this); - MaterialButton mainButton = (MaterialButton) view.findViewById(R.id.main_button); + final MaterialButton mainButton = (MaterialButton) view.findViewById(R.id.main_button); mainButton.setOnClickListener(this); mainButton.setText(mMainButtonLabel); - if (mMainButtonStrokeColorResourceId != 0) { - mainButton.setStrokeColorResource(mMainButtonStrokeColorResourceId); - } - MaterialButton dismissButton = (MaterialButton) view.findViewById(R.id.dismiss_button); + final MaterialButton dismissButton = + (MaterialButton) view.findViewById(R.id.dismiss_button); dismissButton.setOnClickListener(this); dismissButton.setText(mDismissButtonLabel); + if (mButtonColorResourceId != 0) { + final int colorInt = getContext().getColor(mButtonColorResourceId); + mainButton.setBackgroundColor(colorInt); + dismissButton.setTextColor(colorInt); + } + if (mIconResourceId != 0) { ((ImageView) view.findViewById(R.id.icon)).setImageResource(mIconResourceId); } diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsControllerTest.java index 91b2e15d2b4..e7c8e81f422 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsControllerTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryTipsControllerTest.java @@ -84,8 +84,7 @@ public final class BatteryTipsControllerTest { verify(mBatteryTipsCardPreference) .setTitle("Turn on adaptive brightness to extend battery life"); verify(mBatteryTipsCardPreference).setIconResourceId(R.drawable.ic_battery_tips_lightbulb); - verify(mBatteryTipsCardPreference) - .setMainButtonStrokeColorResourceId(R.color.color_accent_selector); + verify(mBatteryTipsCardPreference).setButtonColorResourceId(R.color.color_accent_selector); verify(mBatteryTipsCardPreference).setMainButtonLabel("View Settings"); verify(mBatteryTipsCardPreference).setDismissButtonLabel("Got it"); // Check proto info @@ -104,8 +103,7 @@ public final class BatteryTipsControllerTest { verify(mBatteryTipsCardPreference).setTitle("Reduce screen timeout to extend battery life"); verify(mBatteryTipsCardPreference).setIconResourceId(R.drawable.ic_battery_tips_lightbulb); - verify(mBatteryTipsCardPreference) - .setMainButtonStrokeColorResourceId(R.color.color_accent_selector); + verify(mBatteryTipsCardPreference).setButtonColorResourceId(R.color.color_accent_selector); verify(mBatteryTipsCardPreference).setMainButtonLabel("View Settings"); verify(mBatteryTipsCardPreference).setDismissButtonLabel("Got it"); verify(mBatteryTipsCardPreference).setVisible(true); @@ -134,8 +132,7 @@ public final class BatteryTipsControllerTest { verify(mBatteryTipsCardPreference).setTitle(testTitle); verify(mBatteryTipsCardPreference).setIconResourceId(R.drawable.ic_battery_tips_lightbulb); - verify(mBatteryTipsCardPreference) - .setMainButtonStrokeColorResourceId(R.color.color_accent_selector); + verify(mBatteryTipsCardPreference).setButtonColorResourceId(R.color.color_accent_selector); verify(mBatteryTipsCardPreference).setMainButtonLabel("View Settings"); verify(mBatteryTipsCardPreference).setDismissButtonLabel("Got it"); verify(mBatteryTipsCardPreference).setVisible(true); @@ -159,7 +156,7 @@ public final class BatteryTipsControllerTest { verify(mBatteryTipsCardPreference) .setIconResourceId(R.drawable.ic_battery_tips_warning_icon); verify(mBatteryTipsCardPreference) - .setMainButtonStrokeColorResourceId(R.color.color_battery_anomaly_yellow_selector); + .setButtonColorResourceId(R.color.color_battery_anomaly_app_warning_selector); verify(mBatteryTipsCardPreference).setMainButtonLabel("Check"); verify(mBatteryTipsCardPreference).setDismissButtonLabel("Got it"); verify(mBatteryTipsCardPreference).setVisible(true);