Merge "Use 'setup' header illust before selecting storage type."
diff --git a/res/layout/storage_item.xml b/res/layout/storage_item.xml
new file mode 100644
index 0000000..2da5494
--- /dev/null
+++ b/res/layout/storage_item.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:gravity="center_vertical"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingTop="16dip"
+ android:paddingBottom="16dip"
+ android:background="?android:attr/selectableItemBackground">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+android:id/title"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAlignment="viewStart"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAlignment="viewStart"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorSecondaryNoDisable"
+ android:maxLines="10" />
+
+ </LinearLayout>
+
+ <ProgressBar
+ android:id="@android:id/progress"
+ android:layout_width="match_parent"
+ android:layout_height="8dp"
+ android:layout_marginTop="16dp"
+ android:layout_marginBottom="8dp"
+ android:visibility="gone"
+ android:max="100"
+ style="?android:attr/progressBarStyleHorizontal" />
+
+</LinearLayout>
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index 0c65528..6a98efd 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -430,7 +430,7 @@
}
private void updatePreference(StorageItemPreference pref, long size) {
- pref.setSummary(Formatter.formatFileSize(getActivity(), size));
+ pref.setStorageSize(size, mVolume.getPath().getTotalSpace());
}
/**
diff --git a/src/com/android/settings/deviceinfo/StorageItemPreference.java b/src/com/android/settings/deviceinfo/StorageItemPreference.java
index 41d84c6..a5eacc4 100644
--- a/src/com/android/settings/deviceinfo/StorageItemPreference.java
+++ b/src/com/android/settings/deviceinfo/StorageItemPreference.java
@@ -19,14 +19,22 @@
import android.content.Context;
import android.os.UserHandle;
import android.preference.Preference;
+import android.text.format.Formatter;
+import android.view.View;
+import android.widget.ProgressBar;
import com.android.settings.R;
public class StorageItemPreference extends Preference {
public final int userHandle;
+ private ProgressBar progressBar;
+ private static final int PROGRESS_MAX = 100;
+ private int progress = -1;
+
public StorageItemPreference(Context context, int titleRes) {
this(context, context.getText(titleRes), UserHandle.USER_NULL);
+ setLayoutResource(R.layout.storage_item);
}
public StorageItemPreference(Context context, CharSequence title, int userHandle) {
@@ -41,4 +49,31 @@
public void setLoading() {
setSummary(R.string.memory_calculating_size);
}
+
+ public void setStorageSize(long size, long total) {
+ setSummary(Formatter.formatFileSize(getContext(), size));
+ progress = (int)(size * PROGRESS_MAX / total);
+ updateProgressBar();
+ }
+
+ protected void updateProgressBar() {
+ if (progressBar == null)
+ return;
+
+ if (progress == -1) {
+ progressBar.setVisibility(View.GONE);
+ return;
+ }
+
+ progressBar.setVisibility(View.VISIBLE);
+ progressBar.setMax(PROGRESS_MAX);
+ progressBar.setProgress(progress);
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
+ updateProgressBar();
+ super.onBindView(view);
+ }
}