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

Commit aa76bd5e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Go back to original string for <1 day case"

parents f66f3ae9 4d8a2a41
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -937,7 +937,7 @@
    <string name="power_remaining_duration_only_enhanced">About <xliff:g id="time_remaining">%1$s</xliff:g> left based on your usage</string>
    <!-- [CHAR_LIMIT=60] Label for battery level chart when discharging with duration and using enhanced estimate -->
    <string name="power_discharging_duration_enhanced">About <xliff:g id="time_remaining">%1$s</xliff:g> left based on your usage (<xliff:g id="level">%2$s</xliff:g>)</string>
    <!-- [CHAR_LIMIT=40] Short label for estimated remaining duration of battery charging/discharging -->
    <!-- [CHAR_LIMIT=20] Short label for estimated remaining duration of battery charging/discharging -->
    <string name="power_remaining_duration_only_short"><xliff:g id="time_remaining">%1$s</xliff:g></string>

    <!-- [CHAR_LIMIT=100] Label for enhanced estimated time that phone will run out of battery -->
@@ -948,7 +948,7 @@
    <string name="power_discharge_by">Should last until about <xliff:g id="time">%1$s</xliff:g> (<xliff:g id="level">%2$s</xliff:g>)</string>
    <!-- [CHAR_LIMIT=100] Label for estimated time that phone will run out of battery -->
    <string name="power_discharge_by_only">Should last until about <xliff:g id="time">%1$s</xliff:g></string>
    <!-- [CHAR_LIMIT=100] Label for estimated time that phone will run out of battery -->
    <!-- [CHAR_LIMIT=20] Label for estimated time that phone will run out of battery -->
    <string name="power_discharge_by_only_short">Until <xliff:g id="time" example="12 PM">%1$s</xliff:g></string>
    <!-- [CHAR_LIMIT=100] Extend the battery life past a certain time -->
    <string name="power_suggestion_extend_battery">Extend battery life past <xliff:g id="time" example="12 PM">%1$s</xliff:g></string>
+12 −5
Original line number Diff line number Diff line
@@ -223,12 +223,19 @@ public class PowerUtil {
    }

    private static String getRegularTimeRemainingShortString(Context context, long drainTimeMs) {
        // Get the time remaining rounded to the nearest 15 min
        final long roundedTimeMs = roundTimeToNearestThreshold(drainTimeMs, FIFTEEN_MINUTES_MILLIS);
        CharSequence timeString = StringUtil.formatElapsedTime(context, roundedTimeMs,
                false /* withSeconds */);
        // Get the time of day we think device will die rounded to the nearest 15 min.
        final long roundedTimeOfDayMs =
                roundTimeToNearestThreshold(
                        System.currentTimeMillis() + drainTimeMs,
                        FIFTEEN_MINUTES_MILLIS);

        // convert the time to a properly formatted string.
        String skeleton = android.text.format.DateFormat.getTimeFormatString(context);
        DateFormat fmt = DateFormat.getInstanceForSkeleton(skeleton);
        Date date = Date.from(Instant.ofEpochMilli(roundedTimeOfDayMs));
        CharSequence timeString = fmt.format(date);

        return context.getString(R.string.power_remaining_duration_only_short, timeString);
        return context.getString(R.string.power_discharge_by_only_short, timeString);
    }

    public static long convertUsToMs(long timeUs) {