Remove hardcoded color for cellular data usage view
1. Remove hardcoded color and create colorStateList instead 2. Remove warning color and use attr textColorError instead 3. Add function to extract color from colorStateList Bug: 32592245 Test: manual - Take screenshots Change-Id: I7f0a54b304b09b99ba1f255952e7e99e009a4d2a
This commit is contained in:
@@ -8,6 +8,7 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.pm.Signature;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -165,6 +166,22 @@ public class Utils {
|
||||
return colorAccent;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getColorError(Context context) {
|
||||
TypedArray ta = context.obtainStyledAttributes(new int[]{android.R.attr.textColorError});
|
||||
@ColorInt int colorError = ta.getColor(0, 0);
|
||||
ta.recycle();
|
||||
return colorError;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getDefaultColor(Context context, int resId) {
|
||||
final ColorStateList list =
|
||||
context.getResources().getColorStateList(resId, context.getTheme());
|
||||
|
||||
return list.getDefaultColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a package is a "system package", in which case certain things (like
|
||||
* disabling notifications or disabling the package altogether) should be disallowed.
|
||||
|
||||
18
packages/SystemUI/res/color/data_usage_graph_track.xml
Normal file
18
packages/SystemUI/res/color/data_usage_graph_track.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 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.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="0.2" android:color="?android:attr/colorForeground" />
|
||||
</selector>
|
||||
18
packages/SystemUI/res/color/data_usage_graph_warning.xml
Normal file
18
packages/SystemUI/res/color/data_usage_graph_warning.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 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.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?android:attr/colorForeground" />
|
||||
</selector>
|
||||
@@ -31,15 +31,11 @@
|
||||
<color name="batterymeter_bolt_color">#FFFFFFFF</color>
|
||||
<color name="qs_batterymeter_frame_color">#FF404040</color>
|
||||
<color name="system_warning_color">@*android:color/system_error</color>
|
||||
<color name="qs_text">#FFFFFFFF</color>
|
||||
<color name="qs_tile_divider">#29ffffff</color><!-- 16% white -->
|
||||
<color name="qs_subhead">#99FFFFFF</color><!-- 60% white -->
|
||||
<color name="qs_detail_button">@*android:color/quaternary_device_default_settings</color>
|
||||
<color name="qs_detail_button_white">#B3FFFFFF</color><!-- 70% white -->
|
||||
<color name="qs_detail_transition">#66FFFFFF</color>
|
||||
<color name="data_usage_secondary">#99FFFFFF</color><!-- 60% white -->
|
||||
<color name="data_usage_graph_track">#33FFFFFF</color><!-- 20% white -->
|
||||
<color name="data_usage_graph_warning">#FFFFFFFF</color>
|
||||
<color name="status_bar_clock_color">#FFFFFFFF</color>
|
||||
<color name="qs_user_detail_icon_muted">#FFFFFFFF</color> <!-- not so muted after all -->
|
||||
<color name="qs_tile_disabled_color">#9E9E9E</color> <!-- 38% black -->
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.DataUsage.Secondary">
|
||||
<item name="android:textColor">@color/data_usage_secondary</item>
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.TileLabel">
|
||||
|
||||
@@ -45,10 +45,10 @@ public class DataUsageGraph extends View {
|
||||
public DataUsageGraph(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
final Resources res = context.getResources();
|
||||
mTrackColor = context.getColor(R.color.data_usage_graph_track);
|
||||
mTrackColor = Utils.getDefaultColor(context, R.color.data_usage_graph_track);
|
||||
mWarningColor = Utils.getDefaultColor(context, R.color.data_usage_graph_warning);
|
||||
mUsageColor = Utils.getColorAccent(context);
|
||||
mOverlimitColor = context.getColor(R.color.system_warning_color);
|
||||
mWarningColor = context.getColor(R.color.data_usage_graph_warning);
|
||||
mOverlimitColor = Utils.getColorError(context);
|
||||
mMarkerWidth = res.getDimensionPixelSize(R.dimen.data_usage_graph_marker_width);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user