OSDN Git Service

Update Settings to use themed Context.getDrawable()
authorAlan Viverette <alanv@google.com>
Fri, 10 Oct 2014 17:58:58 +0000 (10:58 -0700)
committerAlan Viverette <alanv@google.com>
Fri, 10 Oct 2014 17:58:58 +0000 (10:58 -0700)
Explicit null theme is passed when using Resources.getDrawable() and
no theme is available, e.g. when using getResourcesForApplication().
This fixes an issue with ic_text_dot theming and helps avoid similar
issues in the future.

BUG: 17648301
Change-Id: I3e97c3490b6f2a55744f567b21284f2935ae9af7

16 files changed:
src/com/android/settings/ActivityPicker.java
src/com/android/settings/MasterClear.java
src/com/android/settings/RegulatoryInfoDisplayActivity.java
src/com/android/settings/UserSpinnerAdapter.java
src/com/android/settings/Utils.java
src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
src/com/android/settings/accounts/AuthenticatorHelper.java
src/com/android/settings/accounts/ChooseAccountActivity.java
src/com/android/settings/applications/AppOpsState.java
src/com/android/settings/applications/ApplicationsState.java
src/com/android/settings/applications/RunningState.java
src/com/android/settings/bluetooth/DeviceProfilesSettings.java
src/com/android/settings/fuelgauge/BatteryEntry.java
src/com/android/settings/fuelgauge/PowerUsageDetail.java
src/com/android/settings/net/UidDetailProvider.java
src/com/android/settings/notification/NotificationStation.java

index edbccc3..7c26923 100644 (file)
@@ -159,7 +159,7 @@ public class ActivityPicker extends AlertActivity implements
                     Resources res = packageManager.getResourcesForApplication(
                             iconResource.packageName);
                     icon = res.getDrawable(res.getIdentifier(
-                            iconResource.resourceName, null, null));
+                            iconResource.resourceName, null, null), null);
                 } catch (NameNotFoundException e) {
                     // Ignore
                 }
