Merge "Add the string "No time remaining" when remaining time <= 0." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
895f785470
@@ -8785,15 +8785,15 @@
|
|||||||
<!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=30] -->
|
<!-- 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>
|
<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] -->
|
<!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
|
||||||
<plurals name="billing_cycle_days_left">
|
<plurals name="billing_cycle_days_left">
|
||||||
<item quantity="one">%d day left</item>
|
<item quantity="one">%d day left</item>
|
||||||
<item quantity="other">%d days left</item>
|
<item quantity="other">%d days left</item>
|
||||||
</plurals>
|
</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] -->
|
<!-- 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>
|
<string name="billing_cycle_less_than_one_day_left">Less than 1 day left</string>
|
||||||
|
|
||||||
|
@@ -199,18 +199,18 @@ public class DataUsageSummaryPreference extends Preference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateCycleTimeText(PreferenceViewHolder holder) {
|
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);
|
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().getString(R.string.billing_cycle_less_than_one_day_left)
|
||||||
: getContext().getResources().getQuantityString(
|
: getContext().getResources().getQuantityString(
|
||||||
R.plurals.billing_cycle_days_left, (int) daysLeft, (int) daysLeft));
|
R.plurals.billing_cycle_days_left, daysLeft, daysLeft));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -179,7 +179,7 @@ public class DataUsageSummaryPreferenceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetUsageInfo_cycleRemainingTimeNegativeDaysLeft_shouldDisplayZeroDays() {
|
public void testSetUsageInfo_cycleRemainingTimeNegativeDaysLeft_shouldDisplayNoneLeft() {
|
||||||
final long cycleEnd = System.currentTimeMillis() - 1L;
|
final long cycleEnd = System.currentTimeMillis() - 1L;
|
||||||
mSummaryPreference.setUsageInfo(cycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
|
mSummaryPreference.setUsageInfo(cycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
|
||||||
new Intent());
|
new Intent());
|
||||||
@@ -187,7 +187,7 @@ public class DataUsageSummaryPreferenceTest {
|
|||||||
bindViewHolder();
|
bindViewHolder();
|
||||||
assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
assertThat(mCycleTime.getText()).isEqualTo(
|
assertThat(mCycleTime.getText()).isEqualTo(
|
||||||
mContext.getResources().getQuantityString(R.plurals.billing_cycle_days_left, 0, 0));
|
mContext.getString(R.string.billing_cycle_none_left));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user