summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/PrivacySettings.java2
-rw-r--r--src/com/android/settings/deviceinfo/FileItemInfoLayout.java80
-rw-r--r--src/com/android/settings/deviceinfo/PrivateVolumeFormatConfirm.java74
-rw-r--r--src/com/android/settings/deviceinfo/PrivateVolumeSettings.java26
-rw-r--r--src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java71
-rw-r--r--src/com/android/settings/deviceinfo/PublicVolumeSettings.java24
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardBase.java136
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java48
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java89
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardInit.java83
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMigrate.java81
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java52
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java75
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardReady.java59
14 files changed, 810 insertions, 90 deletions
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index 4eb8a9e52..6eb22fbd5 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -204,7 +204,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
if (summary != null) {
mConfigure.setSummary(summary);
} else {
- mConfigure.setSummary(R.string.backup_configure_account_default_summary);
+ //mConfigure.setSummary(R.string.backup_configure_account_default_summary);
}
}
diff --git a/src/com/android/settings/deviceinfo/FileItemInfoLayout.java b/src/com/android/settings/deviceinfo/FileItemInfoLayout.java
deleted file mode 100644
index 542d7c97d..000000000
--- a/src/com/android/settings/deviceinfo/FileItemInfoLayout.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-package com.android.settings.deviceinfo;
-
-import android.content.Context;
-import android.os.Environment.UserEnvironment;
-import android.os.UserHandle;
-import android.util.AttributeSet;
-import android.view.ViewDebug;
-import android.widget.CheckBox;
-import android.widget.Checkable;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.android.settings.R;
-
-/**
- * Handles display of a single row entry on Settings --> Storage --> Misc Files screen
- */
-public class FileItemInfoLayout extends RelativeLayout implements Checkable {
- private TextView mFileNameView;
- private TextView mFileSizeView;
- private CheckBox mCheckbox;
-
- private static final int sLengthExternalStorageDirPrefix = new UserEnvironment(
- UserHandle.myUserId()).getExternalStorageDirectory().getAbsolutePath().length() + 1;
-
- public FileItemInfoLayout(Context context) {
- this(context, null);
- }
-
- public FileItemInfoLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public FileItemInfoLayout(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public void toggle() {
- setChecked(!mCheckbox.isChecked());
- }
-
- /* (non-Javadoc)
- * @see android.view.View#onFinishInflate()
- */
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mFileNameView = (TextView) findViewById(R.id.misc_filename);
- mFileSizeView = (TextView) findViewById(R.id.misc_filesize);
- mCheckbox = (CheckBox) findViewById(R.id.misc_checkbox);
- }
-
- public void setFileName(String fileName) {
- mFileNameView.setText(fileName.substring(sLengthExternalStorageDirPrefix));
- }
-
- public void setFileSize(String filesize) {
- mFileSizeView.setText(filesize);
- }
-
- @ViewDebug.ExportedProperty
- public boolean isChecked() {
- return mCheckbox.isChecked();
- }
-
- public CheckBox getCheckBox() {
- return mCheckbox;
- }
-
- /**
- * <p>Changes the checked state of this text view.</p>
- *
- * @param checked true to check the text, false to uncheck it
- */
- public void setChecked(boolean checked) {
- mCheckbox.setChecked(checked);
- }
-} \ No newline at end of file
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeFormatConfirm.java b/src/com/android/settings/deviceinfo/PrivateVolumeFormatConfirm.java
new file mode 100644
index 000000000..12994d50d
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeFormatConfirm.java
@@ -0,0 +1,74 @@
+/*
+ * 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.content.Intent;
+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.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 PrivateVolumeFormatConfirm extends InstrumentedFragment {
+ private VolumeInfo mVolume;
+ private DiskInfo mDisk;
+
+ @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 volumeId = getArguments().getString(StorageSettings.EXTRA_VOLUME_ID);
+ mVolume = storage.findVolumeById(volumeId);
+ mDisk = storage.findDiskByVolumeId(volumeId);
+
+ final View view = inflater.inflate(R.layout.storage_internal_format, 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_format_details),
+ mDisk.getDescription()));
+ confirm.setOnClickListener(mConfirmListener);
+
+ return view;
+ }
+
+ private final OnClickListener mConfirmListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class);
+ intent.putExtra(StorageWizardBase.EXTRA_DISK_ID, mDisk.id);
+ intent.putExtra(StorageWizardFormatProgress.EXTRA_FORMAT_PUBLIC, true);
+ startActivity(intent);
+ getActivity().finish();
+ }
+ };
+}
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index efb9a07d2..95a5874c9 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -58,9 +58,7 @@ import com.android.settings.Settings;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.deviceinfo.StorageMeasurement.MeasurementDetails;
import com.android.settings.deviceinfo.StorageMeasurement.MeasurementReceiver;
-import com.android.settings.deviceinfo.StorageSettings.FormatTask;
import com.android.settings.deviceinfo.StorageSettings.MountTask;
-import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
import com.google.android.collect.Lists;
import java.io.File;
@@ -82,6 +80,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
private StorageManager mStorageManager;
private UserManager mUserManager;
+ private String mVolumeId;
private VolumeInfo mVolume;
private VolumeInfo mSharedVolume;
@@ -119,8 +118,10 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
mUserManager = context.getSystemService(UserManager.class);
mStorageManager = context.getSystemService(StorageManager.class);
- final String volId = getArguments().getString(EXTRA_VOLUME_ID);
- mVolume = Preconditions.checkNotNull(mStorageManager.findVolumeById(volId));
+ mVolumeId = getArguments().getString(EXTRA_VOLUME_ID);
+ mVolume = mStorageManager.findVolumeById(mVolumeId);
+
+ Preconditions.checkNotNull(mVolume);
Preconditions.checkState(mVolume.type == VolumeInfo.TYPE_PRIVATE);
addPreferencesFromResource(R.xml.device_info_storage_volume);
@@ -233,6 +234,14 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
@Override
public void onResume() {
super.onResume();
+
+ // Refresh to verify that we haven't been formatted away
+ mVolume = mStorageManager.findVolumeById(mVolumeId);
+ if (mVolume == null) {
+ getActivity().finish();
+ return;
+ }
+
mStorageManager.registerListener(mStorageListener);
refresh();
}
@@ -283,6 +292,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
final Context context = getActivity();
+ final Bundle args = new Bundle();
switch (item.getItemId()) {
case R.id.storage_rename:
RenameFragment.show(this);
@@ -291,10 +301,14 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
new MountTask(context, mVolume.id).execute();
return true;
case R.id.storage_unmount:
- new UnmountTask(context, mVolume.id).execute();
+ args.putString(StorageSettings.EXTRA_VOLUME_ID, mVolume.id);
+ startFragment(this, PrivateVolumeUnmountConfirm.class.getCanonicalName(),
+ R.string.storage_menu_unmount, 0, args);
return true;
case R.id.storage_format:
- new FormatTask(context, mVolume.id).execute();
+ args.putString(StorageSettings.EXTRA_VOLUME_ID, mVolume.id);
+ startFragment(this, PrivateVolumeFormatConfirm.class.getCanonicalName(),
+ R.string.storage_menu_format, 0, args);
return true;
case R.id.storage_usb:
startFragment(this, UsbSettings.class.getCanonicalName(),
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java b/src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java
new file mode 100644
index 000000000..78283fc42
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeUnmountConfirm.java
@@ -0,0 +1,71 @@
+/*
+ * 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.DiskInfo;
+import android.os.storage.StorageManager;
+import android.os.storage.VolumeInfo;
+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;
+import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
+
+public class PrivateVolumeUnmountConfirm extends InstrumentedFragment {
+ private VolumeInfo mVolume;
+ private DiskInfo mDisk;
+
+ @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 volumeId = getArguments().getString(StorageSettings.EXTRA_VOLUME_ID);
+ mVolume = storage.findVolumeById(volumeId);
+ mDisk = storage.findDiskByVolumeId(volumeId);
+
+ final View view = inflater.inflate(R.layout.storage_internal_unmount, 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()));
+ confirm.setOnClickListener(mConfirmListener);
+
+ return view;
+ }
+
+ private final OnClickListener mConfirmListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new UnmountTask(getActivity(), mVolume.id).execute();
+ getActivity().finish();
+ }
+ };
+}
diff --git a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
index 6edfc924c..ef116b275 100644
--- a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
@@ -19,9 +19,10 @@ package com.android.settings.deviceinfo;
import static com.android.settings.deviceinfo.StorageSettings.EXTRA_VOLUME_ID;
import android.content.Context;
+import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.os.SystemProperties;
+import android.os.storage.DiskInfo;
import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
@@ -52,7 +53,9 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
private StorageManager mStorageManager;
+ private String mVolumeId;
private VolumeInfo mVolume;
+ private DiskInfo mDisk;
private int mNextOrder = 0;
@@ -94,6 +97,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
Preconditions.checkNotNull(mVolume);
Preconditions.checkState(mVolume.type == VolumeInfo.TYPE_PUBLIC);
+ mDisk = mStorageManager.findDiskByVolumeId(mVolume.id);
+ Preconditions.checkNotNull(mDisk);
+
+ mVolumeId = mVolume.id;
+
addPreferencesFromResource(R.xml.device_info_storage_volume);
mGraph = buildGraph();
@@ -127,7 +135,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
screen.addPreference(mUnmount);
}
screen.addPreference(mFormat);
- if (SystemProperties.getBoolean(PREF_FORMAT_INTERNAL, false)) {
+ if ((mDisk.flags & DiskInfo.FLAG_ADOPTABLE) != 0) {
screen.addPreference(mFormatInternal);
}
@@ -167,6 +175,14 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
@Override
public void onResume() {
super.onResume();
+
+ // Refresh to verify that we haven't been formatted away
+ mVolume = mStorageManager.findVolumeById(mVolumeId);
+ if (mVolume == null) {
+ getActivity().finish();
+ return;
+ }
+
mStorageManager.registerListener(mStorageListener);
refresh();
}
@@ -187,7 +203,9 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
} else if (pref == mFormat) {
new FormatTask(context, mVolume.id).execute();
} else if (pref == mFormatInternal) {
- // TODO: implement this
+ final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
+ intent.putExtra(StorageWizardBase.EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
}
return super.onPreferenceTreeClick(preferenceScreen, pref);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java
new file mode 100644
index 000000000..a3f4d7976
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java
@@ -0,0 +1,136 @@
+/*
+ * 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.app.Activity;
+import android.graphics.Color;
+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.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.setupwizardlib.SetupWizardLayout;
+import com.android.setupwizardlib.view.NavigationBar;
+import com.android.setupwizardlib.view.NavigationBar.NavigationBarListener;
+
+import java.text.NumberFormat;
+
+public abstract class StorageWizardBase extends Activity implements NavigationBarListener {
+ protected static final String EXTRA_DISK_ID = "disk_id";
+ protected static final String EXTRA_VOLUME_ID = "volume_id";
+
+ protected StorageManager mStorage;
+
+ protected VolumeInfo mVolume;
+ protected DiskInfo mDisk;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mStorage = getSystemService(StorageManager.class);
+
+ final String volumeId = getIntent().getStringExtra(EXTRA_VOLUME_ID);
+ if (!TextUtils.isEmpty(volumeId)) {
+ mVolume = mStorage.findVolumeById(volumeId);
+ }
+
+ final String diskId = getIntent().getStringExtra(EXTRA_DISK_ID);
+ if (!TextUtils.isEmpty(diskId)) {
+ mDisk = mStorage.findDiskById(diskId);
+ } else {
+ mDisk = mStorage.findDiskByVolumeId(volumeId);
+ }
+
+ setTheme(R.style.SuwThemeMaterial_Light);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS |
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
+ WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
+
+ getNavigationBar().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+
+ getWindow().setStatusBarColor(Color.TRANSPARENT);
+
+ getNavigationBar().setNavigationBarListener(this);
+ getBackButton().setVisibility(View.GONE);
+ }
+
+ protected NavigationBar getNavigationBar() {
+ return (NavigationBar) findViewById(R.id.suw_layout_navigation_bar);
+ }
+
+ protected Button getBackButton() {
+ return getNavigationBar().getBackButton();
+ }
+
+ protected Button getNextButton() {
+ return getNavigationBar().getNextButton();
+ }
+
+ protected SetupWizardLayout getSetupWizardLayout() {
+ return (SetupWizardLayout) findViewById(R.id.setup_wizard_layout);
+ }
+
+ protected ProgressBar getProgressBar() {
+ return (ProgressBar) findViewById(R.id.storage_wizard_progress);
+ }
+
+ protected void setCurrentProgress(int progress) {
+ getProgressBar().setProgress(progress);
+ ((TextView) findViewById(R.id.storage_wizard_progress_summary)).setText(
+ NumberFormat.getPercentInstance().format((double) progress / 100));
+ }
+
+ protected void setHeaderText(int resId, String... args) {
+ getSetupWizardLayout().setHeaderText(TextUtils.expandTemplate(getText(resId), args));
+ }
+
+ protected void setBodyText(int resId, String... args) {
+ ((TextView) findViewById(R.id.storage_wizard_body)).setText(
+ TextUtils.expandTemplate(getText(resId), args));
+ }
+
+ protected void setSecondaryBodyText(int resId, String... args) {
+ final TextView secondBody = ((TextView) findViewById(R.id.storage_wizard_second_body));
+ secondBody.setText(TextUtils.expandTemplate(getText(resId), args));
+ secondBody.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void onNavigateBack() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void onNavigateNext() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
new file mode 100644
index 000000000..37235de1c
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
@@ -0,0 +1,48 @@
+/*
+ * 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.content.Intent;
+import android.os.Bundle;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+
+public class StorageWizardFormatConfirm extends StorageWizardBase {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.storage_wizard_generic);
+
+ Preconditions.checkNotNull(mDisk);
+
+ setHeaderText(R.string.storage_wizard_format_confirm_title);
+ setBodyText(R.string.storage_wizard_format_confirm_body,
+ mDisk.getDescription());
+
+ // TODO: make this a big red scary button
+ getNextButton().setText(R.string.storage_wizard_format_confirm_next);
+ }
+
+ @Override
+ public void onNavigateNext() {
+ final Intent intent = new Intent(this, StorageWizardFormatProgress.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ finishAffinity();
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
new file mode 100644
index 000000000..286f1a4f5
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
@@ -0,0 +1,89 @@
+/*
+ * 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 static com.android.settings.deviceinfo.StorageSettings.TAG;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Toast;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+
+public class StorageWizardFormatProgress extends StorageWizardBase {
+ public static final String EXTRA_FORMAT_PUBLIC = "format_private";
+
+ private boolean mFormatPublic;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.storage_wizard_progress);
+
+ Preconditions.checkNotNull(mDisk);
+
+ mFormatPublic = getIntent().getBooleanExtra(EXTRA_FORMAT_PUBLIC, false);
+
+ 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();
+ }
+
+ public class PartitionTask extends AsyncTask<Void, Void, Exception> {
+ @Override
+ protected Exception doInBackground(Void... params) {
+ try {
+ if (mFormatPublic) {
+ mStorage.partitionPublic(mDisk.id);
+ } else {
+ mStorage.partitionPrivate(mDisk.id);
+ }
+ return null;
+ } catch (Exception e) {
+ return e;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(Exception e) {
+ final Context context = StorageWizardFormatProgress.this;
+ if (e == null) {
+ if (!mFormatPublic) {
+ final Intent intent = new Intent(context, StorageWizardMigrate.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ }
+ finishAffinity();
+
+ } else {
+ Log.e(TAG, "Failed to partition", e);
+ Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
+ finishAffinity();
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java
new file mode 100644
index 000000000..bb5e08f6f
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java
@@ -0,0 +1,83 @@
+/*
+ * 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.content.Intent;
+import android.os.Bundle;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.RadioButton;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+
+public class StorageWizardInit extends StorageWizardBase {
+ private RadioButton mRadioExternal;
+ private RadioButton mRadioInternal;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.storage_wizard_init);
+
+ Preconditions.checkNotNull(mDisk);
+
+ setHeaderText(R.string.storage_wizard_init_title, mDisk.getDescription());
+
+ mRadioExternal = (RadioButton) findViewById(R.id.storage_wizard_init_external_title);
+ mRadioInternal = (RadioButton) findViewById(R.id.storage_wizard_init_internal_title);
+
+ mRadioExternal.setOnCheckedChangeListener(mRadioListener);
+ mRadioInternal.setOnCheckedChangeListener(mRadioListener);
+
+ findViewById(R.id.storage_wizard_init_external_summary).setPadding(
+ mRadioExternal.getCompoundPaddingLeft(), 0,
+ mRadioExternal.getCompoundPaddingRight(), 0);
+ findViewById(R.id.storage_wizard_init_internal_summary).setPadding(
+ mRadioExternal.getCompoundPaddingLeft(), 0,
+ mRadioExternal.getCompoundPaddingRight(), 0);
+
+ getNextButton().setEnabled(false);
+ }
+
+ private final OnCheckedChangeListener mRadioListener = new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ if (buttonView == mRadioExternal) {
+ mRadioInternal.setChecked(false);
+ } else if (buttonView == mRadioInternal) {
+ mRadioExternal.setChecked(false);
+ }
+ getNextButton().setEnabled(true);
+ }
+ }
+ };
+
+ @Override
+ public void onNavigateNext() {
+ if (mRadioExternal.isChecked()) {
+ final Intent intent = new Intent(this, StorageWizardReady.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ } else if (mRadioInternal.isChecked()) {
+ final Intent intent = new Intent(this, StorageWizardFormatConfirm.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ }
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrate.java b/src/com/android/settings/deviceinfo/StorageWizardMigrate.java
new file mode 100644
index 000000000..2afdc1537
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrate.java
@@ -0,0 +1,81 @@
+/*
+ * 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.content.Intent;
+import android.os.Bundle;
+import android.text.format.DateUtils;
+import android.text.format.Formatter;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.RadioButton;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+
+public class StorageWizardMigrate extends StorageWizardBase {
+ private RadioButton mRadioNow;
+ private RadioButton mRadioLater;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.storage_wizard_migrate);
+
+ Preconditions.checkNotNull(mDisk);
+
+ final String time = DateUtils.formatDuration(0).toString();
+ final String size = Formatter.formatFileSize(this, 0);
+
+ setHeaderText(R.string.storage_wizard_migrate_title, mDisk.getDescription());
+ setBodyText(R.string.storage_wizard_migrate_body, mDisk.getDescription(), time, size);
+
+ mRadioNow = (RadioButton) findViewById(R.id.storage_wizard_migrate_now);
+ mRadioLater = (RadioButton) findViewById(R.id.storage_wizard_migrate_later);
+
+ mRadioNow.setOnCheckedChangeListener(mRadioListener);
+ mRadioLater.setOnCheckedChangeListener(mRadioListener);
+
+ mRadioNow.setChecked(true);
+ }
+
+ private final OnCheckedChangeListener mRadioListener = new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ if (buttonView == mRadioNow) {
+ mRadioLater.setChecked(false);
+ } else if (buttonView == mRadioLater) {
+ mRadioNow.setChecked(false);
+ }
+ }
+ }
+ };
+
+ @Override
+ public void onNavigateNext() {
+ if (mRadioNow.isChecked()) {
+ final Intent intent = new Intent(this, StorageWizardMigrateConfirm.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ } else if (mRadioLater.isChecked()) {
+ final Intent intent = new Intent(this, StorageWizardReady.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ }
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
new file mode 100644
index 000000000..4a6fed61a
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
@@ -0,0 +1,52 @@
+/*
+ * 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.content.Intent;
+import android.os.Bundle;
+import android.text.format.DateUtils;
+import android.text.format.Formatter;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+
+public class StorageWizardMigrateConfirm extends StorageWizardBase {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.storage_wizard_generic);
+
+ Preconditions.checkNotNull(mDisk);
+
+ final String time = DateUtils.formatDuration(0).toString();
+ final String size = Formatter.formatFileSize(this, 0);
+
+ setHeaderText(R.string.storage_wizard_migrate_confirm_title, mDisk.getDescription());
+ setBodyText(R.string.storage_wizard_migrate_confirm_body, time, size);
+ setSecondaryBodyText(R.string.storage_wizard_migrate_details, mDisk.getDescription());
+
+ getNextButton().setText(R.string.storage_wizard_migrate_confirm_next);
+ }
+
+ @Override
+ public void onNavigateNext() {
+ final Intent intent = new Intent(this, StorageWizardMigrateProgress.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ finishAffinity();
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
new file mode 100644
index 000000000..0589694b4
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
@@ -0,0 +1,75 @@
+/*
+ * 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 static com.android.settings.deviceinfo.StorageSettings.TAG;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.util.Log;
+import android.view.View;
+import android.widget.Toast;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+
+public class StorageWizardMigrateProgress extends StorageWizardBase {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.storage_wizard_progress);
+
+ Preconditions.checkNotNull(mDisk);
+
+ setHeaderText(R.string.storage_wizard_migrate_progress_title, mDisk.getDescription());
+ setBodyText(R.string.storage_wizard_migrate_details, mDisk.getDescription());
+
+ setCurrentProgress(20);
+
+ getNextButton().setVisibility(View.GONE);
+
+ new MigrateTask().execute();
+ }
+
+ public class MigrateTask extends AsyncTask<Void, Void, Exception> {
+ @Override
+ protected Exception doInBackground(Void... params) {
+ // TODO: wire up migration
+ SystemClock.sleep(2000);
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Exception e) {
+ final Context context = StorageWizardMigrateProgress.this;
+ if (e == null) {
+ final Intent intent = new Intent(context, StorageWizardReady.class);
+ intent.putExtra(EXTRA_DISK_ID, mDisk.id);
+ startActivity(intent);
+ finishAffinity();
+
+ } else {
+ Log.e(TAG, "Failed to migrate", e);
+ Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
+ finishAffinity();
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardReady.java b/src/com/android/settings/deviceinfo/StorageWizardReady.java
new file mode 100644
index 000000000..c950986f1
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/StorageWizardReady.java
@@ -0,0 +1,59 @@
+/*
+ * 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.VolumeInfo;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+
+public class StorageWizardReady extends StorageWizardBase {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.storage_wizard_generic);
+
+ Preconditions.checkNotNull(mDisk);
+
+ setHeaderText(R.string.storage_wizard_ready_title, mDisk.getDescription());
+
+ // TODO: handle mixed partition cases instead of just guessing based on
+ // first volume type we encounter
+ for (String volId : mDisk.volumes) {
+ final VolumeInfo vol = mStorage.findVolumeById(volId);
+ if (vol == null) continue;
+
+ if (vol.type == VolumeInfo.TYPE_PUBLIC) {
+ setBodyText(R.string.storage_wizard_ready_external_body,
+ mDisk.getDescription());
+ break;
+ } else if (vol.type == VolumeInfo.TYPE_PRIVATE) {
+ setBodyText(R.string.storage_wizard_ready_internal_body,
+ mDisk.getDescription());
+ break;
+ }
+ }
+
+ getNextButton().setText(R.string.done);
+ }
+
+ @Override
+ public void onNavigateNext() {
+ finishAffinity();
+ }
+}