Add ability to disable data warning.

- Add a preference to disable data warning.
- Disable data usage chart in summary page when data warning is turned
  off.

Bug: 26934313
Test: Manually turned on/off data warning and inspected UI.
Test: ag/1440361

Change-Id: I6d5b86b8502647781c52cf940f276e1969251b59
This commit is contained in:
Fan Zhang
2016-09-12 15:00:53 -07:00
parent c88805713d
commit 7bd19b8891
4 changed files with 64 additions and 14 deletions

View File

@@ -246,16 +246,24 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs
formatTitle(context, getString(mDataUsageTemplate), info.usageLevel));
long limit = mDataInfoController.getSummaryLimit(info);
mSummaryPreference.setSummary(info.period);
mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0),
Formatter.formatFileSize(context, limit));
mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0,
(limit - info.usageLevel) / (float) limit);
if (limit <= 0) {
mSummaryPreference.setChartEnabled(false);
} else {
mSummaryPreference.setChartEnabled(true);
mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0),
Formatter.formatFileSize(context, limit));
mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0,
(limit - info.usageLevel) / (float) limit);
}
}
if (mLimitPreference != null) {
if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) {
String warning = Formatter.formatFileSize(context, info.warningLevel);
String limit = Formatter.formatFileSize(context, info.limitLevel);
mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only
: R.string.cell_warning_and_limit, warning, limit));
} else if (mLimitPreference != null) {
mLimitPreference.setSummary(null);
}
PreferenceScreen screen = getPreferenceScreen();