diff options
author | Amith Yamasani <yamasani@google.com> | 2011-07-22 10:34:58 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2011-07-25 14:09:57 -0700 |
commit | a4379d6b38e568fcb60831d6f2fa349ba20f9b82 (patch) | |
tree | c864ae3fb36b7da46c80e8a2639dc63c2352aace /src/com/android/settings/Utils.java | |
parent | 8374a2db64f772c5e934ccd2e47f0df4b5928012 (diff) | |
download | packages_apps_settings-a4379d6b38e568fcb60831d6f2fa349ba20f9b82.zip packages_apps_settings-a4379d6b38e568fcb60831d6f2fa349ba20f9b82.tar.gz packages_apps_settings-a4379d6b38e568fcb60831d6f2fa349ba20f9b82.tar.bz2 |
Use a different wallpaper fragment title from the preference item.
Change wallpaper list ordering to alphabetic.
Display battery level and charging status in Battery settings.
Change-Id: I8ead0fb0f018c79ed258bd1c1ca3f8ecaf32da83
Diffstat (limited to 'src/com/android/settings/Utils.java')
-rw-r--r-- | src/com/android/settings/Utils.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 422ae90..b725d56 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -27,6 +27,7 @@ import android.content.res.Resources.NotFoundException; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; import android.net.LinkProperties; +import android.os.BatteryManager; import android.os.Bundle; import android.os.SystemProperties; import android.preference.Preference; @@ -330,4 +331,38 @@ public class Utils { return new Locale(brokenDownLocale[0], brokenDownLocale[1], brokenDownLocale[2]); } } + + public static String getBatteryPercentage(Intent batteryChangedIntent) { + int level = batteryChangedIntent.getIntExtra("level", 0); + int scale = batteryChangedIntent.getIntExtra("scale", 100); + return String.valueOf(level * 100 / scale) + "%"; + } + + public static String getBatteryStatus(Resources res, Intent batteryChangedIntent) { + final Intent intent = batteryChangedIntent; + + int plugType = intent.getIntExtra("plugged", 0); + int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN); + String statusString; + if (status == BatteryManager.BATTERY_STATUS_CHARGING) { + statusString = res.getString(R.string.battery_info_status_charging); + if (plugType > 0) { + statusString = statusString + + " " + + res.getString((plugType == BatteryManager.BATTERY_PLUGGED_AC) + ? R.string.battery_info_status_charging_ac + : R.string.battery_info_status_charging_usb); + } + } else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) { + statusString = res.getString(R.string.battery_info_status_discharging); + } else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING) { + statusString = res.getString(R.string.battery_info_status_not_charging); + } else if (status == BatteryManager.BATTERY_STATUS_FULL) { + statusString = res.getString(R.string.battery_info_status_full); + } else { + statusString = res.getString(R.string.battery_info_status_unknown); + } + + return statusString; + } } |