Format as public/private; follow refactoring.
Offer to format an empty disk as public/private.
Bug: 19993667
Change-Id: I69fafaed524f3ef5e65d04a9e3a94789fcfc3087
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 435236a..0446178 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1490,7 +1490,7 @@
</activity>
<activity
- android:name="Settings$StorageVolumeSettingsActivity"
+ android:name="Settings$PublicVolumeSettingsActivity"
android:label="@string/storage_settings_title"
android:taskAffinity="com.android.settings"
android:parentActivityName="Settings$StorageSettingsActivity">
@@ -1508,6 +1508,19 @@
android:resource="@id/storage_settings" />
</activity>
+ <activity
+ android:name="Settings$PrivateVolumeForgetActivity"
+ android:label="@string/storage_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings$StorageSettingsActivity"
+ android:exported="true"
+ android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.deviceinfo.PrivateVolumeForget" />
+ <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
+ android:resource="@id/storage_settings" />
+ </activity>
+
<!-- Exported for SystemUI to launch into -->
<activity android:name=".deviceinfo.StorageWizardInit"
android:theme="@style/SuwThemeMaterial.Light"
diff --git a/res/layout/storage_internal_forget.xml b/res/layout/storage_internal_forget.xml
new file mode 100644
index 0000000..cb47d3b
--- /dev/null
+++ b/res/layout/storage_internal_forget.xml
@@ -0,0 +1,51 @@
+<?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="match_parent"
+ android:orientation="vertical">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1">
+ <TextView
+ android:id="@+id/body"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="@dimen/suw_description_margin_top"
+ android:paddingBottom="@dimen/suw_description_margin_bottom"
+ android:paddingStart="@dimen/suw_layout_margin_sides"
+ android:paddingEnd="@dimen/suw_layout_margin_sides"
+ android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorPrimary" />
+ </ScrollView>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="4dp">
+ <Button
+ android:id="@+id/confirm"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/storage_menu_forget" />
+ </FrameLayout>
+
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e08b692..cde0f24 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2287,6 +2287,8 @@
<string name="storage_menu_format_internal">Erase & format as internal storage</string>
<!-- Storage setting. Menu option for USB transfer settings [CHAR LIMIT=30]-->
<string name="storage_menu_usb">USB computer connection</string>
+ <!-- Storage setting. Menu option for forgetting a storage device [CHAR LIMIT=30]-->
+ <string name="storage_menu_forget">Forget</string>
<!-- Storage setting. Title for USB transfer settings [CHAR LIMIT=30]-->
<string name="storage_title_usb">USB computer connection</string>
@@ -2346,6 +2348,12 @@
<string name="storage_internal_unmount_details"><b>When you eject this <xliff:g id="name" example="SD card">^1</xliff:g>, apps stored on it will stop working, and media files stored on it will not be available until it is reinserted.</b>
\n\nThis <xliff:g id="name" example="SD card">^1</xliff:g> is formatted to work on this device only. It won\'t work on any others.</string>
+ <!-- Body of dialog informing user about consequences of forgetting an internal storage device [CHAR LIMIT=NONE]-->
+ <string name="storage_internal_forget_details">To use the apps, photos, or data this <xliff:g id="name" example="SD card">^1</xliff:g> contains, reinsert it.
+\n\nAlternatively, you can choose to forget this storage if the device isn\'t available.
+\n\nIf you choose to forget, all the data the device contains will be lost forever.
+\n\nYou can reinstall the apps later, but their data stored on this device will be lost.</string>
+
<!-- Title of wizard step prompting user to setup a storage device [CHAR LIMIT=32] -->
<string name="storage_wizard_init_title">Set up your <xliff:g id="name" example="SD card">^1</xliff:g></string>
<!-- Title of wizard choice to use storage device as external storage [CHAR LIMIT=64] -->
@@ -2364,6 +2372,14 @@
\n\nAfter formatting, this <xliff:g id="name" example="SD card">^1</xliff:g> will only work in this device.
\n\n<b>Formatting erases all data currently stored on the <xliff:g id="name" example="SD card">^1</xliff:g>.</b> To avoid losing the data, consider backing it up.
</string>
+
+ <!-- Title of wizard step prompting user to format a storage device [CHAR LIMIT=32] -->
+ <string name="storage_wizard_format_confirm_public_title">Format as portable storage</string>
+ <!-- Body of wizard step prompting user to format a storage device [CHAR LIMIT=NONE] -->
+ <string name="storage_wizard_format_confirm_public_body">This requires the <xliff:g id="name" example="SD card">^1</xliff:g> to be formatted.
+\n\n<b>Formatting erases all data currently stored on the <xliff:g id="name" example="SD card">^1</xliff:g>.</b> To avoid losing the data, consider backing it up.
+ </string>
+
<!-- Next button text of wizard step prompting user to format a storage device [CHAR LIMIT=32] -->
<string name="storage_wizard_format_confirm_next">Erase & format</string>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index ba08036..88c8316 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -33,7 +33,8 @@
public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
public static class StorageSettingsActivity extends SettingsActivity { /* empty */ }
- public static class StorageVolumeSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class PublicVolumeSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class PrivateVolumeForgetActivity extends SettingsActivity { /* empty */ }
public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index ee2b1b4..5e1acb1 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -83,6 +83,7 @@
import com.android.settings.dashboard.DashboardTile;
import com.android.settings.dashboard.NoHomeDialogFragment;
import com.android.settings.dashboard.SearchResultsSummary;
+import com.android.settings.deviceinfo.PrivateVolumeForget;
import com.android.settings.deviceinfo.PublicVolumeSettings;
import com.android.settings.deviceinfo.StorageSettings;
import com.android.settings.deviceinfo.UsbSettings;
@@ -310,6 +311,7 @@
TextToSpeechSettings.class.getName(),
StorageSettings.class.getName(),
PublicVolumeSettings.class.getName(),
+ PrivateVolumeForget.class.getName(),
DevelopmentSettings.class.getName(),
UsbSettings.class.getName(),
AndroidBeam.class.getName(),
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java b/src/com/android/settings/deviceinfo/PrivateVolumeForget.java
similarity index 75%
copy from src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java
copy to src/com/android/settings/deviceinfo/PrivateVolumeForget.java
index 614b737..c8b04e3 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeForget.java
@@ -17,9 +17,8 @@
package com.android.settings.deviceinfo;
import android.os.Bundle;
-import android.os.storage.DiskInfo;
import android.os.storage.StorageManager;
-import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -31,11 +30,9 @@
import com.android.internal.logging.MetricsLogger;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
-import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
-public class PrivateVolumeUnmountConfirm extends InstrumentedFragment {
- private VolumeInfo mVolume;
- private DiskInfo mDisk;
+public class PrivateVolumeForget extends InstrumentedFragment {
+ private VolumeRecord mRecord;
@Override
protected int getMetricsCategory() {
@@ -46,16 +43,15 @@
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
- final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
- mVolume = storage.findVolumeById(volumeId);
- mDisk = storage.findDiskById(mVolume.getDiskId());
+ final String fsUuid = getArguments().getString(VolumeRecord.EXTRA_FS_UUID);
+ mRecord = storage.findRecordByUuid(fsUuid);
- final View view = inflater.inflate(R.layout.storage_internal_unmount, container, false);
+ final View view = inflater.inflate(R.layout.storage_internal_forget, container, false);
final TextView body = (TextView) view.findViewById(R.id.body);
final Button confirm = (Button) view.findViewById(R.id.confirm);
- body.setText(TextUtils.expandTemplate(getText(R.string.storage_internal_unmount_details),
- mDisk.getDescription()));
+ body.setText(TextUtils.expandTemplate(getText(R.string.storage_internal_forget_details),
+ mRecord.getNickname()));
confirm.setOnClickListener(mConfirmListener);
return view;
@@ -64,7 +60,8 @@
private final OnClickListener mConfirmListener = new OnClickListener() {
@Override
public void onClick(View v) {
- new UnmountTask(getActivity(), mVolume).execute();
+ final StorageManager storage = getActivity().getSystemService(StorageManager.class);
+ storage.forgetVolume(mRecord.getFsUuid());
getActivity().finish();
}
};
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeFormatConfirm.java b/src/com/android/settings/deviceinfo/PrivateVolumeFormat.java
similarity index 94%
rename from src/com/android/settings/deviceinfo/PrivateVolumeFormatConfirm.java
rename to src/com/android/settings/deviceinfo/PrivateVolumeFormat.java
index 666a918..e16778f 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeFormatConfirm.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeFormat.java
@@ -33,7 +33,7 @@
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
-public class PrivateVolumeFormatConfirm extends InstrumentedFragment {
+public class PrivateVolumeFormat extends InstrumentedFragment {
private VolumeInfo mVolume;
private DiskInfo mDisk;
@@ -66,7 +66,7 @@
public void onClick(View v) {
final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class);
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
- intent.putExtra(StorageWizardFormatProgress.EXTRA_FORMAT_PUBLIC, true);
+ intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, false);
startActivity(intent);
getActivity().finish();
}
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index 492051d..3e2b570 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -37,10 +37,10 @@
import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.provider.MediaStore;
-import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.Log;
import android.view.LayoutInflater;
@@ -160,7 +160,7 @@
setHasOptionsMenu(true);
}
- public void refresh() {
+ public void update() {
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
// Valid options may have changed
@@ -245,7 +245,7 @@
}
mStorageManager.registerListener(mStorageListener);
- refresh();
+ update();
}
@Override
@@ -297,19 +297,19 @@
final Bundle args = new Bundle();
switch (item.getItemId()) {
case R.id.storage_rename:
- RenameFragment.show(this);
+ RenameFragment.show(this, mVolume);
return true;
case R.id.storage_mount:
new MountTask(context, mVolume).execute();
return true;
case R.id.storage_unmount:
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
- startFragment(this, PrivateVolumeUnmountConfirm.class.getCanonicalName(),
+ startFragment(this, PrivateVolumeUnmount.class.getCanonicalName(),
R.string.storage_menu_unmount, 0, args);
return true;
case R.id.storage_format:
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
- startFragment(this, PrivateVolumeFormatConfirm.class.getCanonicalName(),
+ startFragment(this, PrivateVolumeFormat.class.getCanonicalName(),
R.string.storage_menu_format, 0, args);
return true;
case R.id.storage_usb:
@@ -437,15 +437,15 @@
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
if (Objects.equals(mVolume.getId(), vol.getId())) {
mVolume = vol;
- refresh();
+ update();
}
}
@Override
- public void onVolumeMetadataChanged(VolumeInfo vol) {
- if (Objects.equals(mVolume.getId(), vol.getId())) {
- mVolume = vol;
- refresh();
+ public void onVolumeMetadataChanged(String fsUuid) {
+ if (Objects.equals(mVolume.getFsUuid(), fsUuid)) {
+ mVolume = mStorageManager.findVolumeById(mVolumeId);
+ update();
}
}
};
@@ -454,12 +454,14 @@
* Dialog that allows editing of volume nickname.
*/
public static class RenameFragment extends DialogFragment {
- public static void show(PrivateVolumeSettings parent) {
+ public static void show(PrivateVolumeSettings parent, VolumeInfo vol) {
if (!parent.isAdded()) return;
final RenameFragment dialog = new RenameFragment();
dialog.setTargetFragment(parent, 0);
- dialog.setArguments(parent.getArguments());
+ final Bundle args = new Bundle();
+ args.putString(VolumeRecord.EXTRA_FS_UUID, vol.getFsUuid());
+ dialog.setArguments(args);
dialog.show(parent.getFragmentManager(), TAG_RENAME);
}
@@ -468,20 +470,16 @@
final Context context = getActivity();
final StorageManager storageManager = context.getSystemService(StorageManager.class);
- final String volId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
- final VolumeInfo vol = storageManager.findVolumeById(volId);
+ final String fsUuid = getArguments().getString(VolumeRecord.EXTRA_FS_UUID);
+ final VolumeInfo vol = storageManager.findVolumeByUuid(fsUuid);
+ final VolumeRecord rec = storageManager.findRecordByUuid(fsUuid);
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
final View view = dialogInflater.inflate(R.layout.dialog_edittext, null, false);
final EditText nickname = (EditText) view.findViewById(R.id.edittext);
-
- if (!TextUtils.isEmpty(vol.getNickname())) {
- nickname.setText(vol.getNickname());
- } else {
- nickname.setText(storageManager.getBestVolumeDescription(vol));
- }
+ nickname.setText(rec.getNickname());
builder.setTitle(R.string.storage_rename_title);
builder.setView(view);
@@ -491,7 +489,8 @@
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO: move to background thread
- storageManager.setVolumeNickname(volId, nickname.getText().toString());
+ storageManager.setVolumeNickname(fsUuid,
+ nickname.getText().toString());
}
});
builder.setNegativeButton(R.string.cancel, null);
@@ -552,7 +551,7 @@
public void onRemoveCompleted(final String packageName, final boolean succeeded) {
synchronized (this) {
if (--mRemaining == 0) {
- mTarget.refresh();
+ mTarget.update();
}
}
}
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java b/src/com/android/settings/deviceinfo/PrivateVolumeUnmount.java
similarity index 96%
rename from src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java
rename to src/com/android/settings/deviceinfo/PrivateVolumeUnmount.java
index 614b737..410db8f 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeUnmount.java
@@ -33,7 +33,7 @@
import com.android.settings.R;
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
-public class PrivateVolumeUnmountConfirm extends InstrumentedFragment {
+public class PrivateVolumeUnmount extends InstrumentedFragment {
private VolumeInfo mVolume;
private DiskInfo mDisk;
diff --git a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
index e0b6843..1d7991d 100644
--- a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
@@ -33,7 +33,6 @@
import com.android.internal.util.Preconditions;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.deviceinfo.StorageSettings.FormatTask;
import com.android.settings.deviceinfo.StorageSettings.MountTask;
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
@@ -110,7 +109,7 @@
mFormatInternal = buildAction(R.string.storage_menu_format_internal);
}
- public void refresh() {
+ public void update() {
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
final Context context = getActivity();
@@ -180,7 +179,7 @@
}
mStorageManager.registerListener(mStorageListener);
- refresh();
+ update();
}
@Override
@@ -197,10 +196,14 @@
} else if (pref == mUnmount) {
new UnmountTask(context, mVolume).execute();
} else if (pref == mFormat) {
- new FormatTask(context, mVolume).execute();
+ final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
+ intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
+ intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, false);
+ startActivity(intent);
} else if (pref == mFormatInternal) {
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
+ intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, true);
startActivity(intent);
}
@@ -212,15 +215,15 @@
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
if (Objects.equals(mVolume.getId(), vol.getId())) {
mVolume = vol;
- refresh();
+ update();
}
}
@Override
- public void onVolumeMetadataChanged(VolumeInfo vol) {
- if (Objects.equals(mVolume.getId(), vol.getId())) {
- mVolume = vol;
- refresh();
+ public void onVolumeMetadataChanged(String fsUuid) {
+ if (Objects.equals(mVolume.getFsUuid(), fsUuid)) {
+ mVolume = mStorageManager.findVolumeById(mVolumeId);
+ update();
}
}
};
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index 7a7d90d..4c03d8f 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -273,43 +273,6 @@
}
}
- public static class FormatTask extends AsyncTask<Void, Void, Exception> {
- private final Context mContext;
- private final StorageManager mStorageManager;
- private final String mVolumeId;
- private final String mDescription;
-
- public FormatTask(Context context, VolumeInfo volume) {
- mContext = context.getApplicationContext();
- mStorageManager = mContext.getSystemService(StorageManager.class);
- mVolumeId = volume.getId();
- mDescription = mStorageManager.getBestVolumeDescription(volume);
- }
-
- @Override
- protected Exception doInBackground(Void... params) {
- try {
- mStorageManager.format(mVolumeId);
- mStorageManager.mount(mVolumeId);
- return null;
- } catch (Exception e) {
- return e;
- }
- }
-
- @Override
- protected void onPostExecute(Exception e) {
- if (e == null) {
- Toast.makeText(mContext, mContext.getString(R.string.storage_format_success,
- mDescription), Toast.LENGTH_SHORT).show();
- } else {
- Log.e(TAG, "Failed to format " + mVolumeId, e);
- Toast.makeText(mContext, mContext.getString(R.string.storage_format_failure,
- mDescription), Toast.LENGTH_SHORT).show();
- }
- }
- }
-
/**
* Enable indexing of searchable data
*/
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
index f4f475f..81073d6 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
@@ -24,6 +24,10 @@
import com.android.settings.R;
public class StorageWizardFormatConfirm extends StorageWizardBase {
+ public static final String EXTRA_FORMAT_PRIVATE = "format_private";
+
+ private boolean mFormatPrivate;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -31,9 +35,17 @@
Preconditions.checkNotNull(mDisk);
- setHeaderText(R.string.storage_wizard_format_confirm_title);
- setBodyText(R.string.storage_wizard_format_confirm_body,
- mDisk.getDescription());
+ mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
+
+ if (mFormatPrivate) {
+ setHeaderText(R.string.storage_wizard_format_confirm_title);
+ setBodyText(R.string.storage_wizard_format_confirm_body,
+ mDisk.getDescription());
+ } else {
+ setHeaderText(R.string.storage_wizard_format_confirm_public_title);
+ setBodyText(R.string.storage_wizard_format_confirm_public_body,
+ mDisk.getDescription());
+ }
// TODO: make this a big red scary button
getNextButton().setText(R.string.storage_wizard_format_confirm_next);
@@ -43,6 +55,7 @@
public void onNavigateNext() {
final Intent intent = new Intent(this, StorageWizardFormatProgress.class);
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
+ intent.putExtra(EXTRA_FORMAT_PRIVATE, mFormatPrivate);
startActivity(intent);
finishAffinity();
}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
index 2996d45..e60bbcf 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
@@ -31,9 +31,7 @@
import com.android.settings.R;
public class StorageWizardFormatProgress extends StorageWizardBase {
- public static final String EXTRA_FORMAT_PUBLIC = "format_private";
-
- private boolean mFormatPublic;
+ private boolean mFormatPrivate;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -42,7 +40,8 @@
Preconditions.checkNotNull(mDisk);
- mFormatPublic = getIntent().getBooleanExtra(EXTRA_FORMAT_PUBLIC, false);
+ mFormatPrivate = getIntent().getBooleanExtra(
+ StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, false);
setHeaderText(R.string.storage_wizard_format_progress_title, mDisk.getDescription());
setBodyText(R.string.storage_wizard_format_progress_body, mDisk.getDescription());
@@ -58,10 +57,10 @@
@Override
protected Exception doInBackground(Void... params) {
try {
- if (mFormatPublic) {
- mStorage.partitionPublic(mDisk.getId());
- } else {
+ if (mFormatPrivate) {
mStorage.partitionPrivate(mDisk.getId());
+ } else {
+ mStorage.partitionPublic(mDisk.getId());
}
return null;
} catch (Exception e) {
@@ -73,7 +72,7 @@
protected void onPostExecute(Exception e) {
final Context context = StorageWizardFormatProgress.this;
if (e == null) {
- if (!mFormatPublic) {
+ if (mFormatPrivate) {
// TODO: bring back migration once implemented
// final Intent intent = new Intent(context, StorageWizardMigrate.class);
// intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
@@ -81,6 +80,10 @@
final Intent intent = new Intent(context, StorageWizardReady.class);
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
startActivity(intent);
+ } else {
+ final Intent intent = new Intent(context, StorageWizardReady.class);
+ intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
+ startActivity(intent);
}
finishAffinity();
diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java
index 9d59231..22a8008 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardInit.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java
@@ -19,6 +19,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.storage.DiskInfo;
+import android.os.storage.VolumeInfo;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;
@@ -72,15 +73,26 @@
@Override
public void onNavigateNext() {
if (mRadioExternal.isChecked()) {
- // Remember that user made decision
- mStorage.setVolumeInited(mVolume.getId(), true);
+ if (mVolume != null && mVolume.getType() == VolumeInfo.TYPE_PUBLIC) {
+ // Remember that user made decision
+ mStorage.setVolumeInited(mVolume.getFsUuid(), true);
- final Intent intent = new Intent(this, StorageWizardReady.class);
- intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
- startActivity(intent);
+ final Intent intent = new Intent(this, StorageWizardReady.class);
+ intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
+ startActivity(intent);
+
+ } else {
+ // Gotta format to get there
+ final Intent intent = new Intent(this, StorageWizardFormatConfirm.class);
+ intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
+ intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, false);
+ startActivity(intent);
+ }
+
} else if (mRadioInternal.isChecked()) {
final Intent intent = new Intent(this, StorageWizardFormatConfirm.class);
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
+ intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, true);
startActivity(intent);
}
}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java b/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java
index b0946c5..1202b9e 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMoveProgress.java
@@ -49,7 +49,7 @@
// Register for updates and push through current status
getPackageManager().registerMoveCallback(mCallback, new Handler());
- mCallback.onStatusChanged(mMoveId, getPackageManager().getMoveStatus(mMoveId), -1);
+ mCallback.onStatusChanged(mMoveId, null, getPackageManager().getMoveStatus(mMoveId), -1);
}
@Override
@@ -60,12 +60,7 @@
private final MoveCallback mCallback = new MoveCallback() {
@Override
- public void onStarted(int moveId, String title) {
- // Ignored
- }
-
- @Override
- public void onStatusChanged(int moveId, int status, long estMillis) {
+ public void onStatusChanged(int moveId, String moveTitle, int status, long estMillis) {
if (mMoveId != moveId) return;
if (PackageManager.isMoveStatusFinished(status)) {