Actually gracefully finish this time around.
Also fix tinting on front-door icon. Bug: 21403958 Change-Id: I74f0372a41b92235abe10391f36d9f6a1e6a40c5
This commit is contained in:
21
res/drawable/ic_settings_sim.xml
Normal file
21
res/drawable/ic_settings_sim.xml
Normal file
@@ -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" />
|
||||||
|
|
@@ -44,7 +44,7 @@
|
|||||||
android:id="@+id/sim_settings"
|
android:id="@+id/sim_settings"
|
||||||
android:title="@string/sim_settings_title"
|
android:title="@string/sim_settings_title"
|
||||||
android:fragment="com.android.settings.sim.SimSettings"
|
android:fragment="com.android.settings.sim.SimSettings"
|
||||||
android:icon="@drawable/ic_sim_sd"
|
android:icon="@drawable/ic_settings_sim"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Data Usage -->
|
<!-- Data Usage -->
|
||||||
|
@@ -53,7 +53,6 @@ import android.view.View;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.util.Preconditions;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings.StorageUseActivity;
|
import com.android.settings.Settings.StorageUseActivity;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
@@ -110,6 +109,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
private Preference mExplore;
|
private Preference mExplore;
|
||||||
|
|
||||||
|
private boolean isVolumeValid() {
|
||||||
|
return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)
|
||||||
|
&& mVolume.isMountedReadable();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
return MetricsLogger.DEVICEINFO_STORAGE;
|
return MetricsLogger.DEVICEINFO_STORAGE;
|
||||||
@@ -127,22 +131,19 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
mVolumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
mVolumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
||||||
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||||
|
|
||||||
if (mVolume == null) {
|
mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
|
||||||
Log.d(TAG, "Leaving details fragment due to missing volume");
|
mMeasure.setReceiver(mReceiver);
|
||||||
finish();
|
|
||||||
|
if (!isVolumeValid()) {
|
||||||
|
getActivity().finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PRIVATE);
|
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.device_info_storage_volume);
|
addPreferencesFromResource(R.xml.device_info_storage_volume);
|
||||||
|
|
||||||
// Find the emulated shared storage layered above this private volume
|
// Find the emulated shared storage layered above this private volume
|
||||||
mSharedVolume = mStorageManager.findEmulatedForPrivate(mVolume);
|
mSharedVolume = mStorageManager.findEmulatedForPrivate(mVolume);
|
||||||
|
|
||||||
mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
|
|
||||||
mMeasure.setReceiver(mReceiver);
|
|
||||||
|
|
||||||
mSummary = new StorageSummaryPreference(context);
|
mSummary = new StorageSummaryPreference(context);
|
||||||
|
|
||||||
mApps = buildItem(R.string.storage_detail_apps);
|
mApps = buildItem(R.string.storage_detail_apps);
|
||||||
@@ -167,6 +168,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if (!isVolumeValid()) {
|
||||||
|
getActivity().finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
||||||
|
|
||||||
// Valid options may have changed
|
// Valid options may have changed
|
||||||
@@ -177,12 +183,6 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
screen.removeAll();
|
screen.removeAll();
|
||||||
|
|
||||||
if (!mVolume.isMountedReadable()) {
|
|
||||||
Log.d(TAG, "Leaving details fragment due to state " + mVolume.getState());
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen.addPreference(mSummary);
|
screen.addPreference(mSummary);
|
||||||
|
|
||||||
final boolean showUsers = !mUsers.isEmpty();
|
final boolean showUsers = !mUsers.isEmpty();
|
||||||
@@ -250,7 +250,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
// Refresh to verify that we haven't been formatted away
|
// Refresh to verify that we haven't been formatted away
|
||||||
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||||
if (mVolume == null) {
|
if (!isVolumeValid()) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,9 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mMeasure.onDestroy();
|
if (mMeasure != null) {
|
||||||
|
mMeasure.onDestroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -278,6 +280,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
|
if (!isVolumeValid()) return;
|
||||||
|
|
||||||
final MenuItem rename = menu.findItem(R.id.storage_rename);
|
final MenuItem rename = menu.findItem(R.id.storage_rename);
|
||||||
final MenuItem mount = menu.findItem(R.id.storage_mount);
|
final MenuItem mount = menu.findItem(R.id.storage_mount);
|
||||||
final MenuItem unmount = menu.findItem(R.id.storage_unmount);
|
final MenuItem unmount = menu.findItem(R.id.storage_unmount);
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.deviceinfo;
|
package com.android.settings.deviceinfo;
|
||||||
|
|
||||||
import static com.android.settings.deviceinfo.StorageSettings.TAG;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -33,7 +31,6 @@ import android.provider.DocumentsContract;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.text.format.Formatter.BytesResult;
|
import android.text.format.Formatter.BytesResult;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
@@ -67,6 +64,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
private Preference mFormatPublic;
|
private Preference mFormatPublic;
|
||||||
private Preference mFormatPrivate;
|
private Preference mFormatPrivate;
|
||||||
|
|
||||||
|
private boolean isVolumeValid() {
|
||||||
|
return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PUBLIC)
|
||||||
|
&& mVolume.isMountedReadable();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
return MetricsLogger.DEVICEINFO_STORAGE;
|
return MetricsLogger.DEVICEINFO_STORAGE;
|
||||||
@@ -90,14 +92,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
mVolume = mStorageManager.findVolumeById(volId);
|
mVolume = mStorageManager.findVolumeById(volId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVolume == null) {
|
if (!isVolumeValid()) {
|
||||||
Log.d(TAG, "Leaving details fragment due to missing volume");
|
getActivity().finish();
|
||||||
finish();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PUBLIC);
|
|
||||||
|
|
||||||
mDisk = mStorageManager.findDiskById(mVolume.getDiskId());
|
mDisk = mStorageManager.findDiskById(mVolume.getDiskId());
|
||||||
Preconditions.checkNotNull(mDisk);
|
Preconditions.checkNotNull(mDisk);
|
||||||
|
|
||||||
@@ -114,6 +113,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if (!isVolumeValid()) {
|
||||||
|
getActivity().finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
||||||
|
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
@@ -121,12 +125,6 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
screen.removeAll();
|
screen.removeAll();
|
||||||
|
|
||||||
if (!mVolume.isMountedReadable()) {
|
|
||||||
Log.d(TAG, "Leaving details fragment due to state " + mVolume.getState());
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mVolume.isMountedReadable()) {
|
if (mVolume.isMountedReadable()) {
|
||||||
screen.addPreference(mSummary);
|
screen.addPreference(mSummary);
|
||||||
|
|
||||||
@@ -168,7 +166,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
// Refresh to verify that we haven't been formatted away
|
// Refresh to verify that we haven't been formatted away
|
||||||
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||||
if (mVolume == null) {
|
if (!isVolumeValid()) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.storage.DiskInfo;
|
import android.os.storage.DiskInfo;
|
||||||
@@ -165,11 +166,16 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
for (VolumeRecord rec : recs) {
|
for (VolumeRecord rec : recs) {
|
||||||
if (rec.getType() == VolumeInfo.TYPE_PRIVATE
|
if (rec.getType() == VolumeInfo.TYPE_PRIVATE
|
||||||
&& mStorageManager.findVolumeByUuid(rec.getFsUuid()) == null) {
|
&& 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);
|
final Preference pref = new Preference(context);
|
||||||
pref.setKey(rec.getFsUuid());
|
pref.setKey(rec.getFsUuid());
|
||||||
pref.setTitle(rec.getNickname());
|
pref.setTitle(rec.getNickname());
|
||||||
pref.setSummary(com.android.internal.R.string.ext_media_status_missing);
|
pref.setSummary(com.android.internal.R.string.ext_media_status_missing);
|
||||||
pref.setIcon(R.drawable.ic_settings_storage);
|
pref.setIcon(icon);
|
||||||
mInternalCategory.addPreference(pref);
|
mInternalCategory.addPreference(pref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user