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

@@ -34,6 +34,7 @@ public class SummaryPreference extends Preference {
private int mLeft, mMiddle, mRight;
private boolean mColorsSet = false;
private boolean mChartEnabled = true;
private float mLeftRatio, mMiddleRatio, mRightRatio;
private String mStartLabel;
private String mEndLabel;
@@ -43,6 +44,13 @@ public class SummaryPreference extends Preference {
setLayoutResource(R.layout.settings_summary_preference);
}
public void setChartEnabled(boolean enabled) {
if (mChartEnabled != enabled) {
mChartEnabled = enabled;
notifyChanged();
}
}
public void setAmount(String amount) {
mAmount = amount;
if (mAmount != null && mUnits != null) {
@@ -85,12 +93,18 @@ public class SummaryPreference extends Preference {
super.onBindViewHolder(holder);
LinearColorBar colorBar = (LinearColorBar) holder.itemView.findViewById(R.id.color_bar);
colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio);
if (mColorsSet) {
colorBar.setColors(mLeft, mMiddle, mRight);
if (mChartEnabled) {
colorBar.setVisibility(View.VISIBLE);
colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio);
if (mColorsSet) {
colorBar.setColors(mLeft, mMiddle, mRight);
}
} else {
colorBar.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel)) {
if (mChartEnabled && (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel))) {
holder.findViewById(R.id.label_bar).setVisibility(View.VISIBLE);
((TextView) holder.findViewById(android.R.id.text1)).setText(mStartLabel);
((TextView) holder.findViewById(android.R.id.text2)).setText(mEndLabel);