Merge "Tint icon colors of storage screen same as other screen"

This commit is contained in:
Linda Tseng
2019-04-01 22:07:32 +00:00
committed by Android (Google) Code Review
8 changed files with 37 additions and 27 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,27 @@
<!--
Copyright (C) 2019 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#000000"
android:pathData="M18 2h-8L4.02 8 4 20c0 1.1 0.9 2 2 2h12c1.1 0 2-0.9 2-2V4c0-1.1-0.9-2-2-2zm-6 6h-2V4h2v4zm3 0h-2V4h2v4zm3 0h-2V4h2v4z" />
</vector>

View File

@@ -23,8 +23,6 @@ import android.app.settings.SettingsEnums;
import android.content.Context; 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.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
@@ -76,16 +74,6 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
private static final String TAG_DISK_INIT = "disk_init"; private static final String TAG_DISK_INIT = "disk_init";
private static final int METRICS_CATEGORY = SettingsEnums.DEVICEINFO_STORAGE; private static final int METRICS_CATEGORY = SettingsEnums.DEVICEINFO_STORAGE;
static final int COLOR_PUBLIC = Color.parseColor("#ff9e9e9e");
static final int[] COLOR_PRIVATE = new int[]{
Color.parseColor("#ff26a69a"),
Color.parseColor("#ffab47bc"),
Color.parseColor("#fff2a600"),
Color.parseColor("#ffec407a"),
Color.parseColor("#ffc0ca33"),
};
private StorageManager mStorageManager; private StorageManager mStorageManager;
private PreferenceCategory mInternalCategory; private PreferenceCategory mInternalCategory;
@@ -176,13 +164,12 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) { if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol, final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol,
sTotalInternalStorage); sTotalInternalStorage);
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
mInternalCategory.addPreference( mInternalCategory.addPreference(
new StorageVolumePreference(context, vol, color, volumeTotalBytes)); new StorageVolumePreference(context, vol, volumeTotalBytes));
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC } else if (vol.getType() == VolumeInfo.TYPE_PUBLIC
|| vol.getType() == VolumeInfo.TYPE_STUB) { || vol.getType() == VolumeInfo.TYPE_STUB) {
mExternalCategory.addPreference( mExternalCategory.addPreference(
new StorageVolumePreference(context, vol, COLOR_PUBLIC, 0)); new StorageVolumePreference(context, vol, 0));
} }
} }
@@ -192,15 +179,11 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
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 // 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(icon); pref.setIcon(R.drawable.ic_sim_sd);
mInternalCategory.addPreference(pref); mInternalCategory.addPreference(pref);
} }
} }

View File

@@ -50,16 +50,16 @@ public class StorageVolumePreference extends Preference {
private final StorageManager mStorageManager; private final StorageManager mStorageManager;
private final VolumeInfo mVolume; private final VolumeInfo mVolume;
private int mColor;
private int mUsedPercent = -1; private int mUsedPercent = -1;
private ColorStateList mColorTintList;
// TODO: ideally, VolumeInfo should have a total physical size. // TODO: ideally, VolumeInfo should have a total physical size.
public StorageVolumePreference(Context context, VolumeInfo volume, int color, long totalBytes) { public StorageVolumePreference(Context context, VolumeInfo volume, long totalBytes) {
super(context); super(context);
mStorageManager = context.getSystemService(StorageManager.class); mStorageManager = context.getSystemService(StorageManager.class);
mVolume = volume; mVolume = volume;
mColor = color; mColorTintList = Utils.getColorAttr(context, android.R.attr.colorControlNormal);
setLayoutResource(R.layout.storage_volume); setLayoutResource(R.layout.storage_volume);
@@ -107,8 +107,10 @@ public class StorageVolumePreference extends Preference {
} }
if (freeBytes < mStorageManager.getStorageLowBytes(path)) { if (freeBytes < mStorageManager.getStorageLowBytes(path)) {
mColor = Utils.getColorAttrDefaultColor(context, android.R.attr.colorError); mColorTintList = Utils.getColorAttr(context, android.R.attr.colorError);
icon = context.getDrawable(R.drawable.ic_warning_24dp); icon = context.getDrawable(R.drawable.ic_warning_24dp);
icon.mutate();
icon.setTintList(mColorTintList);
} }
} else { } else {
@@ -116,8 +118,6 @@ public class StorageVolumePreference extends Preference {
mUsedPercent = -1; mUsedPercent = -1;
} }
icon.mutate();
icon.setTint(mColor);
setIcon(icon); setIcon(icon);
if (volume.getType() == VolumeInfo.TYPE_PUBLIC if (volume.getType() == VolumeInfo.TYPE_PUBLIC
@@ -138,7 +138,7 @@ public class StorageVolumePreference extends Preference {
if (mVolume.getType() == VolumeInfo.TYPE_PRIVATE && mUsedPercent != -1) { if (mVolume.getType() == VolumeInfo.TYPE_PRIVATE && mUsedPercent != -1) {
progress.setVisibility(View.VISIBLE); progress.setVisibility(View.VISIBLE);
progress.setProgress(mUsedPercent); progress.setProgress(mUsedPercent);
progress.setProgressTintList(ColorStateList.valueOf(mColor)); progress.setProgressTintList(mColorTintList);
} else { } else {
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
} }