Clean up usage of theme colors, deprecated Resources.getColor* methods

Change-Id: I34e11e0773c9f8e00e3eab422781094e19a16d3d
This commit is contained in:
Alan Viverette
2015-03-18 18:10:52 -07:00
parent 9a23adf69d
commit 55eaa96fe4
13 changed files with 73 additions and 25 deletions

View File

@@ -0,0 +1,19 @@
<?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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?android:attr/colorAccent" />
</selector>

View File

@@ -0,0 +1,19 @@
<?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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?android:attr/colorAccent" />
</selector>

View File

@@ -53,11 +53,9 @@
<color name="lock_pattern_background">#00000000</color>
<color name="lock_pattern_view_regular_color">#ff37474f</color>
<color name="lock_pattern_view_success_color">@color/theme_accent</color>
<color name="lock_pattern_view_error_color">#fff4511e</color>
<color name="unlock_pattern_view_regular_color">@android:color/white</color>
<color name="unlock_pattern_view_success_color">@color/theme_accent</color>
<color name="unlock_pattern_view_error_color">#fff4511e</color>
<color name="fingerprint_title_area_bg">#ff009688</color>
@@ -72,11 +70,6 @@
<color name="card_background">#ffffffff</color>
<!-- Palette colors referenced by top-level themes. -->
<color name="theme_primary">#ff263238</color>
<color name="theme_primary_dark">#ff21272b</color>
<color name="theme_accent">#ff009688</color>
<color name="switchbar_background_color">#ff37474f</color>
<color name="switch_accent_color">#ff7fcac3</color>

View File

@@ -335,9 +335,8 @@
<style name="TextAppearance.Switch" parent="TextAppearance.Medium">
</style>
<style name="TextAppearance.CategoryTitle" parent="@android:style/TextAppearance.Material.Small">
<item name="android:textColor">@color/theme_accent</item>
<item name="android:textStyle">bold</item>
<style name="TextAppearance.CategoryTitle" parent="@android:style/TextAppearance.Material.Body2">
<item name="android:textColor">?android:attr/colorAccent</item>
</style>
<style name="TextAppearance.TileTitle" parent="@android:style/TextAppearance.Material.Medium">

View File

@@ -870,7 +870,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
mBinding = false;
int seriesColor = resources.getColor(R.color.sim_noitification);
int seriesColor = context.getColor(R.color.sim_noitification);
if (mCurrentTab != null && mCurrentTab.length() > TAB_MOBILE.length() ){
final int slotId = Integer.parseInt(mCurrentTab.substring(TAB_MOBILE.length(),
mCurrentTab.length()));

View File

@@ -18,6 +18,7 @@ package com.android.settings.applications;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.preference.PreferenceFrameLayout;
import android.support.v13.app.FragmentPagerAdapter;
@@ -103,7 +104,15 @@ public class AppOpsSummary extends Fragment {
mViewPager.setAdapter(adapter);
mViewPager.setOnPageChangeListener(adapter);
PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
tabs.setTabIndicatorColorResource(R.color.theme_accent);
// This should be set in the XML layout, but PagerTabStrip lives in
// support-v4 and doesn't have styleable attributes.
final TypedArray ta = tabs.getContext().obtainStyledAttributes(
new int[] { android.R.attr.colorAccent });
final int colorAccent = ta.getColor(0, 0);
ta.recycle();
tabs.setTabIndicatorColorResource(colorAccent);
// We have to do this now because PreferenceFrameLayout looks at it
// only when the view is added.

View File

@@ -34,6 +34,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.net.NetworkPolicyManager;
import android.net.Uri;
import android.os.AsyncTask;
@@ -924,7 +925,15 @@ public class ManageApplications extends Fragment implements
mViewPager.setAdapter(adapter);
mViewPager.setOnPageChangeListener(adapter);
PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
tabs.setTabIndicatorColorResource(R.color.theme_accent);
// This should be set in the XML layout, but PagerTabStrip lives in
// support-v4 and doesn't have styleable attributes.
final TypedArray ta = tabs.getContext().obtainStyledAttributes(
new int[] { android.R.attr.colorAccent });
final int colorAccent = ta.getColor(0, 0);
ta.recycle();
tabs.setTabIndicatorColorResource(colorAccent);
// We have to do this now because PreferenceFrameLayout looks at it
// only when the view is added.

View File

@@ -474,10 +474,10 @@ public class ProcessStatsUi extends PreferenceFragment
memStates = ProcessStats.ALL_MEM_ADJ;
break;
}
Resources res = getResources();
colors.setColors(res.getColor(R.color.running_processes_apps_ram),
res.getColor(R.color.running_processes_apps_ram),
res.getColor(R.color.running_processes_free_ram));
final Context context = getActivity();
colors.setColors(context.getColor(R.color.running_processes_apps_ram),
context.getColor(R.color.running_processes_apps_ram),
context.getColor(R.color.running_processes_free_ram));
// Compute memory badness for chart color.
/*

View File

@@ -449,10 +449,10 @@ public class RunningProcessesView extends FrameLayout
mHeader = inflater.inflate(R.layout.running_processes_header, null);
mListView.addHeaderView(mHeader, null, false /* set as not selectable */);
mColorBar = (LinearColorBar)mHeader.findViewById(R.id.color_bar);
Resources res = getResources();
mColorBar.setColors(res.getColor(R.color.running_processes_system_ram),
res.getColor(R.color.running_processes_apps_ram),
res.getColor(R.color.running_processes_free_ram));
final Context context = getContext();
mColorBar.setColors(context.getColor(R.color.running_processes_system_ram),
context.getColor(R.color.running_processes_apps_ram),
context.getColor(R.color.running_processes_free_ram));
mBackgroundProcessPrefix = (TextView)mHeader.findViewById(R.id.freeSizePrefix);
mAppsProcessPrefix = (TextView)mHeader.findViewById(R.id.appsSizePrefix);
mForegroundProcessPrefix = (TextView)mHeader.findViewById(R.id.systemSizePrefix);

View File

@@ -91,7 +91,7 @@ public final class BluetoothPairingRequest extends BroadcastReceiver {
.setContentIntent(pending)
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_SOUND)
.setColor(res.getColor(
.setColor(context.getColor(
com.android.internal.R.color.system_notification_accent_color));
NotificationManager manager = (NotificationManager)

View File

@@ -157,7 +157,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
.setContentIntent(PendingIntent.getActivity(context, 0,
connectionAccessIntent, 0))
.setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
.setColor(context.getResources().getColor(
.setColor(context.getColor(
com.android.internal.R.color.system_notification_accent_color))
.build();

View File

@@ -39,7 +39,7 @@ public class StorageItemPreference extends Preference {
super(context);
if (colorRes != 0) {
this.color = context.getResources().getColor(colorRes);
this.color = context.getColor(colorRes);
final Resources res = context.getResources();
final int width = res.getDimensionPixelSize(R.dimen.device_memory_usage_button_width);

View File

@@ -136,7 +136,7 @@ public class SimBootReceiver extends BroadcastReceiver {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
.setColor(resources.getColor(R.color.sim_noitification))
.setColor(context.getColor(R.color.sim_noitification))
.setContentTitle(resources.getString(R.string.sim_notification_title))
.setContentText(resources.getString(R.string.sim_notification_summary));
Intent resultIntent = new Intent(context, SimSettingsActivity.class);