summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable/ic_settings_sim.xml21
-rw-r--r--res/xml/dashboard_categories.xml2
-rw-r--r--src/com/android/settings/deviceinfo/PrivateVolumeSettings.java38
-rw-r--r--src/com/android/settings/deviceinfo/PublicVolumeSettings.java28
-rw-r--r--src/com/android/settings/deviceinfo/StorageSettings.java8
5 files changed, 63 insertions, 34 deletions
diff --git a/res/drawable/ic_settings_sim.xml b/res/drawable/ic_settings_sim.xml
new file mode 100644
index 0000000..d2b9d2f
--- /dev/null
+++ b/res/drawable/ic_settings_sim.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/ic_sim_sd"
+ android:tint="?android:attr/colorAccent" />
+
diff --git a/res/xml/dashboard_categories.xml b/res/xml/dashboard_categories.xml
index 54d1d39..d437dcf 100644
--- a/res/xml/dashboard_categories.xml
+++ b/res/xml/dashboard_categories.xml
@@ -44,7 +44,7 @@
android:id="@+id/sim_settings"
android:title="@string/sim_settings_title"
android:fragment="com.android.settings.sim.SimSettings"
- android:icon="@drawable/ic_sim_sd"
+ android:icon="@drawable/ic_settings_sim"
/>
<!-- Data Usage -->
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index b7a42c3..0c65528 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -53,7 +53,6 @@ import android.view.View;
import android.widget.EditText;
import com.android.internal.logging.MetricsLogger;
-import com.android.internal.util.Preconditions;
import com.android.settings.R;
import com.android.settings.Settings.StorageUseActivity;
import com.android.settings.SettingsPreferenceFragment;
@@ -110,6 +109,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
private Preference mExplore;
+ private boolean isVolumeValid() {
+ return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)
+ && mVolume.isMountedReadable();
+ }
+
@Override
protected int getMetricsCategory() {
return MetricsLogger.DEVICEINFO_STORAGE;
@@ -127,22 +131,19 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
mVolumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
mVolume = mStorageManager.findVolumeById(mVolumeId);
- if (mVolume == null) {
- Log.d(TAG, "Leaving details fragment due to missing volume");
- finish();
+ mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
+ mMeasure.setReceiver(mReceiver);
+
+ if (!isVolumeValid()) {
+ getActivity().finish();
return;
}
- Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PRIVATE);
-
addPreferencesFromResource(R.xml.device_info_storage_volume);
// Find the emulated shared storage layered above this private volume
mSharedVolume = mStorageManager.findEmulatedForPrivate(mVolume);
- mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
- mMeasure.setReceiver(mReceiver);
-
mSummary = new StorageSummaryPreference(context);
mApps = buildItem(R.string.storage_detail_apps);
@@ -167,6 +168,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
}
public void update() {
+ if (!isVolumeValid()) {
+ getActivity().finish();
+ return;
+ }
+
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
// Valid options may have changed
@@ -177,12 +183,6 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
screen.removeAll();
- if (!mVolume.isMountedReadable()) {
- Log.d(TAG, "Leaving details fragment due to state " + mVolume.getState());
- finish();
- return;
- }
-
screen.addPreference(mSummary);
final boolean showUsers = !mUsers.isEmpty();
@@ -250,7 +250,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
// Refresh to verify that we haven't been formatted away
mVolume = mStorageManager.findVolumeById(mVolumeId);
- if (mVolume == null) {
+ if (!isVolumeValid()) {
getActivity().finish();
return;
}
@@ -268,7 +268,9 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
@Override
public void onDestroy() {
super.onDestroy();
- mMeasure.onDestroy();
+ if (mMeasure != null) {
+ mMeasure.onDestroy();
+ }
}
@Override
@@ -278,6 +280,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
@Override
public void onPrepareOptionsMenu(Menu menu) {
+ if (!isVolumeValid()) return;
+
final MenuItem rename = menu.findItem(R.id.storage_rename);
final MenuItem mount = menu.findItem(R.id.storage_mount);
final MenuItem unmount = menu.findItem(R.id.storage_unmount);
diff --git a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
index 8e912eb..2987c12 100644
--- a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
@@ -16,8 +16,6 @@
package com.android.settings.deviceinfo;
-import static com.android.settings.deviceinfo.StorageSettings.TAG;
-
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -33,7 +31,6 @@ import android.provider.DocumentsContract;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.text.format.Formatter.BytesResult;
-import android.util.Log;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.Preconditions;
@@ -67,6 +64,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
private Preference mFormatPublic;
private Preference mFormatPrivate;
+ private boolean isVolumeValid() {
+ return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PUBLIC)
+ && mVolume.isMountedReadable();
+ }
+
@Override
protected int getMetricsCategory() {
return MetricsLogger.DEVICEINFO_STORAGE;
@@ -90,14 +92,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
mVolume = mStorageManager.findVolumeById(volId);
}
- if (mVolume == null) {
- Log.d(TAG, "Leaving details fragment due to missing volume");
- finish();
+ if (!isVolumeValid()) {
+ getActivity().finish();
return;
}
- Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PUBLIC);
-
mDisk = mStorageManager.findDiskById(mVolume.getDiskId());
Preconditions.checkNotNull(mDisk);
@@ -114,6 +113,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
}
public void update() {
+ if (!isVolumeValid()) {
+ getActivity().finish();
+ return;
+ }
+
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
final Context context = getActivity();
@@ -121,12 +125,6 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
screen.removeAll();
- if (!mVolume.isMountedReadable()) {
- Log.d(TAG, "Leaving details fragment due to state " + mVolume.getState());
- finish();
- return;
- }
-
if (mVolume.isMountedReadable()) {
screen.addPreference(mSummary);
@@ -168,7 +166,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
// Refresh to verify that we haven't been formatted away
mVolume = mStorageManager.findVolumeById(mVolumeId);
- if (mVolume == null) {
+ if (!isVolumeValid()) {
getActivity().finish();
return;
}
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index b1745ec..a8a516b 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
+import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.storage.DiskInfo;
@@ -165,11 +166,16 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
for (VolumeRecord rec : recs) {
if (rec.getType() == VolumeInfo.TYPE_PRIVATE
&& mStorageManager.findVolumeByUuid(rec.getFsUuid()) == null) {
+ // TODO: add actual storage type to record
+ final Drawable icon = context.getDrawable(R.drawable.ic_sim_sd);
+ icon.mutate();
+ icon.setTint(COLOR_PUBLIC);
+
final Preference pref = new Preference(context);
pref.setKey(rec.getFsUuid());
pref.setTitle(rec.getNickname());
pref.setSummary(com.android.internal.R.string.ext_media_status_missing);
- pref.setIcon(R.drawable.ic_settings_storage);
+ pref.setIcon(icon);
mInternalCategory.addPreference(pref);
}
}