summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Scheff <clark@cyngn.com>2014-06-13 14:09:27 -0700
committerClark Scheff <clark@cyngn.com>2014-06-13 16:25:27 -0700
commitb52694e4fdd3c8ee524b5f6f870697e40061b2a6 (patch)
treea49070ca09d3456cbed669403121732946dc1aca
parent64718d775ce8322915d143adb9a0f1ea3160e9e3 (diff)
downloadandroid_packages_apps_Trebuchet-b52694e4fdd3c8ee524b5f6f870697e40061b2a6.tar.gz
android_packages_apps_Trebuchet-b52694e4fdd3c8ee524b5f6f870697e40061b2a6.tar.bz2
android_packages_apps_Trebuchet-b52694e4fdd3c8ee524b5f6f870697e40061b2a6.zip
Use theme change categories and clear widget preview cache
Change-Id: If10fa3fa407891b91322c7e982742eb1dfab2b93
-rw-r--r--AndroidManifest.xml3
-rw-r--r--src/com/android/launcher3/ThemeChangedReceiver.java40
2 files changed, 21 insertions, 22 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5898071d3..c5fdf05df 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -200,6 +200,9 @@
<receiver android:name="com.android.launcher3.ThemeChangedReceiver" >
<intent-filter>
<action android:name="org.cyanogenmod.intent.action.THEME_CHANGED"/>
+ <category android:name="org.cyanogenmod.intent.category.MODS_ICONS"/>
+ <category android:name="org.cyanogenmod.intent.category.MODS_OVERLAYS"/>
+ <category android:name="org.cyanogenmod.intent.category.MODS_FONTS"/>
</intent-filter>
</receiver>
diff --git a/src/com/android/launcher3/ThemeChangedReceiver.java b/src/com/android/launcher3/ThemeChangedReceiver.java
index 134a28559..19c2e226d 100644
--- a/src/com/android/launcher3/ThemeChangedReceiver.java
+++ b/src/com/android/launcher3/ThemeChangedReceiver.java
@@ -19,34 +19,30 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-public class ThemeChangedReceiver extends BroadcastReceiver {
- private static final String EXTRA_COMPONENTS = "components";
+import java.io.File;
- public static final String MODIFIES_ICONS = "mods_icons";
- public static final String MODIFIES_FONTS = "mods_fonts";
- public static final String MODIFIES_OVERLAYS = "mods_overlays";
+import static com.android.launcher3.WidgetPreviewLoader.CacheDb.DB_NAME;
+public class ThemeChangedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
- // components is a '|' delimited string of the components that changed
- // due to a theme change.
- String components = intent.getStringExtra(EXTRA_COMPONENTS);
- if (components != null) {
- LauncherAppState.setApplicationContext(context.getApplicationContext());
- LauncherAppState app = LauncherAppState.getInstance();
- if (isInterestingThemeChange(components)) {
- app.getIconCache().flush();
- app.getModel().forceReload();
- }
- }
+ LauncherAppState app = LauncherAppState.getInstance();
+ clearWidgetPreviewCache(context);
+ app.recreateWidgetPreviewDb();
+ app.getIconCache().flush();
+ app.getModel().forceReload();
}
/**
- * We consider this an "interesting" theme change if it modifies icons, overlays, or fonts.
- * @param components
- * @return
+ * Normally we could use context.deleteDatabase() but this db is in cache/ so we'll
+ * manually delete it and the journal ourselves.
+ * @param context
*/
- private boolean isInterestingThemeChange(String components) {
- return components.contains(MODIFIES_ICONS) || components.contains(MODIFIES_FONTS) ||
- components.contains(MODIFIES_OVERLAYS);
+ private void clearWidgetPreviewCache(Context context) {
+ File[] files = context.getCacheDir().listFiles();
+ if (files != null) {
+ for (File f : files) {
+ if (!f.isDirectory() && f.getName().startsWith(DB_NAME)) f.delete();
+ }
+ }
}
}