summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/fuelgauge/PowerGaugePreference.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-09-02 16:10:24 -0700
committerJeff Sharkey <jsharkey@android.com>2011-09-02 16:15:25 -0700
commit28130d96385d7d7b17992b45fb5d124836d85880 (patch)
treef05e9eb5842250ac07a2153d843476272c4c6148 /src/com/android/settings/fuelgauge/PowerGaugePreference.java
parent4e658ba969830e8c9617dc8938271df1ed09aa44 (diff)
downloadpackages_apps_Settings-28130d96385d7d7b17992b45fb5d124836d85880.zip
packages_apps_Settings-28130d96385d7d7b17992b45fb5d124836d85880.tar.gz
packages_apps_Settings-28130d96385d7d7b17992b45fb5d124836d85880.tar.bz2
Unify data/power layout, confirm disable, round.
Share consistent layout between data usage and battery usage. Show confirmation dialog before disabling mobile data. Round warning/limit sweep values to match displayed label. Suppress fade when switching data usage tabs. Bug: 5208510, 5058157, 5038589, 5252816 Change-Id: I3c76f3397445d2d3b173666a41672871df4c61af
Diffstat (limited to 'src/com/android/settings/fuelgauge/PowerGaugePreference.java')
-rw-r--r--src/com/android/settings/fuelgauge/PowerGaugePreference.java56
1 files changed, 16 insertions, 40 deletions
diff --git a/src/com/android/settings/fuelgauge/PowerGaugePreference.java b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
index 00e397e..7b11ae1 100644
--- a/src/com/android/settings/fuelgauge/PowerGaugePreference.java
+++ b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
@@ -20,70 +20,46 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
import android.view.View;
-import android.widget.ImageView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.settings.R;
/**
- * Custom preference for displaying power consumption as a bar and an icon on the left for the
- * subsystem/app type.
- *
+ * Custom preference for displaying power consumption as a bar and an icon on
+ * the left for the subsystem/app type.
*/
public class PowerGaugePreference extends Preference {
-
- private Drawable mIcon;
- private PercentageBar mGauge;
- private double mValue;
private BatterySipper mInfo;
- private double mPercent;
+ private int mProgress;
+ private CharSequence mProgressText;
public PowerGaugePreference(Context context, Drawable icon, BatterySipper info) {
super(context);
- setLayoutResource(R.layout.preference_powergauge);
- mIcon = icon;
- mGauge = new PercentageBar();
- mGauge.bar = context.getResources().getDrawable(R.drawable.app_gauge);
+ setLayoutResource(R.layout.app_percentage_item);
+ setIcon(icon);
mInfo = info;
}
- /**
- * Sets the width of the gauge in percentage (0 - 100)
- * @param percent
- */
- void setGaugeValue(double percent) {
- mValue = percent;
- mGauge.percent = mValue;
- }
-
- void setPercent(double percent) {
- mPercent = percent;
+ public void setPercent(double percentOfMax, double percentOfTotal) {
+ mProgress = (int) Math.ceil(percentOfMax);
+ mProgressText = getContext().getResources().getString(
+ R.string.percentage, (int) Math.ceil(percentOfTotal));
+ notifyChanged();
}
BatterySipper getInfo() {
return mInfo;
}
- void setPowerIcon(Drawable icon) {
- mIcon = icon;
- notifyChanged();
- }
-
@Override
protected void onBindView(View view) {
super.onBindView(view);
- ImageView appIcon = (ImageView) view.findViewById(R.id.appIcon);
- if (mIcon == null) {
- mIcon = getContext().getResources().getDrawable(android.R.drawable.sym_def_app_icon);
- }
- appIcon.setImageDrawable(mIcon);
+ final ProgressBar progress = (ProgressBar) view.findViewById(android.R.id.progress);
+ progress.setProgress(mProgress);
- ImageView appGauge = (ImageView) view.findViewById(R.id.appGauge);
- appGauge.setImageDrawable(mGauge);
-
- TextView percentView = (TextView) view.findViewById(R.id.percent);
- percentView.setText((int) (Math.ceil(mPercent)) + "%");
+ final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
+ text1.setText(mProgressText);
}
-
}