Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 896b9c62 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Show charging speed when time to full is available" into mnc-dr-dev

parents 31fe464d 7e39e59f
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
<?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>
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -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>
+6 −0
Original line number Diff line number Diff line
@@ -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. -->
+21 −12
Original line number Diff line number Diff line
@@ -187,33 +187,42 @@ 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;
        }

        if (hasChargingTime) {
            String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes(
                    mContext, chargingTimeRemaining);
            return mContext.getResources().getString(chargingId, chargingTimeFormatted);
        } else {
            return mContext.getResources().getString(chargingId);
        }
    }

    KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() {
        @Override