Remove LinearColorBar and replace uses with ProgressBar.
We never actually needed it, since progress bar can do
everything we want it to. Renamed data_usage_progress to
color_bar_progress to reflect its more generic state.
Updated color_bar_progress to use proper values.
Since we can't seem to use private attrs in settings,
use the dimen/color values that are customizable.
Updated usages to use regular ProgressBar APIs.
Fixes: 74111937
Test: visual inspection and robotests
Change-Id: I4f0c59e6cf5c629e3cc3901800d9c4afc95fa495
diff --git a/src/com/android/settings/SummaryPreference.java b/src/com/android/settings/SummaryPreference.java
index 23965ee..dbe036a 100644
--- a/src/com/android/settings/SummaryPreference.java
+++ b/src/com/android/settings/SummaryPreference.java
@@ -20,10 +20,9 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.ProgressBar;
import android.widget.TextView;
-import com.android.settings.widget.LinearColorBar;
-
/**
* Provides a summary of a setting page in a preference. Such as memory or data usage.
*/
@@ -33,8 +32,6 @@
private String mAmount;
private String mUnits;
- private int mLeft, mMiddle, mRight;
- private boolean mColorsSet = false;
private boolean mChartEnabled = true;
private float mLeftRatio, mMiddleRatio, mRightRatio;
private String mStartLabel;
@@ -81,26 +78,17 @@
notifyChanged();
}
- public void setColors(int left, int middle, int right) {
- mLeft = left;
- mMiddle = middle;
- mRight = right;
- mColorsSet = true;
- notifyChanged();
- }
-
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- final LinearColorBar colorBar = holder.itemView.findViewById(R.id.color_bar);
+ final ProgressBar colorBar = holder.itemView.findViewById(R.id.color_bar);
if (mChartEnabled) {
colorBar.setVisibility(View.VISIBLE);
- colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio);
- if (mColorsSet) {
- colorBar.setColors(mLeft, mMiddle, mRight);
- }
+ int progress = (int) (mLeftRatio * 100);
+ colorBar.setProgress(progress);
+ colorBar.setSecondaryProgress(progress + (int) (mMiddleRatio * 100));
} else {
colorBar.setVisibility(View.GONE);
}