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

Commit 50f314e4 authored by Wesley.CW Wang's avatar Wesley.CW Wang Committed by Wesley Wang
Browse files

Update StringUtil#formatElapsedTime method (2/3)

 - Update the usage and the test case
 - Update discharging string to follow new string doc

Bug: 183689347
Test: make RunSettingsRoboTests
Change-Id: I1e14e7da8cb02755d8cf6e12626a0d94fad87121
parent acacad4c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -364,7 +364,12 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
            final TextView textView = linearLayout.findViewById(R.id.bt_battery_prediction);
            if (estimateReady == 1) {
                textView.setVisibility(View.VISIBLE);
                textView.setText(StringUtil.formatElapsedTime(mContext, batteryEstimate, false));
                textView.setText(
                        StringUtil.formatElapsedTime(
                                mContext,
                                batteryEstimate,
                                /* withSeconds */ false,
                                /* collapseTimeUnit */  false));
            } else {
                textView.setVisibility(View.GONE);
            }
+4 −1
Original line number Diff line number Diff line
@@ -318,7 +318,10 @@ public class DataUsageSummaryPreference extends Preference {
                    textResourceId = R.string.no_carrier_update_text;
                }
                updateTime = StringUtil.formatElapsedTime(
                        getContext(), updateAgeMillis, false /* withSeconds */);
                        getContext(),
                        updateAgeMillis,
                        false /* withSeconds */,
                        false /* collapseTimeUnit */);
            }
            carrierInfo.setText(TextUtils.expandTemplate(
                    getContext().getText(textResourceId),
+10 −2
Original line number Diff line number Diff line
@@ -229,10 +229,18 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
        final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
        mForegroundPreference.setSummary(
                TextUtils.expandTemplate(getText(R.string.battery_used_for),
                        StringUtil.formatElapsedTime(context, foregroundTimeMs, false)));
                        StringUtil.formatElapsedTime(
                                context,
                                foregroundTimeMs,
                                /* withSeconds */ false,
                                /* collapseTimeUnit */ false)));
        mBackgroundPreference.setSummary(
                TextUtils.expandTemplate(getText(R.string.battery_active_for),
                        StringUtil.formatElapsedTime(context, backgroundTimeMs, false)));
                        StringUtil.formatElapsedTime(
                                context,
                                backgroundTimeMs,
                                /* withSeconds */ false,
                                /* collapseTimeUnit */ false)));
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
        final long usageTimeMs = entry.getTimeInForegroundMs();
        if (shouldShowSummary(entry) && usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
            final CharSequence timeSequence =
                    StringUtil.formatElapsedTime(mContext, usageTimeMs, false);
                    StringUtil.formatElapsedTime(mContext, usageTimeMs, false, false);
            preference.setSummary(
                    entry.isHidden()
                            ? timeSequence
+6 −3
Original line number Diff line number Diff line
@@ -263,8 +263,11 @@ public class BatteryInfo {
                context.getString(chargingLimitedResId, info.batteryPercentString);
        } else if (chargeTimeMs > 0 && status != BatteryManager.BATTERY_STATUS_FULL) {
            info.remainingTimeUs = PowerUtil.convertMsToUs(chargeTimeMs);
            CharSequence timeString = StringUtil.formatElapsedTime(context,
                    PowerUtil.convertUsToMs(info.remainingTimeUs), false /* withSeconds */);
            final CharSequence timeString = StringUtil.formatElapsedTime(
                    context,
                    PowerUtil.convertUsToMs(info.remainingTimeUs),
                    false /* withSeconds */,
                    true /* collapseTimeUnit */);
            int resId = R.string.power_charging_duration;
            info.remainingLabel = context.getString(
                    R.string.power_remaining_charging_duration_only, timeString);
@@ -287,7 +290,7 @@ public class BatteryInfo {
                    context,
                    PowerUtil.convertUsToMs(drainTimeUs),
                    null /* percentageString */,
                    estimate.isBasedOnUsage() && !shortString
                    false /* basedOnUsage */
            );
            info.chargeLabel = PowerUtil.getBatteryRemainingStringFormatted(
                    context,
Loading