index bbd98fb..6a0a249 100644 (file)
@@ -212,7 +212,7 @@ public class MasterClear extends Fragment {
             try {
                 if (desc.iconId != 0) {
                     Context authContext = context.createPackageContext(desc.packageName, 0);
-                    icon = authContext.getResources().getDrawable(desc.iconId);
+                    icon = authContext.getDrawable(desc.iconId);
                 }
             } catch (PackageManager.NameNotFoundException e) {
                 Log.w(TAG, "No icon for account type " + desc.type);
index 171059c..c674f13 100644 (file)
@@ -63,7 +63,7 @@ public class RegulatoryInfoDisplayActivity extends Activity implements
         int resId = getResourceId();
         if (resId != 0) {
             try {
-                Drawable d = resources.getDrawable(resId);
+                Drawable d = getDrawable(resId);
                 // set to false if the width or height is <= 2
                 // (missing PNG can return an empty 2x2 pixel Drawable)
                 regulatoryInfoDrawableExists = (d.getIntrinsicWidth() > 2
index 001dfc4..eb4a118 100644 (file)
@@ -51,7 +51,7 @@ public class UserSpinnerAdapter implements SpinnerAdapter {
             UserInfo userInfo = um.getUserInfo(mUserHandle.getIdentifier());
             if (userInfo.isManagedProfile()) {
                 name = context.getString(R.string.managed_user_title);
-                icon = Resources.getSystem().getDrawable(
+                icon = context.getDrawable(
                     com.android.internal.R.drawable.ic_corp_icon);
             } else {
                 name = userInfo.name;
index 04160fb..88536c4 100644 (file)
@@ -211,7 +211,8 @@ public final class Utils {
                         Bundle metaData = resolveInfo.activityInfo.metaData;
 
                         if (res != null && metaData != null) {
-                            icon = res.getDrawable(metaData.getInt(META_DATA_PREFERENCE_ICON));
+                            icon = res.getDrawable(
+                                    metaData.getInt(META_DATA_PREFERENCE_ICON), null);
                             title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
                             summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
                         }
index 9fe224e..f38d482 100644 (file)
@@ -231,7 +231,7 @@ public class ToggleAccessibilityServicePreferenceFragment
 
         ImageView imageView = (ImageView) capabilityView.findViewById(
                 com.android.internal.R.id.perm_icon);
-        imageView.setImageDrawable(getResources().getDrawable(
+        imageView.setImageDrawable(getActivity().getDrawable(
                 com.android.internal.R.drawable.ic_text_dot));
 
         TextView labelView = (TextView) capabilityView.findViewById(
@@ -257,7 +257,7 @@ public class ToggleAccessibilityServicePreferenceFragment
 
             imageView = (ImageView) capabilityView.findViewById(
                     com.android.internal.R.id.perm_icon);
-            imageView.setImageDrawable(getResources().getDrawable(
+            imageView.setImageDrawable(getActivity().getDrawable(
                     com.android.internal.R.drawable.ic_text_dot));
 
             labelView = (TextView) capabilityView.findViewById(
index cc8a6d5..3757d97 100644 (file)
@@ -111,7 +111,7 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
                 Context authContext = context.createPackageContextAsUser(desc.packageName, 0,
                         mUserHandle);
                 icon = mContext.getPackageManager().getUserBadgedIcon(
-                        authContext.getResources().getDrawable(desc.iconId), mUserHandle);
+                        authContext.getDrawable(desc.iconId), mUserHandle);
                 synchronized (mAccTypeIconCache) {
                     mAccTypeIconCache.put(accountType, icon);
                 }
index e52d640..5e7e81e 100644 (file)
@@ -216,7 +216,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
                 AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
                 Context authContext = createPackageContextAsUser(desc.packageName, 0, mUserHandle);
                 icon = getPackageManager().getUserBadgedIcon(
-                        authContext.getResources().getDrawable(desc.iconId), mUserHandle);
+                        authContext.getDrawable(desc.iconId), mUserHandle);
             } catch (PackageManager.NameNotFoundException e) {
                 // TODO: place holder icon for missing account icons?
                 Log.w(TAG, "No icon name for account type " + accountType);
index 580c44e..1ab3c73 100644 (file)
@@ -269,7 +269,7 @@ public class AppOpsState {
                 return mIcon;
             }
 
-            return mState.mContext.getResources().getDrawable(
+            return mState.mContext.getDrawable(
                     android.R.drawable.sym_def_app_icon);
         }
 
index 1c2eb2c..9c51181 100644 (file)
@@ -144,7 +144,7 @@ public class ApplicationsState {
                     return true;
                 } else {
                     this.mounted = false;
-                    this.icon = context.getResources().getDrawable(
+                    this.icon = context.getDrawable(
                             com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
                 }
             } else if (!this.mounted) {
index 1019abc..1d24148 100644 (file)
@@ -679,7 +679,7 @@ public class RunningState {
                     return constState.newDrawable();
                 }
             }
-            return context.getResources().getDrawable(
+            return context.getDrawable(
                     com.android.internal.R.drawable.ic_menu_cc);
         }
     }
index 757535a..0109e35 100755 (executable)
@@ -194,7 +194,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment
 
         int iconResource = profile.getDrawableResource(mCachedDevice.getBtClass());
         if (iconResource != 0) {
-            pref.setIcon(getResources().getDrawable(iconResource));
+            pref.setIcon(getActivity().getDrawable(iconResource));
         }
 
         refreshProfilePreference(pref, profile);
index 4ff4dfd..0dfd5c9 100644 (file)
@@ -189,7 +189,7 @@ public class BatteryEntry {
                 break;
         }
         if (iconId > 0) {
-            icon = context.getResources().getDrawable(iconId);
+            icon = context.getDrawable(iconId);
         }
         if ((name == null || iconId == 0) && this.sipper.uidObj != null) {
             getQuickNameIconForUid(this.sipper.uidObj);
@@ -228,7 +228,7 @@ public class BatteryEntry {
                 name = context.getResources().getString(R.string.process_mediaserver_label);
             }
             iconId = R.drawable.ic_power_system;
-            icon = context.getResources().getDrawable(iconId);
+            icon = context.getDrawable(iconId);
             return;
         } else {
             //name = packages[0];
index 9dca029..e3c8dab 100644 (file)
@@ -379,7 +379,7 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
                 // Use default icon
             }
         } else if (iconId != 0) {
-            mAppIcon = getActivity().getResources().getDrawable(iconId);
+            mAppIcon = getActivity().getDrawable(iconId);
         }
         if (mAppIcon == null) {
             mAppIcon = getActivity().getPackageManager().getDefaultActivityIcon();
index 4b54137..b6160fd 100644 (file)
@@ -138,7 +138,7 @@ public class UidDetailProvider {
             if (info != null) {
                 if (info.isManagedProfile()) {
                     detail.label = res.getString(R.string.managed_user_title);
-                    detail.icon = Resources.getSystem().getDrawable(
+                    detail.icon = mContext.getDrawable(
                             com.android.internal.R.drawable.ic_corp_icon);
                 } else {
                     detail.label = res.getString(R.string.running_process_item_user_label,
index c61f91e..3f4d3df 100644 (file)
@@ -275,7 +275,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
         }
 
         try {
-            return r.getDrawable(resId);
+            return r.getDrawable(resId, null);
         } catch (RuntimeException e) {
             Log.w(TAG, "Icon not found in "
                     + (pkg != null ? resId : "<system>")