summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemePackageHelper.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java
index 0accb55..feb4647 100644
--- a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java
+++ b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java
@@ -24,6 +24,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ThemeInfo;
import android.content.pm.ThemeUtils;
import android.content.res.AssetManager;
+import android.content.res.Configuration;
+import android.content.res.ThemeConfig;
import android.content.res.ThemeManager;
import android.database.Cursor;
import android.provider.ThemesContract;
@@ -350,20 +352,24 @@ public class ThemePackageHelper {
}
private static void reapplyInstalledComponentsForTheme(Context context, String pkgName) {
+ Configuration config = context.getResources().getConfiguration();
+ if (config == null || config.themeConfig == null) return;
+
List<String> reApply = new LinkedList<String>(); // components to re-apply
- Cursor mixnmatch = context.getContentResolver().query(MixnMatchColumns.CONTENT_URI,
- null, null, null, null);
- while (mixnmatch.moveToNext()) {
- String mixnmatchKey = mixnmatch.getString(mixnmatch
- .getColumnIndex(MixnMatchColumns.COL_KEY));
- String component = ThemesContract.MixnMatchColumns
- .mixNMatchKeyToComponent(mixnmatchKey);
- String pkg = mixnmatch.getString(
- mixnmatch.getColumnIndex(MixnMatchColumns.COL_VALUE));
- if (pkgName.equals(pkg)) {
- reApply.add(component);
- }
+ // Other packages such as wallpaper can be changed outside of themes
+ // and are not tracked well by the provider. We only care to apply resources that may crash
+ // the system if they are not reapplied.
+ ThemeConfig themeConfig = config.themeConfig;
+ if (pkgName.equals(themeConfig.getFontPkgName())) {
+ reApply.add(ThemesColumns.MODIFIES_FONTS);
+ }
+ if (pkgName.equals(themeConfig.getIconPackPkgName())) {
+ reApply.add(ThemesColumns.MODIFIES_ICONS);
}
+ if (pkgName.equals(themeConfig.getOverlayPkgName())) {
+ reApply.add(ThemesColumns.MODIFIES_OVERLAYS);
+ }
+
ThemeManager manager = (ThemeManager) context.getSystemService(Context.THEME_SERVICE);
manager.requestThemeChange(pkgName, reApply);
}