Format as public/private; follow refactoring.
Offer to format an empty disk as public/private. Bug: 19993667 Change-Id: I69fafaed524f3ef5e65d04a9e3a94789fcfc3087
This commit is contained in:
@@ -1490,7 +1490,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$StorageVolumeSettingsActivity"
|
android:name="Settings$PublicVolumeSettingsActivity"
|
||||||
android:label="@string/storage_settings_title"
|
android:label="@string/storage_settings_title"
|
||||||
android:taskAffinity="com.android.settings"
|
android:taskAffinity="com.android.settings"
|
||||||
android:parentActivityName="Settings$StorageSettingsActivity">
|
android:parentActivityName="Settings$StorageSettingsActivity">
|
||||||
@@ -1508,6 +1508,19 @@
|
|||||||
android:resource="@id/storage_settings" />
|
android:resource="@id/storage_settings" />
|
||||||
</activity>
|
</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 -->
|
<!-- Exported for SystemUI to launch into -->
|
||||||
<activity android:name=".deviceinfo.StorageWizardInit"
|
<activity android:name=".deviceinfo.StorageWizardInit"
|
||||||
android:theme="@style/SuwThemeMaterial.Light"
|
android:theme="@style/SuwThemeMaterial.Light"
|
||||||
|
51
res/layout/storage_internal_forget.xml
Normal file
51
res/layout/storage_internal_forget.xml
Normal file
@@ -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>
|
@@ -2287,6 +2287,8 @@
|
|||||||
<string name="storage_menu_format_internal">Erase & format as internal storage</string>
|
<string name="storage_menu_format_internal">Erase & format as internal storage</string>
|
||||||
<!-- Storage setting. Menu option for USB transfer settings [CHAR LIMIT=30]-->
|
<!-- Storage setting. Menu option for USB transfer settings [CHAR LIMIT=30]-->
|
||||||
<string name="storage_menu_usb">USB computer connection</string>
|
<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]-->
|
<!-- Storage setting. Title for USB transfer settings [CHAR LIMIT=30]-->
|
||||||
<string name="storage_title_usb">USB computer connection</string>
|
<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>
|
<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>
|
\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] -->
|
<!-- 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>
|
<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] -->
|
<!-- 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\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.
|
\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>
|
</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] -->
|
<!-- 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>
|
<string name="storage_wizard_format_confirm_next">Erase & format</string>
|
||||||
|
|
||||||
|
@@ -33,7 +33,8 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class StorageSettingsActivity 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 WifiSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
@@ -83,6 +83,7 @@ import com.android.settings.dashboard.DashboardSummary;
|
|||||||
import com.android.settings.dashboard.DashboardTile;
|
import com.android.settings.dashboard.DashboardTile;
|
||||||
import com.android.settings.dashboard.NoHomeDialogFragment;
|
import com.android.settings.dashboard.NoHomeDialogFragment;
|
||||||
import com.android.settings.dashboard.SearchResultsSummary;
|
import com.android.settings.dashboard.SearchResultsSummary;
|
||||||
|
import com.android.settings.deviceinfo.PrivateVolumeForget;
|
||||||
import com.android.settings.deviceinfo.PublicVolumeSettings;
|
import com.android.settings.deviceinfo.PublicVolumeSettings;
|
||||||
import com.android.settings.deviceinfo.StorageSettings;
|
import com.android.settings.deviceinfo.StorageSettings;
|
||||||
import com.android.settings.deviceinfo.UsbSettings;
|
import com.android.settings.deviceinfo.UsbSettings;
|
||||||
@@ -310,6 +311,7 @@ public class SettingsActivity extends Activity
|
|||||||
TextToSpeechSettings.class.getName(),
|
TextToSpeechSettings.class.getName(),
|
||||||
StorageSettings.class.getName(),
|
StorageSettings.class.getName(),
|
||||||
PublicVolumeSettings.class.getName(),
|
PublicVolumeSettings.class.getName(),
|
||||||
|
PrivateVolumeForget.class.getName(),
|
||||||
DevelopmentSettings.class.getName(),
|
DevelopmentSettings.class.getName(),
|
||||||
UsbSettings.class.getName(),
|
UsbSettings.class.getName(),
|
||||||
AndroidBeam.class.getName(),
|
AndroidBeam.class.getName(),
|
||||||
|
68
src/com/android/settings/deviceinfo/PrivateVolumeForget.java
Normal file
68
src/com/android/settings/deviceinfo/PrivateVolumeForget.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.deviceinfo;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.storage.StorageManager;
|
||||||
|
import android.os.storage.VolumeRecord;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
import com.android.settings.InstrumentedFragment;
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
public class PrivateVolumeForget extends InstrumentedFragment {
|
||||||
|
private VolumeRecord mRecord;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMetricsCategory() {
|
||||||
|
return MetricsLogger.DEVICEINFO_STORAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
||||||
|
final String fsUuid = getArguments().getString(VolumeRecord.EXTRA_FS_UUID);
|
||||||
|
mRecord = storage.findRecordByUuid(fsUuid);
|
||||||
|
|
||||||
|
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_forget_details),
|
||||||
|
mRecord.getNickname()));
|
||||||
|
confirm.setOnClickListener(mConfirmListener);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final OnClickListener mConfirmListener = new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
||||||
|
storage.forgetVolume(mRecord.getFsUuid());
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@@ -33,7 +33,7 @@ import com.android.internal.logging.MetricsLogger;
|
|||||||
import com.android.settings.InstrumentedFragment;
|
import com.android.settings.InstrumentedFragment;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class PrivateVolumeFormatConfirm extends InstrumentedFragment {
|
public class PrivateVolumeFormat extends InstrumentedFragment {
|
||||||
private VolumeInfo mVolume;
|
private VolumeInfo mVolume;
|
||||||
private DiskInfo mDisk;
|
private DiskInfo mDisk;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public class PrivateVolumeFormatConfirm extends InstrumentedFragment {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class);
|
final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
intent.putExtra(StorageWizardFormatProgress.EXTRA_FORMAT_PUBLIC, true);
|
intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, false);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
@@ -37,10 +37,10 @@ import android.os.UserManager;
|
|||||||
import android.os.storage.StorageEventListener;
|
import android.os.storage.StorageEventListener;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.os.storage.VolumeInfo;
|
import android.os.storage.VolumeInfo;
|
||||||
|
import android.os.storage.VolumeRecord;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -160,7 +160,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void update() {
|
||||||
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
||||||
|
|
||||||
// Valid options may have changed
|
// Valid options may have changed
|
||||||
@@ -245,7 +245,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mStorageManager.registerListener(mStorageListener);
|
mStorageManager.registerListener(mStorageListener);
|
||||||
refresh();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -297,19 +297,19 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.storage_rename:
|
case R.id.storage_rename:
|
||||||
RenameFragment.show(this);
|
RenameFragment.show(this, mVolume);
|
||||||
return true;
|
return true;
|
||||||
case R.id.storage_mount:
|
case R.id.storage_mount:
|
||||||
new MountTask(context, mVolume).execute();
|
new MountTask(context, mVolume).execute();
|
||||||
return true;
|
return true;
|
||||||
case R.id.storage_unmount:
|
case R.id.storage_unmount:
|
||||||
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
|
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);
|
R.string.storage_menu_unmount, 0, args);
|
||||||
return true;
|
return true;
|
||||||
case R.id.storage_format:
|
case R.id.storage_format:
|
||||||
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
|
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);
|
R.string.storage_menu_format, 0, args);
|
||||||
return true;
|
return true;
|
||||||
case R.id.storage_usb:
|
case R.id.storage_usb:
|
||||||
@@ -437,15 +437,15 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
||||||
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
||||||
mVolume = vol;
|
mVolume = vol;
|
||||||
refresh();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVolumeMetadataChanged(VolumeInfo vol) {
|
public void onVolumeMetadataChanged(String fsUuid) {
|
||||||
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
if (Objects.equals(mVolume.getFsUuid(), fsUuid)) {
|
||||||
mVolume = vol;
|
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||||
refresh();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -454,12 +454,14 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
* Dialog that allows editing of volume nickname.
|
* Dialog that allows editing of volume nickname.
|
||||||
*/
|
*/
|
||||||
public static class RenameFragment extends DialogFragment {
|
public static class RenameFragment extends DialogFragment {
|
||||||
public static void show(PrivateVolumeSettings parent) {
|
public static void show(PrivateVolumeSettings parent, VolumeInfo vol) {
|
||||||
if (!parent.isAdded()) return;
|
if (!parent.isAdded()) return;
|
||||||
|
|
||||||
final RenameFragment dialog = new RenameFragment();
|
final RenameFragment dialog = new RenameFragment();
|
||||||
dialog.setTargetFragment(parent, 0);
|
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);
|
dialog.show(parent.getFragmentManager(), TAG_RENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,20 +470,16 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
final StorageManager storageManager = context.getSystemService(StorageManager.class);
|
final StorageManager storageManager = context.getSystemService(StorageManager.class);
|
||||||
|
|
||||||
final String volId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
final String fsUuid = getArguments().getString(VolumeRecord.EXTRA_FS_UUID);
|
||||||
final VolumeInfo vol = storageManager.findVolumeById(volId);
|
final VolumeInfo vol = storageManager.findVolumeByUuid(fsUuid);
|
||||||
|
final VolumeRecord rec = storageManager.findRecordByUuid(fsUuid);
|
||||||
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
|
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
|
||||||
|
|
||||||
final View view = dialogInflater.inflate(R.layout.dialog_edittext, null, false);
|
final View view = dialogInflater.inflate(R.layout.dialog_edittext, null, false);
|
||||||
final EditText nickname = (EditText) view.findViewById(R.id.edittext);
|
final EditText nickname = (EditText) view.findViewById(R.id.edittext);
|
||||||
|
nickname.setText(rec.getNickname());
|
||||||
if (!TextUtils.isEmpty(vol.getNickname())) {
|
|
||||||
nickname.setText(vol.getNickname());
|
|
||||||
} else {
|
|
||||||
nickname.setText(storageManager.getBestVolumeDescription(vol));
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setTitle(R.string.storage_rename_title);
|
builder.setTitle(R.string.storage_rename_title);
|
||||||
builder.setView(view);
|
builder.setView(view);
|
||||||
@@ -491,7 +489,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// TODO: move to background thread
|
// TODO: move to background thread
|
||||||
storageManager.setVolumeNickname(volId, nickname.getText().toString());
|
storageManager.setVolumeNickname(fsUuid,
|
||||||
|
nickname.getText().toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
@@ -552,7 +551,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
public void onRemoveCompleted(final String packageName, final boolean succeeded) {
|
public void onRemoveCompleted(final String packageName, final boolean succeeded) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (--mRemaining == 0) {
|
if (--mRemaining == 0) {
|
||||||
mTarget.refresh();
|
mTarget.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ import com.android.settings.InstrumentedFragment;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
|
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
|
||||||
|
|
||||||
public class PrivateVolumeUnmountConfirm extends InstrumentedFragment {
|
public class PrivateVolumeUnmount extends InstrumentedFragment {
|
||||||
private VolumeInfo mVolume;
|
private VolumeInfo mVolume;
|
||||||
private DiskInfo mDisk;
|
private DiskInfo mDisk;
|
||||||
|
|
@@ -33,7 +33,6 @@ import com.android.internal.logging.MetricsLogger;
|
|||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
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.MountTask;
|
||||||
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
|
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
|
||||||
|
|
||||||
@@ -110,7 +109,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
mFormatInternal = buildAction(R.string.storage_menu_format_internal);
|
mFormatInternal = buildAction(R.string.storage_menu_format_internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void update() {
|
||||||
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
||||||
|
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
@@ -180,7 +179,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mStorageManager.registerListener(mStorageListener);
|
mStorageManager.registerListener(mStorageListener);
|
||||||
refresh();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -197,10 +196,14 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
} else if (pref == mUnmount) {
|
} else if (pref == mUnmount) {
|
||||||
new UnmountTask(context, mVolume).execute();
|
new UnmountTask(context, mVolume).execute();
|
||||||
} else if (pref == mFormat) {
|
} 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) {
|
} else if (pref == mFormatInternal) {
|
||||||
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
|
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
|
intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,15 +215,15 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
||||||
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
||||||
mVolume = vol;
|
mVolume = vol;
|
||||||
refresh();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVolumeMetadataChanged(VolumeInfo vol) {
|
public void onVolumeMetadataChanged(String fsUuid) {
|
||||||
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
if (Objects.equals(mVolume.getFsUuid(), fsUuid)) {
|
||||||
mVolume = vol;
|
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||||
refresh();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -273,43 +273,6 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
* Enable indexing of searchable data
|
||||||
*/
|
*/
|
||||||
|
@@ -24,6 +24,10 @@ import com.android.internal.util.Preconditions;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class StorageWizardFormatConfirm extends StorageWizardBase {
|
public class StorageWizardFormatConfirm extends StorageWizardBase {
|
||||||
|
public static final String EXTRA_FORMAT_PRIVATE = "format_private";
|
||||||
|
|
||||||
|
private boolean mFormatPrivate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -31,9 +35,17 @@ public class StorageWizardFormatConfirm extends StorageWizardBase {
|
|||||||
|
|
||||||
Preconditions.checkNotNull(mDisk);
|
Preconditions.checkNotNull(mDisk);
|
||||||
|
|
||||||
setHeaderText(R.string.storage_wizard_format_confirm_title);
|
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
|
||||||
setBodyText(R.string.storage_wizard_format_confirm_body,
|
|
||||||
mDisk.getDescription());
|
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
|
// TODO: make this a big red scary button
|
||||||
getNextButton().setText(R.string.storage_wizard_format_confirm_next);
|
getNextButton().setText(R.string.storage_wizard_format_confirm_next);
|
||||||
@@ -43,6 +55,7 @@ public class StorageWizardFormatConfirm extends StorageWizardBase {
|
|||||||
public void onNavigateNext() {
|
public void onNavigateNext() {
|
||||||
final Intent intent = new Intent(this, StorageWizardFormatProgress.class);
|
final Intent intent = new Intent(this, StorageWizardFormatProgress.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
|
intent.putExtra(EXTRA_FORMAT_PRIVATE, mFormatPrivate);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finishAffinity();
|
finishAffinity();
|
||||||
}
|
}
|
||||||
|
@@ -31,9 +31,7 @@ import com.android.internal.util.Preconditions;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class StorageWizardFormatProgress extends StorageWizardBase {
|
public class StorageWizardFormatProgress extends StorageWizardBase {
|
||||||
public static final String EXTRA_FORMAT_PUBLIC = "format_private";
|
private boolean mFormatPrivate;
|
||||||
|
|
||||||
private boolean mFormatPublic;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -42,7 +40,8 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
|||||||
|
|
||||||
Preconditions.checkNotNull(mDisk);
|
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());
|
setHeaderText(R.string.storage_wizard_format_progress_title, mDisk.getDescription());
|
||||||
setBodyText(R.string.storage_wizard_format_progress_body, mDisk.getDescription());
|
setBodyText(R.string.storage_wizard_format_progress_body, mDisk.getDescription());
|
||||||
@@ -58,10 +57,10 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
|||||||
@Override
|
@Override
|
||||||
protected Exception doInBackground(Void... params) {
|
protected Exception doInBackground(Void... params) {
|
||||||
try {
|
try {
|
||||||
if (mFormatPublic) {
|
if (mFormatPrivate) {
|
||||||
mStorage.partitionPublic(mDisk.getId());
|
|
||||||
} else {
|
|
||||||
mStorage.partitionPrivate(mDisk.getId());
|
mStorage.partitionPrivate(mDisk.getId());
|
||||||
|
} else {
|
||||||
|
mStorage.partitionPublic(mDisk.getId());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -73,7 +72,7 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
|||||||
protected void onPostExecute(Exception e) {
|
protected void onPostExecute(Exception e) {
|
||||||
final Context context = StorageWizardFormatProgress.this;
|
final Context context = StorageWizardFormatProgress.this;
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
if (!mFormatPublic) {
|
if (mFormatPrivate) {
|
||||||
// TODO: bring back migration once implemented
|
// TODO: bring back migration once implemented
|
||||||
// final Intent intent = new Intent(context, StorageWizardMigrate.class);
|
// final Intent intent = new Intent(context, StorageWizardMigrate.class);
|
||||||
// intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
// intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
@@ -81,6 +80,10 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
|||||||
final Intent intent = new Intent(context, StorageWizardReady.class);
|
final Intent intent = new Intent(context, StorageWizardReady.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
final Intent intent = new Intent(context, StorageWizardReady.class);
|
||||||
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
finishAffinity();
|
finishAffinity();
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.deviceinfo;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.storage.DiskInfo;
|
import android.os.storage.DiskInfo;
|
||||||
|
import android.os.storage.VolumeInfo;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
@@ -72,15 +73,26 @@ public class StorageWizardInit extends StorageWizardBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onNavigateNext() {
|
public void onNavigateNext() {
|
||||||
if (mRadioExternal.isChecked()) {
|
if (mRadioExternal.isChecked()) {
|
||||||
// Remember that user made decision
|
if (mVolume != null && mVolume.getType() == VolumeInfo.TYPE_PUBLIC) {
|
||||||
mStorage.setVolumeInited(mVolume.getId(), true);
|
// 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);
|
||||||
|
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
final Intent intent = new Intent(this, StorageWizardReady.class);
|
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
|
||||||
startActivity(intent);
|
|
||||||
} else if (mRadioInternal.isChecked()) {
|
} else if (mRadioInternal.isChecked()) {
|
||||||
final Intent intent = new Intent(this, StorageWizardFormatConfirm.class);
|
final Intent intent = new Intent(this, StorageWizardFormatConfirm.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
|
intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ public class StorageWizardMoveProgress extends StorageWizardBase {
|
|||||||
|
|
||||||
// Register for updates and push through current status
|
// Register for updates and push through current status
|
||||||
getPackageManager().registerMoveCallback(mCallback, new Handler());
|
getPackageManager().registerMoveCallback(mCallback, new Handler());
|
||||||
mCallback.onStatusChanged(mMoveId, getPackageManager().getMoveStatus(mMoveId), -1);
|
mCallback.onStatusChanged(mMoveId, null, getPackageManager().getMoveStatus(mMoveId), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,12 +60,7 @@ public class StorageWizardMoveProgress extends StorageWizardBase {
|
|||||||
|
|
||||||
private final MoveCallback mCallback = new MoveCallback() {
|
private final MoveCallback mCallback = new MoveCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onStarted(int moveId, String title) {
|
public void onStatusChanged(int moveId, String moveTitle, int status, long estMillis) {
|
||||||
// Ignored
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(int moveId, int status, long estMillis) {
|
|
||||||
if (mMoveId != moveId) return;
|
if (mMoveId != moveId) return;
|
||||||
|
|
||||||
if (PackageManager.isMoveStatusFinished(status)) {
|
if (PackageManager.isMoveStatusFinished(status)) {
|
||||||
|
Reference in New Issue
Block a user