summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Scheff <clark@cyngn.com>2014-08-25 11:27:55 -0700
committerAbhisek Devkota <ciwrl@cyanogenmod.com>2014-08-27 00:30:15 +0000
commit21df88b3e47c6ce768ae2f414c2eaf56b39da7ce (patch)
treeb7c5f131ec7f6541e9b5e1f09b7accb908cf35a3
parentf926c30cd3c9284163c64c08f31a52e190eb53fb (diff)
downloadandroid_packages_apps_Trebuchet-21df88b3e47c6ce768ae2f414c2eaf56b39da7ce.tar.gz
android_packages_apps_Trebuchet-21df88b3e47c6ce768ae2f414c2eaf56b39da7ce.tar.bz2
android_packages_apps_Trebuchet-21df88b3e47c6ce768ae2f414c2eaf56b39da7ce.zip
Revert "Use theme change categories and clear widget preview cache"
This reverts commit b52694e4fdd3c8ee524b5f6f870697e40061b2a6. Change-Id: I69bff363280ea69ee83dea3a8f2ef2d0d95a7be0
-rw-r--r--AndroidManifest.xml3
-rw-r--r--src/com/android/launcher3/ThemeChangedReceiver.java40
2 files changed, 22 insertions, 21 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fcf3baf8f..0dd98d68b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -197,9 +197,6 @@
<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 19c2e226d..134a28559 100644
--- a/src/com/android/launcher3/ThemeChangedReceiver.java
+++ b/src/com/android/launcher3/ThemeChangedReceiver.java
@@ -19,30 +19,34 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import java.io.File;
+public class ThemeChangedReceiver extends BroadcastReceiver {
+ private static final String EXTRA_COMPONENTS = "components";
-import static com.android.launcher3.WidgetPreviewLoader.CacheDb.DB_NAME;
+ public static final String MODIFIES_ICONS = "mods_icons";
+ public static final String MODIFIES_FONTS = "mods_fonts";
+ public static final String MODIFIES_OVERLAYS = "mods_overlays";
-public class ThemeChangedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
- LauncherAppState app = LauncherAppState.getInstance();
- clearWidgetPreviewCache(context);
- app.recreateWidgetPreviewDb();
- app.getIconCache().flush();
- app.getModel().forceReload();
+ // 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();
+ }
+ }
}
/**
- * Normally we could use context.deleteDatabase() but this db is in cache/ so we'll
- * manually delete it and the journal ourselves.
- * @param context
+ * We consider this an "interesting" theme change if it modifies icons, overlays, or fonts.
+ * @param components
+ * @return
*/
- 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();
- }
- }
+ private boolean isInterestingThemeChange(String components) {
+ return components.contains(MODIFIES_ICONS) || components.contains(MODIFIES_FONTS) ||
+ components.contains(MODIFIES_OVERLAYS);
}
}