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

Commit 8f9f25c5 authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge "Add TtsSpan for formatted time." into oc-dev

parents bcaabec9 f4c1cef3
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -4474,10 +4474,10 @@
    <!-- Title for the cellular network in power use UI(i.e. Mobile network scanning: 30% of battery usage) [CHAR_LIMIT=40] -->
    <string name="device_cellular_network">Mobile network scanning</string>
    <!-- Label for time since last full charge in power use UI, i.e. "7 h 20 min ago" [CHAR_LIMIT=60] -->
    <string name="power_last_full_charge_summary"><xliff:g id="time">%1$s</xliff:g> ago</string>
    <!-- Label for list of apps using battery in power use UI [CHAR_LIMIT=120] -->
    <string name="power_usage_list_summary">App usage since full charge (<xliff:g id="time">%1$s</xliff:g> ago)</string>
    <!-- Label for time since last full charge in power use UI, i.e. "7 h 20 min ago". Note: ^1 should be used in all translations [CHAR_LIMIT=60] -->
    <string name="power_last_full_charge_summary"><xliff:g id="time">^1</xliff:g> ago</string>
    <!-- Label for list of apps using battery in power use UI. Note: ^1 should be used in all translations[CHAR_LIMIT=120] -->
    <string name="power_usage_list_summary">App usage since full charge (<xliff:g id="time">^1</xliff:g> ago)</string>
    <!-- Description for the screen usage item [CHAR_LIMIT=120] -->
    <string name="screen_usage_summary">Amount of time screen has been on since full charge</string>
    <!-- Label for list of different types using battery in power use UI [CHAR_LIMIT=60] -->
@@ -4676,8 +4676,8 @@
    <!-- Representation of a mAh value. [CHAR LIMIT=NONE] -->
    <string name="mah"><xliff:g id="number" example="30">%d</xliff:g> mAh</string>
    <!-- Description for battery usage time for an app, i.e. Used for 30min. [CHAR LIMIT=60] -->
    <string name="battery_used_for">Used for %1$s</string>
    <!-- Description for battery usage time for an app, i.e. Used for 30min. Note: ^1 should be used in all translations [CHAR LIMIT=60] -->
    <string name="battery_used_for">Used for <xliff:g id="time">^1</xliff:g></string>
    <!-- Description for battery usage info for an app, i.e. 60% used by facebook. [CHAR LIMIT=60] -->
    <string name="battery_used_by"><xliff:g id="percent">%1$s</xliff:g> used by <xliff:g id="app">%2$s</xliff:g></string>
    <!-- Description for percentage of battery usage for an app, i.e. Screen: 30% of overall battery. [CHAR LIMIT=60] -->
+13 −3
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ import android.support.v7.preference.PreferenceScreen;
import android.telephony.TelephonyManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.TtsSpan;
@@ -770,8 +772,9 @@ public final class Utils extends com.android.settingslib.Utils {
     * @param withSeconds include seconds?
     * @return the formatted elapsed time
     */
    public static String formatElapsedTime(Context context, double millis, boolean withSeconds) {
        StringBuilder sb = new StringBuilder();
    public static CharSequence formatElapsedTime(Context context, double millis,
            boolean withSeconds) {
        SpannableStringBuilder sb = new SpannableStringBuilder();
        int seconds = (int) Math.floor(millis / 1000);
        if (!withSeconds) {
            // Round up.
@@ -812,9 +815,15 @@ public final class Utils extends com.android.settingslib.Utils {
                        hours, minutes));
            } else {
                sb.append(context.getString(R.string.battery_history_minutes_no_seconds, minutes));

                // Add ttsSpan if it only have minute value, because it will be read as "meters"
                TtsSpan ttsSpan = new TtsSpan.MeasureBuilder().setNumber(minutes)
                        .setUnit("minute").build();
                sb.setSpan(ttsSpan, 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        return sb.toString();

        return sb;
    }

    /**
@@ -1256,4 +1265,5 @@ public final class Utils extends com.android.settingslib.Utils {
        return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
                && volume.isMountedReadable();
    }

}
+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.view.View;

import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -82,6 +83,8 @@ public class AdvancedPowerUsageDetail extends PowerUsageBase implements
    ApplicationsState mState;
    @VisibleForTesting
    ApplicationsState.AppEntry mAppEntry;
    @VisibleForTesting
    BatteryUtils mBatteryUtils;

    private Preference mForegroundPreference;
    private Preference mBackgroundPreference;
@@ -137,6 +140,7 @@ public class AdvancedPowerUsageDetail extends PowerUsageBase implements
                (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE));
        mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
        mPackageManager = activity.getPackageManager();
        mBatteryUtils = BatteryUtils.getInstance(getContext());
    }

    @Override
+3 −3
Original line number Diff line number Diff line
@@ -15,14 +15,13 @@
 */
package com.android.settings.fuelgauge;

import android.annotation.IntDef;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.BatteryStats;
import android.os.SystemClock;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.text.format.DateUtils;
import android.util.Log;

import com.android.internal.os.BatterySipper;
@@ -64,7 +63,8 @@ public class BatteryUtils {
        return sInstance;
    }

    private BatteryUtils(Context context) {
    @VisibleForTesting
    BatteryUtils(Context context) {
        mPackageManager = context.getPackageManager();
        mPowerUsageFeatureProvider = FeatureFactory.getFactory(
                context).getPowerUsageFeatureProvider(context);
+5 −1
Original line number Diff line number Diff line
@@ -79,11 +79,15 @@ public class PowerGaugePreference extends TintablePreference {
        return mProgress.toString();
    }

    public void setSubtitle(String subtitle) {
    public void setSubtitle(CharSequence subtitle) {
        mProgress = subtitle;
        notifyChanged();
    }

    public CharSequence getSubtitle() {
        return mProgress;
    }

    BatteryEntry getInfo() {
        return mInfo;
    }
Loading