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

Commit 895f7854 authored by Andreas Terzis's avatar Andreas Terzis Committed by Android (Google) Code Review
Browse files

Merge "Add the string "No time remaining" when remaining time <= 0." into pi-dev

parents b0f25159 c7faabf4
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -8785,15 +8785,15 @@
    <!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=30] -->
    <string name="data_remaining"><xliff:g name="bytes" example="2 GB">^1</xliff:g> left</string>
    <!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
    <string name="cycle_left_multiple_days"><xliff:g name="time" example="2d">%d</xliff:g> days left</string>
    <!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
    <plurals name="billing_cycle_days_left">
        <item quantity="one">%d day left</item>
        <item quantity="other">%d days left</item>
    </plurals>
    <!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
    <string name="billing_cycle_none_left">No time remaining</string>
    <!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
    <string name="billing_cycle_less_than_one_day_left">Less than 1 day left</string>
+11 −11
Original line number Diff line number Diff line
@@ -199,18 +199,18 @@ public class DataUsageSummaryPreference extends Preference {
    }

    private void updateCycleTimeText(PreferenceViewHolder holder) {
        float daysLeft =
                ((float) mCycleEndTimeMs - System.currentTimeMillis()) / MILLIS_IN_A_DAY;
        if (daysLeft < 0) {
            daysLeft = 0;
        }

        TextView cycleTime = (TextView) holder.findViewById(R.id.cycle_left_time);
        cycleTime.setText(
                (daysLeft > 0 && daysLeft < 1)

        long millisLeft = mCycleEndTimeMs - System.currentTimeMillis();
        if (millisLeft <= 0) {
            cycleTime.setText(getContext().getString(R.string.billing_cycle_none_left));
        } else {
            int daysLeft = (int)(millisLeft / MILLIS_IN_A_DAY);
            cycleTime.setText(daysLeft < 1
                            ? getContext().getString(R.string.billing_cycle_less_than_one_day_left)
                            : getContext().getResources().getQuantityString(
                        R.plurals.billing_cycle_days_left, (int) daysLeft, (int) daysLeft));
                            R.plurals.billing_cycle_days_left, daysLeft, daysLeft));
        }
    }


+2 −2
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public class DataUsageSummaryPreferenceTest {
    }

    @Test
    public void testSetUsageInfo_cycleRemainingTimeNegativeDaysLeft_shouldDisplayZeroDays() {
    public void testSetUsageInfo_cycleRemainingTimeNegativeDaysLeft_shouldDisplayNoneLeft() {
        final long cycleEnd = System.currentTimeMillis() - 1L;
        mSummaryPreference.setUsageInfo(cycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
                new Intent());
@@ -187,7 +187,7 @@ public class DataUsageSummaryPreferenceTest {
        bindViewHolder();
        assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
        assertThat(mCycleTime.getText()).isEqualTo(
                mContext.getResources().getQuantityString(R.plurals.billing_cycle_days_left, 0, 0));
                mContext.getString(R.string.billing_cycle_none_left));
    }

    @Test