diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-07-05 22:09:07 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-07-05 22:10:13 -0700 |
commit | 48751c1a5163ccf411009344f352abdf6e1b9684 (patch) | |
tree | a84bcf390159d676481051d4e0c1b8fe166f6f61 | |
parent | 6a0082b483eb487c44dec5e8855cf0e1ab92020b (diff) | |
download | packages_apps_Settings-48751c1a5163ccf411009344f352abdf6e1b9684.tar.gz packages_apps_Settings-48751c1a5163ccf411009344f352abdf6e1b9684.tar.bz2 packages_apps_Settings-48751c1a5163ccf411009344f352abdf6e1b9684.zip |
Fix some ordering, colors, and accessibility bugs.
When adding preferences to public/private details screens, always
add in-order when rebuilding. Hacky fix for broken summary text and
eject image color tints.
Fix crash when device rotated during partitioning. Set correct
accessibility titles in all wizard steps.
Bug: 22098044, 21376962
Change-Id: I68aff96cba497a91919cad8865722bc9cef7eaa7
8 files changed, 91 insertions, 51 deletions
diff --git a/res/layout/preference_storage_action.xml b/res/layout/preference_storage_action.xml index 5a378713a..19d776324 100644 --- a/res/layout/preference_storage_action.xml +++ b/res/layout/preference_storage_action.xml @@ -30,7 +30,6 @@ android:layout_gravity="center" android:gravity="center" android:src="@drawable/ic_eject_24dp" - android:tint="?android:attr/textColorSecondary" android:background="?android:attr/selectableItemBackground" /> </LinearLayout> diff --git a/res/layout/storage_summary.xml b/res/layout/storage_summary.xml index 96a0ceedc..35201e165 100644 --- a/res/layout/storage_summary.xml +++ b/res/layout/storage_summary.xml @@ -44,7 +44,6 @@ android:layout_height="wrap_content" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Body1" - android:textColor="?android:attr/textColorSecondaryNoDisable" android:maxLines="10" /> <ProgressBar diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java index 0c65528bf..f3e40e883 100644 --- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java +++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java @@ -96,8 +96,6 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { private UserInfo mCurrentUser; - private int mNextOrder = 0; - private StorageSummaryPreference mSummary; private StorageItemPreference mApps; private StorageItemPreference mImages; @@ -140,6 +138,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { } addPreferencesFromResource(R.xml.device_info_storage_volume); + getPreferenceScreen().setOrderingAsAdded(true); // Find the emulated shared storage layered above this private volume mSharedVolume = mStorageManager.findEmulatedForPrivate(mVolume); @@ -183,29 +182,29 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { screen.removeAll(); - screen.addPreference(mSummary); + addPreference(mSummary); final boolean showUsers = !mUsers.isEmpty(); final boolean showShared = (mSharedVolume != null) && mSharedVolume.isMountedReadable(); if (showUsers) { - screen.addPreference(new PreferenceHeader(context, mCurrentUser.name)); + addPreference(new PreferenceHeader(context, mCurrentUser.name)); } - screen.addPreference(mApps); + addPreference(mApps); if (showShared) { - screen.addPreference(mImages); - screen.addPreference(mVideos); - screen.addPreference(mAudio); - screen.addPreference(mOther); + addPreference(mImages); + addPreference(mVideos); + addPreference(mAudio); + addPreference(mOther); } - screen.addPreference(mCache); + addPreference(mCache); if (showShared) { - screen.addPreference(mExplore); + addPreference(mExplore); } if (showUsers) { - screen.addPreference(new PreferenceHeader(context, R.string.storage_other_users)); + addPreference(new PreferenceHeader(context, R.string.storage_other_users)); for (Preference pref : mUsers) { - screen.addPreference(pref); + addPreference(pref); } } @@ -231,16 +230,18 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { mMeasure.forceMeasure(); } + private void addPreference(Preference pref) { + pref.setOrder(Preference.DEFAULT_ORDER); + getPreferenceScreen().addPreference(pref); + } + private StorageItemPreference buildItem(int titleRes) { - final StorageItemPreference pref = new StorageItemPreference(getActivity(), titleRes); - pref.setOrder(mNextOrder++); - return pref; + return new StorageItemPreference(getActivity(), titleRes); } private Preference buildAction(int titleRes) { final Preference pref = new Preference(getActivity()); pref.setTitle(titleRes); - pref.setOrder(mNextOrder++); return pref; } diff --git a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java index 9caf92ca5..4c77d217b 100644 --- a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java +++ b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java @@ -56,8 +56,6 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { private VolumeInfo mVolume; private DiskInfo mDisk; - private int mNextOrder = 0; - private StorageSummaryPreference mSummary; private Preference mMount; @@ -108,6 +106,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { mVolumeId = mVolume.getId(); addPreferencesFromResource(R.xml.device_info_storage_volume); + getPreferenceScreen().setOrderingAsAdded(true); mSummary = new StorageSummaryPreference(context); @@ -133,7 +132,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { screen.removeAll(); if (mVolume.isMountedReadable()) { - screen.addPreference(mSummary); + addPreference(mSummary); final File file = mVolume.getPath(); final long totalBytes = file.getTotalSpace(); @@ -149,21 +148,25 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { } if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) { - screen.addPreference(mMount); + addPreference(mMount); } if (mVolume.isMountedReadable()) { - screen.addPreference(mUnmount); + addPreference(mUnmount); } - screen.addPreference(mFormatPublic); + addPreference(mFormatPublic); if (mDisk.isAdoptable() && mIsPermittedToAdopt) { - screen.addPreference(mFormatPrivate); + addPreference(mFormatPrivate); } } + private void addPreference(Preference pref) { + pref.setOrder(Preference.DEFAULT_ORDER); + getPreferenceScreen().addPreference(pref); + } + private Preference buildAction(int titleRes) { final Preference pref = new Preference(getActivity()); pref.setTitle(titleRes); - pref.setOrder(mNextOrder++); return pref; } diff --git a/src/com/android/settings/deviceinfo/StorageSummaryPreference.java b/src/com/android/settings/deviceinfo/StorageSummaryPreference.java index 4a1d1b2ca..2641cb618 100644 --- a/src/com/android/settings/deviceinfo/StorageSummaryPreference.java +++ b/src/com/android/settings/deviceinfo/StorageSummaryPreference.java @@ -17,9 +17,11 @@ package com.android.settings.deviceinfo; import android.content.Context; +import android.graphics.Color; import android.preference.Preference; import android.view.View; import android.widget.ProgressBar; +import android.widget.TextView; import com.android.settings.R; @@ -47,6 +49,9 @@ public class StorageSummaryPreference extends Preference { progress.setVisibility(View.GONE); } + final TextView summary = (TextView) view.findViewById(android.R.id.summary); + summary.setTextColor(Color.parseColor("#8a000000")); + super.onBindView(view); } } diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreference.java b/src/com/android/settings/deviceinfo/StorageVolumePreference.java index bc7972a46..3511b91d1 100644 --- a/src/com/android/settings/deviceinfo/StorageVolumePreference.java +++ b/src/com/android/settings/deviceinfo/StorageVolumePreference.java @@ -28,7 +28,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; import android.widget.ProgressBar; -import android.widget.TextView; import com.android.settings.R; import com.android.settings.deviceinfo.StorageSettings.UnmountTask; @@ -101,6 +100,7 @@ public class StorageVolumePreference extends Preference { protected void onBindView(View view) { final ImageView unmount = (ImageView) view.findViewById(R.id.unmount); if (unmount != null) { + unmount.setImageTintList(ColorStateList.valueOf(Color.parseColor("#8a000000"))); unmount.setOnClickListener(mUnmountListener); } diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java index beb0f3d17..e508cd1c4 100644 --- a/src/com/android/settings/deviceinfo/StorageWizardBase.java +++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java @@ -150,7 +150,9 @@ public abstract class StorageWizardBase extends Activity { } protected void setHeaderText(int resId, String... args) { - getSetupWizardLayout().setHeaderText(TextUtils.expandTemplate(getText(resId), args)); + final CharSequence headerText = TextUtils.expandTemplate(getText(resId), args); + getSetupWizardLayout().setHeaderText(headerText); + setTitle(headerText); } protected void setBodyText(int resId, String... args) { diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java index e117c2640..8a03f83d1 100644 --- a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java +++ b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java @@ -27,6 +27,7 @@ import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.os.storage.DiskInfo; +import android.os.storage.StorageManager; import android.os.storage.VolumeInfo; import android.text.TextUtils; import android.util.Log; @@ -40,6 +41,8 @@ public class StorageWizardFormatProgress extends StorageWizardBase { private boolean mFormatPrivate; + private PartitionTask mTask; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -56,32 +59,48 @@ public class StorageWizardFormatProgress extends StorageWizardBase { setHeaderText(R.string.storage_wizard_format_progress_title, mDisk.getDescription()); setBodyText(R.string.storage_wizard_format_progress_body, mDisk.getDescription()); - setCurrentProgress(20); - getNextButton().setVisibility(View.GONE); - new PartitionTask().execute(); + mTask = (PartitionTask) getLastNonConfigurationInstance(); + if (mTask == null) { + mTask = new PartitionTask(); + mTask.setActivity(this); + mTask.execute(); + } else { + mTask.setActivity(this); + } + } + + @Override + public Object onRetainNonConfigurationInstance() { + return mTask; } - public class PartitionTask extends AsyncTask<Void, Integer, Exception> { + public static class PartitionTask extends AsyncTask<Void, Integer, Exception> { + public StorageWizardFormatProgress mActivity; + + private volatile int mProgress = 20; + private volatile long mInternalBench; private volatile long mPrivateBench; @Override protected Exception doInBackground(Void... params) { + final StorageWizardFormatProgress activity = mActivity; + final StorageManager storage = mActivity.mStorage; try { - if (mFormatPrivate) { - mStorage.partitionPrivate(mDisk.getId()); + if (activity.mFormatPrivate) { + storage.partitionPrivate(activity.mDisk.getId()); publishProgress(40); - mInternalBench = mStorage.benchmark(null); + mInternalBench = storage.benchmark(null); publishProgress(60); - final VolumeInfo privateVol = findFirstVolume(VolumeInfo.TYPE_PRIVATE); - mPrivateBench = mStorage.benchmark(privateVol.id); + final VolumeInfo privateVol = activity.findFirstVolume(VolumeInfo.TYPE_PRIVATE); + mPrivateBench = storage.benchmark(privateVol.id); } else { - mStorage.partitionPublic(mDisk.getId()); + storage.partitionPublic(activity.mDisk.getId()); } return null; } catch (Exception e) { @@ -91,16 +110,22 @@ public class StorageWizardFormatProgress extends StorageWizardBase { @Override protected void onProgressUpdate(Integer... progress) { - setCurrentProgress(progress[0]); + mProgress = progress[0]; + mActivity.setCurrentProgress(mProgress); + } + + public void setActivity(StorageWizardFormatProgress activity) { + mActivity = activity; + mActivity.setCurrentProgress(mProgress); } @Override protected void onPostExecute(Exception e) { - final Context context = StorageWizardFormatProgress.this; + final StorageWizardFormatProgress activity = mActivity; if (e != null) { Log.e(TAG, "Failed to partition", e); - Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); - finishAffinity(); + Toast.makeText(activity, e.getMessage(), Toast.LENGTH_LONG).show(); + activity.finishAffinity(); return; } @@ -110,22 +135,24 @@ public class StorageWizardFormatProgress extends StorageWizardBase { // TODO: refine this warning threshold if (mPrivateBench > 2000000000) { final SlowWarningFragment dialog = new SlowWarningFragment(); - dialog.show(getFragmentManager(), TAG_SLOW_WARNING); + dialog.show(activity.getFragmentManager(), TAG_SLOW_WARNING); } else { - onFormatFinished(); + activity.onFormatFinished(); } } } - public class SlowWarningFragment extends DialogFragment { + public static class SlowWarningFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); - final String descrip = mDisk.getDescription(); - final String genericDescip = getGenericDescription(mDisk); + final StorageWizardFormatProgress target = + (StorageWizardFormatProgress) getActivity(); + final String descrip = target.getDiskDescription(); + final String genericDescip = target.getGenericDiskDescription(); builder.setMessage(TextUtils.expandTemplate(getText(R.string.storage_wizard_slow_body), descrip, genericDescip)); @@ -142,11 +169,15 @@ public class StorageWizardFormatProgress extends StorageWizardBase { } } - private String getGenericDescription(DiskInfo disk) { + private String getDiskDescription() { + return mDisk.getDescription(); + } + + private String getGenericDiskDescription() { // TODO: move this directly to DiskInfo - if (disk.isSd()) { + if (mDisk.isSd()) { return getString(com.android.internal.R.string.storage_sd_card); - } else if (disk.isUsb()) { + } else if (mDisk.isUsb()) { return getString(com.android.internal.R.string.storage_usb_drive); } else { return null; |