diff options
author | Danesh M <daneshm90@gmail.com> | 2014-06-13 23:28:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2014-06-13 23:28:38 +0000 |
commit | 4520d4cbf5cc57e88c0b9998603f83e2a0cf632b (patch) | |
tree | 1476e45c3aad239b7a22869f65d96686a012240d /src | |
parent | 7fb166a65c92d9cd7d375937321bde723b4b6669 (diff) | |
parent | b52694e4fdd3c8ee524b5f6f870697e40061b2a6 (diff) | |
download | android_packages_apps_Trebuchet-4520d4cbf5cc57e88c0b9998603f83e2a0cf632b.tar.gz android_packages_apps_Trebuchet-4520d4cbf5cc57e88c0b9998603f83e2a0cf632b.tar.bz2 android_packages_apps_Trebuchet-4520d4cbf5cc57e88c0b9998603f83e2a0cf632b.zip |
Merge "Use theme change categories and clear widget preview cache" into cm-11.0
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/ThemeChangedReceiver.java | 40 |
1 files changed, 18 insertions, 22 deletions
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(); + } + } } } |