From b343731b5d5816bc4be98f289d7198d6210a3f2f Mon Sep 17 00:00:00 2001 From: d34d Date: Tue, 10 Mar 2015 09:50:45 -0700 Subject: Send broadcast when theme chooser opened and theme removed This introduces two new actions that will be broadcasted to the store, or any app that is granted the com.cyngn.themes.permission.THEMES_APP permission, which requires the same signature as the Theme Chooser. If a theme is uninstalled from the chooser, a broadcast is sent along with a String extra with the key "package" that identifies the package name of the theme being removed. Change-Id: I6b3f4e19ebb1b8d763d7e0038591fccbbe1809f2 --- src/com/cyngn/theme/chooser/ChooserActivity.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java index 6a82c70..81ec1e2 100644 --- a/src/com/cyngn/theme/chooser/ChooserActivity.java +++ b/src/com/cyngn/theme/chooser/ChooserActivity.java @@ -87,6 +87,14 @@ public class ChooserActivity extends FragmentActivity private static final String TYPE_IMAGE = "image/*"; + private static final String CYNGN_THEMES_PERMISSION = + "com.cyngn.themes.permission.THEMES_APP"; + private static final String ACTION_CHOOSER_OPENED = + "com.cyngn.themes.action.CHOOSER_OPENED"; + private static final String ACTION_THEME_REMOVED = + "com.cyngn.themes.action.THEME_REMOVED_FROM_CHOOSER"; + private static final String EXTRA_PACKAGE = "package"; + /** * Request code for picking an external wallpaper */ @@ -555,6 +563,7 @@ public class ChooserActivity extends FragmentActivity public void uninstallTheme(String pkgName) { PackageManager pm = getPackageManager(); pm.deletePackage(pkgName, new PackageDeleteObserver(), PackageManager.DELETE_ALL_USERS); + sendThemeRemovedBroadcast(pkgName); } private void slideContentIntoView(int yDelta, int selectorHeight) { @@ -649,6 +658,7 @@ public class ChooserActivity extends FragmentActivity if (mTypefaceHelperCache.getTypefaceCount() <= 0) { new TypefacePreloadTask().execute(); } + sendChooserOpenedBroadcast(); mAnimateContentInDelay = ANIMATE_CONTENT_DELAY; } @@ -675,6 +685,16 @@ public class ChooserActivity extends FragmentActivity } } + private void sendChooserOpenedBroadcast() { + sendBroadcast(new Intent(ACTION_CHOOSER_OPENED), CYNGN_THEMES_PERMISSION); + } + + private void sendThemeRemovedBroadcast(String pkgName) { + Intent intent = new Intent(ACTION_THEME_REMOVED); + intent.putExtra(EXTRA_PACKAGE, pkgName); + sendBroadcast(intent, CYNGN_THEMES_PERMISSION); + } + private void animateContentIn() { Drawable d = mCustomBackground.getDrawable(); if (d instanceof TransitionDrawable) { -- cgit v1.1