Merge "Update Power Anomaly UI." into main
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user