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

Change-Id: I34e11e0773c9f8e00e3eab422781094e19a16d3d
diff --git a/res/color/lock_pattern_view_success_color.xml b/res/color/lock_pattern_view_success_color.xml
new file mode 100644
index 0000000..075e919
--- /dev/null
+++ b/res/color/lock_pattern_view_success_color.xml
@@ -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>
diff --git a/res/color/unlock_pattern_view_success_color.xml b/res/color/unlock_pattern_view_success_color.xml
new file mode 100644
index 0000000..075e919
--- /dev/null
+++ b/res/color/unlock_pattern_view_success_color.xml
@@ -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>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 83449f9..97ba2ed 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -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>
 
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8ea359d..a1a596e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -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">
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index b78cd6e..0d21066 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -870,7 +870,7 @@
 
         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()));
diff --git a/src/com/android/settings/applications/AppOpsSummary.java b/src/com/android/settings/applications/AppOpsSummary.java
index 3401c99..382caed 100644
--- a/src/com/android/settings/applications/AppOpsSummary.java
+++ b/src/com/android/settings/applications/AppOpsSummary.java
@@ -18,6 +18,7 @@
 
 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 @@
         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.
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index f40bfdc..555d18c 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -34,6 +34,7 @@
 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 @@
         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.
diff --git a/src/com/android/settings/applications/ProcessStatsUi.java b/src/com/android/settings/applications/ProcessStatsUi.java
index 14e0b90..bf1f666 100644
--- a/src/com/android/settings/applications/ProcessStatsUi.java
+++ b/src/com/android/settings/applications/ProcessStatsUi.java
@@ -474,10 +474,10 @@
                 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.
         /*
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index 13d9655..b71262e 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -449,10 +449,10 @@
         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);
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
index 44198d3..5b06661 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
@@ -91,7 +91,7 @@
                         .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)
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index e436b79..b3a9571 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -157,7 +157,7 @@
                         .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();
 
diff --git a/src/com/android/settings/deviceinfo/StorageItemPreference.java b/src/com/android/settings/deviceinfo/StorageItemPreference.java
index e4f3ff9..87e827e 100644
--- a/src/com/android/settings/deviceinfo/StorageItemPreference.java
+++ b/src/com/android/settings/deviceinfo/StorageItemPreference.java
@@ -39,7 +39,7 @@
         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);
diff --git a/src/com/android/settings/sim/SimBootReceiver.java b/src/com/android/settings/sim/SimBootReceiver.java
index 58e3721..2fe833b 100644
--- a/src/com/android/settings/sim/SimBootReceiver.java
+++ b/src/com/android/settings/sim/SimBootReceiver.java
@@ -136,7 +136,7 @@
         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);