--- /dev/null
+<?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" />
+
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 -->
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;
private Preference mExplore;
+ private boolean isVolumeValid() {
+ return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)
+ && mVolume.isMountedReadable();
+ }
+
@Override
protected int getMetricsCategory() {
return MetricsLogger.DEVICEINFO_STORAGE;
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);
}
public void update() {
+ if (!isVolumeValid()) {
+ getActivity().finish();
+ return;
+ }
+
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
// Valid options may have changed
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();
// Refresh to verify that we haven't been formatted away
mVolume = mStorageManager.findVolumeById(mVolumeId);
- if (mVolume == null) {
+ if (!isVolumeValid()) {
getActivity().finish();
return;
}
@Override
public void onDestroy() {
super.onDestroy();
- mMeasure.onDestroy();
+ if (mMeasure != null) {
+ mMeasure.onDestroy();
+ }
}
@Override
@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);
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;
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;
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;
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);
}
public void update() {
+ if (!isVolumeValid()) {
+ getActivity().finish();
+ return;
+ }
+
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
final Context context = getActivity();
screen.removeAll();
- if (!mVolume.isMountedReadable()) {
- Log.d(TAG, "Leaving details fragment due to state " + mVolume.getState());
- finish();
- return;
- }
-
if (mVolume.isMountedReadable()) {
screen.addPreference(mSummary);
// Refresh to verify that we haven't been formatted away
mVolume = mStorageManager.findVolumeById(mVolumeId);
- if (mVolume == null) {
+ if (!isVolumeValid()) {
getActivity().finish();
return;
}
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;
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);
}
}