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
This commit is contained in:
mxyyiyi
2023-11-08 16:52:48 +08:00
parent 7350779738
commit 1817f066ec
14 changed files with 394 additions and 440 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);
}