diff options
author | jackqdyulei <jackqdyulei@google.com> | 2017-05-01 13:03:49 -0700 |
---|---|---|
committer | jackqdyulei <jackqdyulei@google.com> | 2017-05-03 16:01:55 -0700 |
commit | 4cb19e74b392ce9fc114ce1645699a04049954bc (patch) | |
tree | f477905b446e75039eb29a17aa8fd221952112ac /src/com/android/settings/fuelgauge/PowerGaugePreference.java | |
parent | b45a9fe0a9aead81c41d6f50effa2c1a8b239609 (diff) | |
download | packages_apps_Settings-4cb19e74b392ce9fc114ce1645699a04049954bc.tar.gz packages_apps_Settings-4cb19e74b392ce9fc114ce1645699a04049954bc.tar.bz2 packages_apps_Settings-4cb19e74b392ce9fc114ce1645699a04049954bc.zip |
Add anomaly icon for PowerGaugePreference
When the app contains anomaly, we should show anomaly icon(triangle
alert).
This cl also extracts a new method refreshAppListGroup from refreshUi.
New method is used to only refresh appListGroup. Reason for this action:
1. Improve performance(partial refresh)
2. We init AnomalyLoader in refreshUi, invoke refreshUi in
onLoadFinish will create infinite loop.
Bug: 36924669
Test: RunSettingsRoboTests
Change-Id: If54c89349e21763ca714123ac6ae884bd0f6a377
Diffstat (limited to 'src/com/android/settings/fuelgauge/PowerGaugePreference.java')
-rw-r--r-- | src/com/android/settings/fuelgauge/PowerGaugePreference.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/com/android/settings/fuelgauge/PowerGaugePreference.java b/src/com/android/settings/fuelgauge/PowerGaugePreference.java index b124c8150b..2c12f717b6 100644 --- a/src/com/android/settings/fuelgauge/PowerGaugePreference.java +++ b/src/com/android/settings/fuelgauge/PowerGaugePreference.java @@ -21,6 +21,7 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.support.v7.preference.PreferenceViewHolder; import android.util.AttributeSet; +import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -41,6 +42,7 @@ public class PowerGaugePreference extends TintablePreference { private BatteryEntry mInfo; private CharSequence mContentDescription; private CharSequence mProgress; + private boolean mShowAnomalyIcon; public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription, BatteryEntry info) { @@ -63,6 +65,7 @@ public class PowerGaugePreference extends TintablePreference { mInfo = info; mContentDescription = contentDescription; mIconSize = context.getResources().getDimensionPixelSize(R.dimen.app_icon_size); + mShowAnomalyIcon = false; } public void setContentDescription(String name) { @@ -88,6 +91,11 @@ public class PowerGaugePreference extends TintablePreference { return mProgress; } + public void shouldShowAnomalyIcon(boolean showAnomalyIcon) { + mShowAnomalyIcon = showAnomalyIcon; + notifyChanged(); + } + BatteryEntry getInfo() { return mInfo; } @@ -98,6 +106,12 @@ public class PowerGaugePreference extends TintablePreference { ImageView icon = (ImageView) view.findViewById(android.R.id.icon); icon.setLayoutParams(new LinearLayout.LayoutParams(mIconSize, mIconSize)); + final TextView subtitle = (TextView) view.findViewById(R.id.widget_summary); + subtitle.setText(mProgress); + if (mShowAnomalyIcon) { + subtitle.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_warning_24dp, 0, + 0, 0); + } ((TextView) view.findViewById(R.id.widget_summary)).setText(mProgress); if (mContentDescription != null) { final TextView titleView = (TextView) view.findViewById(android.R.id.title); |