am b126a4ea
: am 084dd048
: am fc963764
: am bdb64bf1
: am 7616b00b
: Merge changes from topic \'mig\' into mnc-dev
* commit 'b126a4ea4abffecd9580b1c56cde22f58e7f742d': Fix some ordering, colors, and accessibility bugs. Handle missing migration source volume.
This commit is contained in:
@@ -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>
|
||||
|
@@ -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
|
||||
|
@@ -81,6 +81,11 @@ public abstract class MigrateEstimateTask extends AsyncTask<Void, Void, Long> im
|
||||
final VolumeInfo privateVol = mContext.getPackageManager().getPrimaryStorageCurrentVolume();
|
||||
final VolumeInfo emulatedVol = mStorage.findEmulatedForPrivate(privateVol);
|
||||
|
||||
if (emulatedVol == null) {
|
||||
Log.w(TAG, "Failed to find current primary storage");
|
||||
return -1L;
|
||||
}
|
||||
|
||||
final String path = emulatedVol.getPath().getAbsolutePath();
|
||||
Log.d(TAG, "Estimating for current path " + path);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
@@ -57,32 +60,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);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartitionTask extends AsyncTask<Void, Integer, Exception> {
|
||||
@Override
|
||||
public Object onRetainNonConfigurationInstance() {
|
||||
return mTask;
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -92,16 +111,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;
|
||||
}
|
||||
|
||||
@@ -111,22 +136,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));
|
||||
|
||||
@@ -143,11 +170,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;
|
||||
|
@@ -16,10 +16,13 @@
|
||||
|
||||
package com.android.settings.deviceinfo;
|
||||
|
||||
import static com.android.settings.deviceinfo.StorageSettings.TAG;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
@@ -36,12 +39,13 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
||||
mVolume = findFirstVolume(VolumeInfo.TYPE_PRIVATE);
|
||||
}
|
||||
|
||||
if (mVolume == null) {
|
||||
final VolumeInfo sourceVol = getPackageManager().getPrimaryStorageCurrentVolume();
|
||||
if (sourceVol == null || mVolume == null) {
|
||||
Log.d(TAG, "Missing either source or target volume");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
final VolumeInfo sourceVol = getPackageManager().getPrimaryStorageCurrentVolume();
|
||||
final String sourceDescrip = mStorage.getBestVolumeDescription(sourceVol);
|
||||
final String targetDescrip = mStorage.getBestVolumeDescription(mVolume);
|
||||
|
||||
|
Reference in New Issue
Block a user