From 5756a992657acab8b3b990f1c3fd911f50f9f0e5 Mon Sep 17 00:00:00 2001 From: d34d Date: Fri, 15 Jan 2016 10:10:14 -0800 Subject: Fix blank WiFi and signal icon previews The icons used in SystemUI for the wifi and cell signal now use color attributes for defining the fill and background colors. These previews were showing up as blank because no theme/style was applied to the resources and the system was unable to resolve the fill and background colors due to missing attributes. This patch loads in the style needed to get the proper colors for the icon previews Change-Id: Id5da421333c2def3a75e42824a298ee90759a18d TICKET: CYNGNOS-1609 --- .../provider/util/SystemUiPreviewGenerator.java | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/org/cyanogenmod/themes/provider/util/SystemUiPreviewGenerator.java b/src/org/cyanogenmod/themes/provider/util/SystemUiPreviewGenerator.java index d53ad2f..9b5df5e 100644 --- a/src/org/cyanogenmod/themes/provider/util/SystemUiPreviewGenerator.java +++ b/src/org/cyanogenmod/themes/provider/util/SystemUiPreviewGenerator.java @@ -48,6 +48,9 @@ public class SystemUiPreviewGenerator { private static final String IC_SYSBAR_RECENT = "ic_sysbar_recent"; private static final String STATUS_BAR_ICON_SIZE = "status_bar_icon_size"; + // Style used for tinting of wifi and signal icons + private static final String DUAL_TONE_LIGHT_THEME = "DualToneLightTheme"; + private Context mContext; public SystemUiPreviewGenerator(Context context) { @@ -61,29 +64,42 @@ public class SystemUiPreviewGenerator { * @throws NameNotFoundException */ public SystemUiItems generateSystemUiItems(String pkgName) throws NameNotFoundException { - PackageManager pm = mContext.getPackageManager(); - Resources res = pm.getThemedResourcesForApplication(SYSTEMUI_PACKAGE, pkgName); + final PackageManager pm = mContext.getPackageManager(); + final Context themeContext = mContext.createApplicationContext( + pm.getApplicationInfo(SYSTEMUI_PACKAGE, 0), pkgName, 0); + final Resources res = themeContext.getResources(); + // Set the theme for use when tinting the signal icons + themeContext.setTheme(res.getIdentifier(DUAL_TONE_LIGHT_THEME, "style", SYSTEMUI_PACKAGE)); + int iconSize = res.getDimensionPixelSize(res.getIdentifier(STATUS_BAR_ICON_SIZE, "dimen", SYSTEMUI_PACKAGE)); - SystemUiItems items = new SystemUiItems(); - Drawable d = res.getDrawable(res.getIdentifier(BLUETOOTH_DRAWABLE, "drawable", + + // Generate bluetooth icon + Drawable d = themeContext.getDrawable(res.getIdentifier(BLUETOOTH_DRAWABLE, "drawable", SYSTEMUI_PACKAGE)); items.bluetoothIcon = renderDrawableToBitmap(d, iconSize); - d = res.getDrawable(res.getIdentifier(WIFI_DRAWABLE, "drawable", SYSTEMUI_PACKAGE)); + // Generate wifi icon + d = themeContext.getDrawable(res.getIdentifier(WIFI_DRAWABLE, "drawable", + SYSTEMUI_PACKAGE)); items.wifiIcon = renderDrawableToBitmap(d, iconSize); - d = res.getDrawable(res.getIdentifier(SIGNAL_DRAWABLE, "drawable", SYSTEMUI_PACKAGE)); + // Generate cell signal icon + d = themeContext.getDrawable(res.getIdentifier(SIGNAL_DRAWABLE, "drawable", + SYSTEMUI_PACKAGE)); items.signalIcon = renderDrawableToBitmap(d, iconSize); - items.clockColor = res.getColor(res.getIdentifier(STATUS_BAR_CLOCK_COLOR, "color", + // Retrieve the color used for the clock + items.clockColor = themeContext.getColor(res.getIdentifier(STATUS_BAR_CLOCK_COLOR, "color", SYSTEMUI_PACKAGE)); + // wifi margin no longer used in systemui items.wifiMarginEnd = 0; generateBatteryPreviews(res, items); generateBackgroundPreviews(res, items); + // Generate navigation bar icons items.navbarBack = BitmapFactory.decodeResource(res, res.getIdentifier(IC_SYSBAR_BACK, "drawable", SYSTEMUI_PACKAGE)); items.navbarHome = BitmapFactory.decodeResource(res, res.getIdentifier(IC_SYSBAR_HOME, -- cgit v1.2.3