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
diff --git a/src/com/android/settings/SummaryPreference.java b/src/com/android/settings/SummaryPreference.java
index 38449b1..d129661 100644
--- a/src/com/android/settings/SummaryPreference.java
+++ b/src/com/android/settings/SummaryPreference.java
@@ -34,6 +34,7 @@
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 @@
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 @@
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);