am 896b9c62: Merge "Show charging speed when time to full is available" into mnc-dr-dev
* commit '896b9c6261641e285bc37c4d22a589b01ce11ffe': Show charging speed when time to full is available
This commit is contained in:
23
packages/SystemUI/res/values-en/donottranslate.xml
Normal file
23
packages/SystemUI/res/values-en/donottranslate.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2015 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- DO NOT TRANSLATE - temporary hack to show the speed-less label if no translation is available -->
|
||||
<item type="string" name="keyguard_indication_charging_time_fast_if_translated">@string/keyguard_indication_charging_time_fast</item>
|
||||
<!-- DO NOT TRANSLATE - temporary hack to show the speed-less label if no translation is available -->
|
||||
<item type="string" name="keyguard_indication_charging_time_slowly_if_translated">@string/keyguard_indication_charging_time_slowly</item>
|
||||
</resources>
|
||||
@@ -20,4 +20,10 @@
|
||||
<!-- Date format for display: should match the lockscreen in /policy. -->
|
||||
<string name="system_ui_date_pattern">@*android:string/system_ui_date_pattern</string>
|
||||
|
||||
<!-- DO NOT TRANSLATE - temporary hack to show the speed-less label if no translation is available -->
|
||||
<item type="string" name="keyguard_indication_charging_time_fast_if_translated">@string/keyguard_indication_charging_time</item>
|
||||
|
||||
<!-- DO NOT TRANSLATE - temporary hack to show the speed-less label if no translation is available -->
|
||||
<item type="string" name="keyguard_indication_charging_time_slowly_if_translated">@string/keyguard_indication_charging_time</item>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -793,6 +793,12 @@
|
||||
<!-- Indication on the keyguard that is shown when the device is charging. [CHAR LIMIT=40]-->
|
||||
<string name="keyguard_indication_charging_time">Charging (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>
|
||||
|
||||
<!-- Indication on the keyguard that is shown when the device is charging rapidly. Should match keyguard_plugged_in_charging_fast [CHAR LIMIT=40]-->
|
||||
<string name="keyguard_indication_charging_time_fast">Charging rapidly (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>
|
||||
|
||||
<!-- Indication on the keyguard that is shown when the device is charging slowly. Should match keyguard_plugged_in_charging_slowly [CHAR LIMIT=40]-->
|
||||
<string name="keyguard_indication_charging_time_slowly">Charging slowly (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>
|
||||
|
||||
<!-- Related to user switcher --><skip/>
|
||||
|
||||
<!-- Accessibility label for the button that opens the user switcher. -->
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user