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

Change-Id: I34e11e0773c9f8e00e3eab422781094e19a16d3d
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);