summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhisek Devkota <ciwrl@cyanogenmod.com>2014-06-13 01:04:08 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2014-06-13 01:04:08 +0000
commitc4b39dbe53d258029a9d3f77d78121a0eca8ab4d (patch)
tree3275f72e9bf0f7947973d8d886f9d82268baa268
parent44d180199b36f1ff17edbc7c0c68c0a0298f78f4 (diff)
parent64718d775ce8322915d143adb9a0f1ea3160e9e3 (diff)
downloadandroid_packages_apps_Trebuchet-c4b39dbe53d258029a9d3f77d78121a0eca8ab4d.tar.gz
android_packages_apps_Trebuchet-c4b39dbe53d258029a9d3f77d78121a0eca8ab4d.tar.bz2
android_packages_apps_Trebuchet-c4b39dbe53d258029a9d3f77d78121a0eca8ab4d.zip
Merge "Handle theme changes" into cm-11.0
-rw-r--r--AndroidManifest.xml6
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/ThemeChangedReceiver.java52
3 files changed, 59 insertions, 1 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b2c577ee1..0d04558c4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -191,6 +191,12 @@
</intent-filter>
</receiver>
+ <receiver android:name="com.android.launcher3.ThemeChangedReceiver" >
+ <intent-filter>
+ <action android:name="org.cyanogenmod.intent.action.THEME_CHANGED"/>
+ </intent-filter>
+ </receiver>
+
<!-- The settings provider contains Home's data, like the workspace favorites -->
<provider
android:name="com.android.launcher3.LauncherProvider"
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d30cde45b..ea6333479 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -541,7 +541,7 @@ public class Launcher extends Activity
R.bool.preferences_interface_homescreen_search_screen_left_default);
}
- private void initializeDynamicGrid() {
+ void initializeDynamicGrid() {
LauncherAppState.setApplicationContext(getApplicationContext());
LauncherAppState app = LauncherAppState.getInstance();
diff --git a/src/com/android/launcher3/ThemeChangedReceiver.java b/src/com/android/launcher3/ThemeChangedReceiver.java
new file mode 100644
index 000000000..134a28559
--- /dev/null
+++ b/src/com/android/launcher3/ThemeChangedReceiver.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2014 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+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) {
+ // 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();
+ }
+ }
+ }
+
+ /**
+ * We consider this an "interesting" theme change if it modifies icons, overlays, or fonts.
+ * @param components
+ * @return
+ */
+ private boolean isInterestingThemeChange(String components) {
+ return components.contains(MODIFIES_ICONS) || components.contains(MODIFIES_FONTS) ||
+ components.contains(MODIFIES_OVERLAYS);
+ }
+}