Commit 27ae53a7 authored by Michael W's avatar Michael W

Settings: Apply system tint to first private storage

* Instead of always using the default tint, we get the current
  tint from system and use that for the first private storage
* Refactor the code away from hardcoded colors

Solves:
https://gitlab.com/LineageOS/issues/android/issues/1130

Change-Id: I8eca661224ee32147fd5fc95e1fa8a7d4589697f
parent 3476e978
......@@ -400,4 +400,14 @@
<item>@string/app_ops_permissions_ignored</item>
<item>@string/app_ops_permissions_always_ask</item>
</string-array>
<!-- Colors for internal storages -->
<array name="internal_storage_colors">
<item>@color/storage_color_default</item>
<item>@color/storage_color1</item>
<item>@color/storage_color2</item>
<item>@color/storage_color3</item>
<item>@color/storage_color4</item>
</array>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019 The LineageOS 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.
-->
<resources>
<color name="storage_color_default">@*android:color/accent_device_default_light</color>
<color name="storage_color1">#ffab47bc</color>
<color name="storage_color2">#fff2a600</color>
<color name="storage_color3">#ffec407a</color>
<color name="storage_color4">#ffc0ca33</color>
</resources>
/*
* Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2019 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -76,14 +77,6 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
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 PreferenceCategory mInternalCategory;
......@@ -169,11 +162,13 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
final List<VolumeInfo> volumes = mStorageManager.getVolumes();
Collections.sort(volumes, VolumeInfo.getDescriptionComparator());
int[] colors = getResources().getIntArray(R.array.internal_storage_colors);
for (VolumeInfo vol : volumes) {
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol,
sTotalInternalStorage);
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
final int color = colors[privateCount++ % colors.length];
mInternalCategory.addPreference(
new StorageVolumePreference(context, vol, color, volumeTotalBytes));
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment