From e8400c2fb78e80979b5190d4abc9685442cdfc25 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Wed, 15 Jul 2015 13:04:59 -0400 Subject: [PATCH] Change move storage from dropdown pref to dialog Use a horizontal pref and a single button that triggers the dialog Bug: 21922660 Change-Id: Ifb4de75ca9269d2e8163eec5602932260adec0d9 --- res/values/strings.xml | 6 ++ res/xml/app_storage_settings.xml | 14 ++++- .../applications/AppStorageSettings.java | 61 ++++++++++++------- 3 files changed, 57 insertions(+), 24 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 02d92ecaae4..5c57f83bc46 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6460,6 +6460,12 @@ Storage used + + Change + + + Change storage + Notifications diff --git a/res/xml/app_storage_settings.xml b/res/xml/app_storage_settings.xml index 7c5c25ce8b6..093d7812b66 100644 --- a/res/xml/app_storage_settings.xml +++ b/res/xml/app_storage_settings.xml @@ -17,11 +17,19 @@ - + + + android:selectable="false" + android:layout="@layout/horizontal_preference" /> + + 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); } }