summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Mast <andy@cyngn.com>2014-06-24 13:47:17 -0700
committerAndy Mast <andy@cyngn.com>2014-06-30 22:00:45 +0000
commitebf8f37515c23a167cef2bb8cff04854c52fd35b (patch)
tree74c0a8aa932193154abc4e1981c17a6c238582b4
parent5fabfae2b58c7cba517475f2d4465f6d3c4eeb63 (diff)
downloadandroid_packages_apps_Trebuchet-ebf8f37515c23a167cef2bb8cff04854c52fd35b.tar.gz
android_packages_apps_Trebuchet-ebf8f37515c23a167cef2bb8cff04854c52fd35b.tar.bz2
android_packages_apps_Trebuchet-ebf8f37515c23a167cef2bb8cff04854c52fd35b.zip
Use ArrayListExtra for broadcasting theme changes [2/2]
Change-Id: I2931915eba0cde2d66577bcb83ba8521ce034158
-rw-r--r--AndroidManifest.xml3
-rw-r--r--src/com/android/launcher3/ThemeChangedReceiver.java45
2 files changed, 38 insertions, 10 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b26dfcf91..8262f4886 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -189,9 +189,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..c7a98c5ab 100644
--- a/src/com/android/launcher3/ThemeChangedReceiver.java
+++ b/src/com/android/launcher3/ThemeChangedReceiver.java
@@ -19,22 +19,53 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import java.io.File;
-
import static com.android.launcher3.WidgetPreviewLoader.CacheDb.DB_NAME;
+import java.io.File;
+import java.util.ArrayList;
+
public class ThemeChangedReceiver extends BroadcastReceiver {
+ private static final String EXTRA_COMPONENTS = "components";
+
+ 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 void onReceive(Context context, Intent intent) {
- LauncherAppState app = LauncherAppState.getInstance();
- clearWidgetPreviewCache(context);
- app.recreateWidgetPreviewDb();
- app.getIconCache().flush();
- app.getModel().forceReload();
+ // components is a string array of the components that changed
+ ArrayList<String> components = intent.getStringArrayListExtra(EXTRA_COMPONENTS);
+ if (isInterestingThemeChange(components)) {
+ 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
+ */
+ private boolean isInterestingThemeChange(ArrayList<String> components) {
+ if (components != null) {
+ for (String component : components) {
+ if (component.equals(MODIFIES_ICONS) ||
+ component.equals(MODIFIES_FONTS) ||
+ component.equals(MODIFIES_OVERLAYS)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ /**
* 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 void clearWidgetPreviewCache(Context context) {