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

Commit 2b66ff61 authored by Zaiyue Xue's avatar Zaiyue Xue
Browse files

Remove the comma between hour and minutes in app list.

Bug: 267184192
Fix: 267184192
Test: presubmit
Change-Id: Ic37046218ffe501600d5d247a10d3f091acf131b
parent 1d45f7f6
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -639,6 +639,13 @@ public class BatteryUtils {
        return DockDefenderMode.DISABLED;
    }

    /** Formats elapsed time without commas in between.  */
    public static CharSequence formatElapsedTimeWithoutComma(
            Context context, double millis, boolean withSeconds, boolean collapseTimeUnit) {
        return StringUtil.formatElapsedTime(context, millis, withSeconds, collapseTimeUnit)
                .toString().replaceAll(",", "");
    }

    /** Builds the battery usage time summary. */
    public static String buildBatteryUsageTimeSummary(final Context context, final boolean isSystem,
            final long foregroundUsageTimeInMs, final long backgroundUsageTimeInMs,
@@ -675,7 +682,7 @@ public class BatteryUtils {
        if (timeInMs < DateUtils.MINUTE_IN_MILLIS) {
            return context.getString(lessThanOneMinuteResId);
        }
        final CharSequence timeSequence = StringUtil.formatElapsedTime(
        final CharSequence timeSequence = formatElapsedTimeWithoutComma(
                context, (double) timeInMs, /*withSeconds=*/ false, /*collapseTimeUnit=*/ false);
        return context.getString(normalResId, timeSequence);
    }
+3 −7
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.utils.StringUtil;
import com.android.settings.fuelgauge.BatteryUtils;

import java.util.Locale;
import java.util.regex.Matcher;
@@ -89,10 +89,10 @@ public class ScreenOnTimeController extends BasePreferenceController {
    @VisibleForTesting
    void showScreenOnTimeText(Long screenOnTime) {
        final CharSequence timeSequence =
                StringUtil.formatElapsedTime(mPrefContext, (double) screenOnTime,
                BatteryUtils.formatElapsedTimeWithoutComma(mPrefContext, (double) screenOnTime,
                        /*withSeconds=*/ false, /*collapseTimeUnit=*/ false);
        mScreenOnTimeTextPreference.setText(
                enlargeFontOfNumberIfNeeded(mPrefContext, removeCommas(timeSequence)));
                enlargeFontOfNumberIfNeeded(mPrefContext, timeSequence));
        mScreenOnTimeTextPreference.setVisible(true);
    }

@@ -115,8 +115,4 @@ public class ScreenOnTimeController extends BasePreferenceController {
        }
        return spannableText;
    }

    private static CharSequence removeCommas(CharSequence text) {
        return text.toString().replaceAll(",", "");
    }
}