Merge "Show charging speed when time to full is available" into mnc-dr-dev
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. -->
|
<!-- Date format for display: should match the lockscreen in /policy. -->
|
||||||
<string name="system_ui_date_pattern">@*android:string/system_ui_date_pattern</string>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -793,6 +793,12 @@
|
|||||||
<!-- Indication on the keyguard that is shown when the device is charging. [CHAR LIMIT=40]-->
|
<!-- 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>
|
<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/>
|
<!-- Related to user switcher --><skip/>
|
||||||
|
|
||||||
<!-- Accessibility label for the button that opens the user switcher. -->
|
<!-- Accessibility label for the button that opens the user switcher. -->
|
||||||
|
|||||||
@@ -187,32 +187,41 @@ public class KeyguardIndicationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try fetching charging time from battery stats.
|
// Try fetching charging time from battery stats.
|
||||||
|
long chargingTimeRemaining = 0;
|
||||||
try {
|
try {
|
||||||
long chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining();
|
chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining();
|
||||||
if (chargingTimeRemaining > 0) {
|
|
||||||
String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes(
|
|
||||||
mContext, chargingTimeRemaining);
|
|
||||||
return mContext.getResources().getString(
|
|
||||||
R.string.keyguard_indication_charging_time, chargingTimeFormatted);
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Error calling IBatteryStats: ", e);
|
Log.e(TAG, "Error calling IBatteryStats: ", e);
|
||||||
}
|
}
|
||||||
|
final boolean hasChargingTime = chargingTimeRemaining > 0;
|
||||||
|
|
||||||
// Fall back to simple charging label.
|
|
||||||
int chargingId;
|
int chargingId;
|
||||||
switch (mChargingSpeed) {
|
switch (mChargingSpeed) {
|
||||||
case KeyguardUpdateMonitor.BatteryStatus.CHARGING_FAST:
|
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;
|
break;
|
||||||
case KeyguardUpdateMonitor.BatteryStatus.CHARGING_SLOWLY:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
chargingId = R.string.keyguard_plugged_in;
|
chargingId = hasChargingTime
|
||||||
|
? R.string.keyguard_indication_charging_time
|
||||||
|
: R.string.keyguard_plugged_in;
|
||||||
break;
|
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() {
|
KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() {
|
||||||
|
|||||||
Reference in New Issue
Block a user