summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml6
-rw-r--r--res/xml/app_storage_settings.xml14
-rw-r--r--src/com/android/settings/applications/AppStorageSettings.java61
3 files changed, 57 insertions, 24 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 02d92ec..5c57f83 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6460,6 +6460,12 @@
<!-- Title of storage preference to control where app is stored -->
<string name="storage_used">Storage used</string>
+ <!-- Title of button to change storage [CHAR LIMIT=25] -->
+ <string name="change">Change</string>
+
+ <!-- Title of dialog to change storage [CHAR LIMIT=25] -->
+ <string name="change_storage">Change storage</string>
+
<!-- Label for notification settings for an specific app [CHAR LIMIT=40] -->
<string name="notifications_label">Notifications</string>
<!-- App notification summary with notifications enabled [CHAR LIMIT=40] -->
diff --git a/res/xml/app_storage_settings.xml b/res/xml/app_storage_settings.xml
index 7c5c25c..093d781 100644
--- a/res/xml/app_storage_settings.xml
+++ b/res/xml/app_storage_settings.xml
@@ -17,11 +17,19 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/application_info_label">
- <com.android.settings.DropDownPreference
- android:key="app_location_setting"
+ <com.android.settings.applications.SpacePreference
+ android:layout_height="8dp" />
+
+ <Preference
+ android:key="storage_used"
android:title="@string/storage_used"
android:summary="@string/storage_type_internal"
- android:selectable="true" />
+ android:selectable="false"
+ android:layout="@layout/horizontal_preference" />
+
+ <com.android.settings.applications.LayoutPreference
+ android:key="change_storage_button"
+ android:layout="@layout/single_button_panel" />
<PreferenceCategory
android:key="storage_category"
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index 739aa3c..38440cb 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -38,7 +38,6 @@ import android.view.View.OnClickListener;
import android.widget.Button;
import com.android.internal.logging.MetricsLogger;
-import com.android.settings.DropDownPreference;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.deviceinfo.StorageWizardMoveConfirm;
@@ -51,7 +50,7 @@ import java.util.List;
import java.util.Objects;
public class AppStorageSettings extends AppInfoWithHeader
- implements OnClickListener, Callbacks, DropDownPreference.Callback {
+ implements OnClickListener, Callbacks, DialogInterface.OnClickListener {
private static final String TAG = AppStorageSettings.class.getSimpleName();
//internal constants used in Handler
@@ -70,7 +69,8 @@ public class AppStorageSettings extends AppInfoWithHeader
private static final int DLG_CLEAR_DATA = DLG_BASE + 1;
private static final int DLG_CANNOT_CLEAR_DATA = DLG_BASE + 2;
- private static final String KEY_MOVE_PREFERENCE = "app_location_setting";
+ private static final String KEY_STORAGE_USED = "storage_used";
+ private static final String KEY_CHANGE_STORAGE = "change_storage_button";
private static final String KEY_STORAGE_CATEGORY = "storage_category";
private static final String KEY_TOTAL_SIZE = "total_size";
@@ -94,7 +94,8 @@ public class AppStorageSettings extends AppInfoWithHeader
private Button mClearDataButton;
private Button mClearCacheButton;
- private DropDownPreference mMoveDropDown;
+ private Preference mStorageUsed;
+ private Button mChangeStorageButton;
private boolean mCanClearData = true;
private boolean mHaveSizes = false;
@@ -113,6 +114,9 @@ public class AppStorageSettings extends AppInfoWithHeader
private CharSequence mInvalidSizeStr;
private CharSequence mComputingStr;
+ private VolumeInfo[] mCandidates;
+ private AlertDialog.Builder mDialogBuilder;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -146,8 +150,11 @@ public class AppStorageSettings extends AppInfoWithHeader
mClearDataButton = (Button) ((LayoutPreference) findPreference(KEY_CLEAR_DATA))
.findViewById(R.id.button);
- mMoveDropDown = (DropDownPreference) findPreference(KEY_MOVE_PREFERENCE);
- mMoveDropDown.setCallback(this);
+ mStorageUsed = findPreference(KEY_STORAGE_USED);
+ mChangeStorageButton = (Button) ((LayoutPreference) findPreference(KEY_CHANGE_STORAGE))
+ .findViewById(R.id.button);
+ mChangeStorageButton.setText(R.string.change);
+ mChangeStorageButton.setOnClickListener(this);
// Cache section
mCacheSize = findPreference(KEY_CACHE_SIZE);
@@ -164,7 +171,7 @@ public class AppStorageSettings extends AppInfoWithHeader
mClearCacheObserver = new ClearCacheObserver();
}
mPm.deleteApplicationCacheFiles(mPackageName, mClearCacheObserver);
- } else if(v == mClearDataButton) {
+ } else if (v == mClearDataButton) {
if (mAppEntry.info.manageSpaceActivityName != null) {
if (!Utils.isMonkeyRunning()) {
Intent intent = new Intent(Intent.ACTION_DEFAULT);
@@ -175,15 +182,17 @@ public class AppStorageSettings extends AppInfoWithHeader
} else {
showDialogInner(DLG_CLEAR_DATA, 0);
}
+ } else if (v == mChangeStorageButton) {
+ mDialogBuilder.show();
}
}
@Override
- public boolean onItemSelected(int pos, Object value) {
+ public void onClick(DialogInterface dialog, int which) {
final Context context = getActivity();
// If not current volume, kick off move wizard
- final VolumeInfo targetVol = (VolumeInfo) value;
+ final VolumeInfo targetVol = mCandidates[which];
final VolumeInfo currentVol = context.getPackageManager().getPackageCurrentVolume(
mAppEntry.info);
if (!Objects.equals(targetVol, currentVol)) {
@@ -192,8 +201,7 @@ public class AppStorageSettings extends AppInfoWithHeader
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mAppEntry.info.packageName);
startActivity(intent);
}
-
- return true;
+ dialog.dismiss();
}
private String getSizeStr(long size) {
@@ -273,18 +281,20 @@ public class AppStorageSettings extends AppInfoWithHeader
@Override
protected boolean refreshUi() {
retrieveAppEntry();
- refreshButtons();
refreshSizeInfo();
final VolumeInfo currentVol = getActivity().getPackageManager()
.getPackageCurrentVolume(mAppEntry.info);
- mMoveDropDown.setSelectedValue(currentVol);
+ final StorageManager storage = getContext().getSystemService(StorageManager.class);
+ mStorageUsed.setSummary(storage.getBestVolumeDescription(currentVol));
+
+ refreshButtons();
return true;
}
private void refreshButtons() {
- initMoveDropDown();
+ initMoveDialog();
initDataButtons();
}
@@ -314,7 +324,7 @@ public class AppStorageSettings extends AppInfoWithHeader
}
}
- private void initMoveDropDown() {
+ private void initMoveDialog() {
final Context context = getActivity();
final StorageManager storage = context.getSystemService(StorageManager.class);
@@ -323,14 +333,23 @@ public class AppStorageSettings extends AppInfoWithHeader
if (candidates.size() > 1) {
Collections.sort(candidates, VolumeInfo.getDescriptionComparator());
- mMoveDropDown.clearItems();
- for (VolumeInfo vol : candidates) {
- final String volDescrip = storage.getBestVolumeDescription(vol);
- mMoveDropDown.addItem(volDescrip, vol);
+ CharSequence[] labels = new CharSequence[candidates.size()];
+ int current = -1;
+ for (int i = 0; i < candidates.size(); i++) {
+ final String volDescrip = storage.getBestVolumeDescription(candidates.get(i));
+ if (Objects.equals(volDescrip, mStorageUsed.getSummary())) {
+ current = i;
+ }
+ labels[i] = volDescrip;
}
- mMoveDropDown.setSelectable(!mAppControlRestricted);
+ mCandidates = candidates.toArray(new VolumeInfo[candidates.size()]);
+ mDialogBuilder = new AlertDialog.Builder(getContext())
+ .setTitle(R.string.change_storage)
+ .setSingleChoiceItems(labels, current, this)
+ .setNegativeButton(R.string.cancel, null);
} else {
- removePreference(KEY_MOVE_PREFERENCE);
+ removePreference(KEY_STORAGE_USED);
+ removePreference(KEY_CHANGE_STORAGE);
}
}