diff options
author | Adrian Roos <roosa@google.com> | 2015-09-23 17:03:47 -0700 |
---|---|---|
committer | Adrian Roos <roosa@google.com> | 2015-09-25 15:22:32 -0700 |
commit | 7e39e59f37cce1f0ad803b20d36bfaed3c6f7e5f (patch) | |
tree | f4239e4e300a26d1f0b56696f9503978c06d20e4 /packages/SystemUI/src | |
parent | 6a15d528c0a4501389008ef945dec38b5ca6919a (diff) | |
download | frameworks_base-7e39e59f37cce1f0ad803b20d36bfaed3c6f7e5f.zip frameworks_base-7e39e59f37cce1f0ad803b20d36bfaed3c6f7e5f.tar.gz frameworks_base-7e39e59f37cce1f0ad803b20d36bfaed3c6f7e5f.tar.bz2 |
Show charging speed when time to full is available
Only shows if translation is available, follow-up
I3e883eeca002e86d4df30c2b238e18bd63bbddea to show in
all locales.
Bug: 24167496
Change-Id: I667cde69e5d5f8aec8ac9fd105bbfb7e118ced64
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 54f91da..50d274d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -187,32 +187,41 @@ public class KeyguardIndicationController { } // Try fetching charging time from battery stats. + long chargingTimeRemaining = 0; try { - long chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining(); - if (chargingTimeRemaining > 0) { - String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes( - mContext, chargingTimeRemaining); - return mContext.getResources().getString( - R.string.keyguard_indication_charging_time, chargingTimeFormatted); - } + chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining(); + } catch (RemoteException e) { Log.e(TAG, "Error calling IBatteryStats: ", e); } + final boolean hasChargingTime = chargingTimeRemaining > 0; - // Fall back to simple charging label. int chargingId; switch (mChargingSpeed) { case KeyguardUpdateMonitor.BatteryStatus.CHARGING_FAST: - chargingId = R.string.keyguard_plugged_in_charging_fast; + chargingId = hasChargingTime + ? R.string.keyguard_indication_charging_time_fast_if_translated + : R.string.keyguard_plugged_in_charging_fast; break; case KeyguardUpdateMonitor.BatteryStatus.CHARGING_SLOWLY: - chargingId = R.string.keyguard_plugged_in_charging_slowly; + chargingId = hasChargingTime + ? R.string.keyguard_indication_charging_time_slowly_if_translated + : R.string.keyguard_plugged_in_charging_slowly; break; default: - chargingId = R.string.keyguard_plugged_in; + chargingId = hasChargingTime + ? R.string.keyguard_indication_charging_time + : R.string.keyguard_plugged_in; break; } - return mContext.getResources().getString(chargingId); + + if (hasChargingTime) { + String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes( + mContext, chargingTimeRemaining); + return mContext.getResources().getString(chargingId, chargingTimeFormatted); + } else { + return mContext.getResources().getString(chargingId); + } } KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() { |