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

Commit 0066b7b8 authored by Adrian Roos's avatar Adrian Roos Committed by Android Git Automerger
Browse files

am 7e9f6fbf: am 47a497cf: am 1a6f9216: am 896b9c62: Merge "Show charging speed...

am 7e9f6fbf: am 47a497cf: am 1a6f9216: am 896b9c62: Merge "Show charging speed when time to full is available" into mnc-dr-dev

* commit '7e9f6fbf':
  Show charging speed when time to full is available
parents 30c767af 7e9f6fbf
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line 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 Original line Diff line number Diff line
@@ -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>
+6 −0
Original line number Original line Diff line number Diff line
@@ -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. -->
+21 −12
Original line number Original line Diff line number Diff line
@@ -187,33 +187,42 @@ 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;
        }
        }

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


    KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() {
    KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() {
        @Override
        @Override