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

This commit is contained in:
Alan Viverette
2015-03-20 20:07:41 +00:00
committed by Android (Google) Code Review
13 changed files with 73 additions and 25 deletions

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);