diff --git a/res/drawable/data_usage_progress.xml b/res/drawable/data_usage_progress.xml
new file mode 100644
index 00000000000..46b9a128b7b
--- /dev/null
+++ b/res/drawable/data_usage_progress.xml
@@ -0,0 +1,45 @@
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml
index c1a676a1722..c2e1581d9e7 100644
--- a/res/layout/data_usage_summary_preference.xml
+++ b/res/layout/data_usage_summary_preference.xml
@@ -45,10 +45,12 @@
android:textColor="?android:attr/colorAccent"
android:textAppearance="@android:style/TextAppearance.Material.Large" />
-
+ android:layout_height="10dp"
+ android:progressDrawable="@drawable/data_usage_progress"/>
1 ? View.VISIBLE : View.GONE);
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 11da829ad61..0729fff1517 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -194,8 +194,7 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
summaryPreference.setChartEnabled(true);
summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
Formatter.formatFileSize(mContext, mDataplanSize));
- summaryPreference.setRatios(mDataplanUse / (float) mDataplanSize, 0 /* middle */,
- (mDataplanSize - mDataplanUse) / (float) mDataplanSize);
+ summaryPreference.setProgress(mDataplanUse / (float) mDataplanSize);
}
summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
mDataplanCount, mManageSubscriptionIntent);
diff --git a/src/com/android/settings/widget/LinearColorBar.java b/src/com/android/settings/widget/LinearColorBar.java
index b3e685efc75..df1403e792d 100644
--- a/src/com/android/settings/widget/LinearColorBar.java
+++ b/src/com/android/settings/widget/LinearColorBar.java
@@ -26,6 +26,9 @@ import android.widget.LinearLayout;
import com.android.settings.Utils;
+/**
+ * @Deprecated Use {@link android.widget.ProgressBar} instead.
+ */
public class LinearColorBar extends LinearLayout {
static final int RIGHT_COLOR = 0xffced7db;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
index ecd556db3f4..57f1f8c6f66 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -24,6 +24,8 @@ import android.support.v7.preference.PreferenceViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.settings.R;
@@ -54,6 +56,10 @@ public class DataUsageSummaryPreferenceTest {
private TextView mCarrierInfo;
private TextView mDataLimits;
private Button mLaunchButton;
+ private LinearLayout mLabelBar;
+ private TextView mLabel1;
+ private TextView mLabel2;
+ private ProgressBar mProgressBar;
private long mCycleEnd;
private long mUpdateTime;
@@ -159,6 +165,46 @@ public class DataUsageSummaryPreferenceTest {
assertThat(mDataLimits.getVisibility()).isEqualTo(View.GONE);
}
+ @Test
+ public void testSetChartEnabledFalse_hidesLabelBar() {
+ setValidLabels();
+ mSummaryPreference.setChartEnabled(false);
+
+ bindViewHolder();
+ assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void testSetEmptyLabels_hidesLabelBar() {
+ mSummaryPreference.setLabels("", "");
+
+ bindViewHolder();
+ assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void testLabelBar_isVisible_whenLabelsSet() {
+ setValidLabels();
+ //mChartEnabled defaults to true
+
+ bindViewHolder();
+ assertThat(mLabelBar.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+
+ @Test
+ public void testSetProgress_updatesProgressBar() {
+ setValidLabels();
+ mSummaryPreference.setProgress(.5f);
+
+ bindViewHolder();
+ assertThat(mProgressBar.getProgress()).isEqualTo(50);
+ }
+
+ private void setValidLabels() {
+ mSummaryPreference.setLabels("0.0 GB", "5.0 GB");
+ }
+
private void bindViewHolder() {
mSummaryPreference.onBindViewHolder(mHolder);
mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
@@ -166,5 +212,9 @@ public class DataUsageSummaryPreferenceTest {
mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
mDataLimits = (TextView) mHolder.findViewById(R.id.data_limits);
mLaunchButton = (Button) mHolder.findViewById(R.id.launch_mdp_app_button);
+ mLabelBar = (LinearLayout) mHolder.findViewById(R.id.label_bar);
+ mLabel1 = (TextView) mHolder.findViewById(R.id.text1);
+ mLabel2 = (TextView) mHolder.findViewById(R.id.text2);
+ mProgressBar = (ProgressBar) mHolder.findViewById(R.id.determinateBar);
}
}
\ No newline at end of file