diff options
Diffstat (limited to 'src/com/android/settings/fuelgauge')
-rw-r--r-- | src/com/android/settings/fuelgauge/PowerUsageDetail.java | 18 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/PowerUsageSummary.java | 7 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/Utils.java | 17 |
3 files changed, 15 insertions, 27 deletions
diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java index 4f98163..8ecc659 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java +++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java @@ -16,6 +16,8 @@ package com.android.settings.fuelgauge; +import static com.android.settings.Utils.prepareCustomPreferencesList; + import android.app.Activity; import android.app.ActivityManager; import android.app.ApplicationErrorReport; @@ -34,10 +36,10 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.Process; -import android.os.UserHandle; import android.preference.PreferenceActivity; import android.provider.Settings; import android.text.TextUtils; +import android.text.format.Formatter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -141,8 +143,12 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = mRootView = inflater.inflate(R.layout.power_usage_details, null); + public View onCreateView( + LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View view = inflater.inflate(R.layout.power_usage_details, container, false); + prepareCustomPreferencesList(container, view, view, false); + + mRootView = view; createDetails(); return view; } @@ -310,10 +316,12 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener switch (mTypes[i]) { case R.string.usage_type_data_recv: case R.string.usage_type_data_send: - value = Utils.formatBytes(getActivity(), mValues[i]); + final long bytes = (long) (mValues[i]); + value = Formatter.formatFileSize(getActivity(), bytes); break; case R.string.usage_type_no_coverage: - value = String.format("%d%%", (int) Math.floor(mValues[i])); + final int percentage = (int) Math.floor(mValues[i]); + value = getActivity().getString(R.string.percentage, percentage); break; case R.string.usage_type_gps: mUsesGps = true; diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index 4a79d9d..0a6e2ab 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -52,6 +52,7 @@ import android.view.MenuItem; import com.android.internal.app.IBatteryStats; import com.android.internal.os.BatteryStatsImpl; import com.android.internal.os.PowerProfile; +import com.android.settings.HelpUtils; import com.android.settings.R; import com.android.settings.fuelgauge.PowerUsageDetail.DrainType; import com.android.settings.users.UserUtils; @@ -339,11 +340,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable { String helpUrl; if (!TextUtils.isEmpty(helpUrl = getResources().getString(R.string.help_url_battery))) { final MenuItem help = menu.add(0, MENU_HELP, 0, R.string.help_label); - Intent helpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(helpUrl)); - helpIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - help.setIntent(helpIntent); - help.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + HelpUtils.prepareHelpMenuItem(getActivity(), help, helpUrl); } } diff --git a/src/com/android/settings/fuelgauge/Utils.java b/src/com/android/settings/fuelgauge/Utils.java index 2ffc9de..5c99a86 100644 --- a/src/com/android/settings/fuelgauge/Utils.java +++ b/src/com/android/settings/fuelgauge/Utils.java @@ -64,21 +64,4 @@ public class Utils { } return sb.toString(); } - - /** - * Formats data size in KB, MB, from the given bytes. - * @param context the application context - * @param bytes data size in bytes - * @return the formatted size such as 4.52 MB or 245 KB or 332 bytes - */ - public static String formatBytes(Context context, double bytes) { - // TODO: I18N - if (bytes > 1000 * 1000) { - return String.format("%.2f MB", ((int) (bytes / 1000)) / 1000f); - } else if (bytes > 1024) { - return String.format("%.2f KB", ((int) (bytes / 10)) / 100f); - } else { - return String.format("%d bytes", (int) bytes); - } - } } |