From 6d17ea67d7f040941706c3afd71149f05c3b1342 Mon Sep 17 00:00:00 2001 From: Clark Scheff Date: Mon, 19 May 2014 15:33:43 -0700 Subject: Properly handle updating holo theme. Change-Id: I157e597ee53894b1237c05dd2000b1da957b1968 --- .../themes/provider/ThemePackageHelper.java | 31 ++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java index 0ecdcaf..ed1a740 100644 --- a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java +++ b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java @@ -39,6 +39,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import static android.content.res.CustomTheme.HOLO_DEFAULT; + /** * Helper class to populate the provider with info from the theme. */ @@ -155,14 +157,18 @@ public class ThemePackageHelper { } public static void updatePackage(Context context, String pkgName) throws NameNotFoundException { - PackageInfo pi = context.getPackageManager().getPackageInfo(pkgName, 0); - Map capabilities = getCapabilities(context, pkgName); - if (pi.themeInfos != null && pi.themeInfos.length > 0) { - updatePackageInternal(context, pi, capabilities); - } else if (pi.legacyThemeInfos != null && pi.legacyThemeInfos.length > 0) { - updateLegacyPackageInternal(context, pi, capabilities); - } else if (pi.isLegacyIconPackApk) { - updateLegacyIconPackInternal(context, pi, capabilities); + if (HOLO_DEFAULT.equals(pkgName)) { + updateHoloPackageInternal(context); + } else { + PackageInfo pi = context.getPackageManager().getPackageInfo(pkgName, 0); + Map capabilities = getCapabilities(context, pkgName); + if (pi.themeInfos != null && pi.themeInfos.length > 0) { + updatePackageInternal(context, pi, capabilities); + } else if (pi.legacyThemeInfos != null && pi.legacyThemeInfos.length > 0) { + updateLegacyPackageInternal(context, pi, capabilities); + } else if (pi.isLegacyIconPackApk) { + updateLegacyIconPackInternal(context, pi, capabilities); + } } } @@ -186,6 +192,15 @@ public class ThemePackageHelper { context.getContentResolver().update(ThemesColumns.CONTENT_URI, values, where, args); } + private static void updateHoloPackageInternal(Context context) { + ContentValues values = new ContentValues(); + values.put(ThemesColumns.IS_DEFAULT_THEME, + HOLO_DEFAULT == ThemeUtils.getDefaultThemePackageName(context) ? 1 : 0); + String where = ThemesColumns.PKG_NAME + "=?"; + String[] args = { HOLO_DEFAULT }; + context.getContentResolver().update(ThemesColumns.CONTENT_URI, values, where, args); + } + private static void updateLegacyPackageInternal(Context context, PackageInfo pi, Map capabilities) { LegacyThemeInfo info = pi.legacyThemeInfos[0]; -- cgit v1.2.3