summaryrefslogtreecommitdiffstats
path: root/src/com/cyngn
diff options
context:
space:
mode:
authorClark Scheff <clark@cyngn.com>2014-11-19 11:35:17 -0800
committerGerrit Code Review <gerrit@cyngn.com>2014-11-20 16:11:43 +0000
commita4d0390b36adc5089b1819712de7c6d7b78ac54f (patch)
tree354485f3a688d2c17007cb2c95b2b3e0cf8b80b9 /src/com/cyngn
parent6c1f0f1a4c8fbc8a947c7536cdefa39a98f0229f (diff)
downloadpackages_apps_ThemeChooser-a4d0390b36adc5089b1819712de7c6d7b78ac54f.zip
packages_apps_ThemeChooser-a4d0390b36adc5089b1819712de7c6d7b78ac54f.tar.gz
packages_apps_ThemeChooser-a4d0390b36adc5089b1819712de7c6d7b78ac54f.tar.bz2
Fix theme installed notification not showing up
Change-Id: I80a2a9002544be3a2336820f5c2f8b470713ddd2 REF: THEMES-428
Diffstat (limited to 'src/com/cyngn')
-rw-r--r--src/com/cyngn/theme/chooser/AppReceiver.java19
-rw-r--r--src/com/cyngn/theme/util/PreferenceUtils.java35
2 files changed, 8 insertions, 46 deletions
diff --git a/src/com/cyngn/theme/chooser/AppReceiver.java b/src/com/cyngn/theme/chooser/AppReceiver.java
index 920dc4d..024496c 100644
--- a/src/com/cyngn/theme/chooser/AppReceiver.java
+++ b/src/com/cyngn/theme/chooser/AppReceiver.java
@@ -16,8 +16,6 @@ import android.text.TextUtils;
import com.cyngn.theme.util.NotificationHelper;
import com.cyngn.theme.util.PreferenceUtils;
-import java.util.Set;
-
public class AppReceiver extends BroadcastReceiver {
@Override
@@ -30,11 +28,11 @@ public class AppReceiver extends BroadcastReceiver {
if (Intent.ACTION_PACKAGE_ADDED.equals(action) && !isReplacing) {
try {
if (isTheme(context, pkgName)) {
+ // If the theme is not being processed, show the notification. If the
+ // theme is being processed we will handle that once the
+ // Intent.ACTION_THEME_RESOURCES_CACHED is received.
if (!isThemeBeingProcessed(context, pkgName)) {
NotificationHelper.postThemeInstalledNotification(context, pkgName);
- } else {
- // store this package name so we know it's being processed
- PreferenceUtils.addThemeBeingProcessed(context, pkgName);
}
}
} catch (NameNotFoundException e) {
@@ -62,12 +60,11 @@ public class AppReceiver extends BroadcastReceiver {
final String themePkgName = intent.getStringExtra(Intent.EXTRA_THEME_PACKAGE_NAME);
final int result = intent.getIntExtra(Intent.EXTRA_THEME_RESULT,
PackageManager.INSTALL_FAILED_THEME_UNKNOWN_ERROR);
- Set<String> processingThemes =
- PreferenceUtils.getInstalledThemesBeingProcessed(context);
- if (processingThemes != null &&
- processingThemes.contains(themePkgName) && result >= 0) {
- NotificationHelper.postThemeInstalledNotification(context, themePkgName);
- PreferenceUtils.removeThemeBeingProcessed(context, themePkgName);
+ try {
+ if (result >= 0 && isTheme(context, themePkgName)) {
+ NotificationHelper.postThemeInstalledNotification(context, themePkgName);
+ }
+ } catch (NameNotFoundException e) {
}
}
}
diff --git a/src/com/cyngn/theme/util/PreferenceUtils.java b/src/com/cyngn/theme/util/PreferenceUtils.java
index 5e81a9a..58a1561 100644
--- a/src/com/cyngn/theme/util/PreferenceUtils.java
+++ b/src/com/cyngn/theme/util/PreferenceUtils.java
@@ -81,41 +81,6 @@ public class PreferenceUtils {
}
}
- public static Set<String> getInstalledThemesBeingProcessed(Context context) {
- SharedPreferences prefs = getSharedPreferences(context);
- if (prefs == null) return null;
-
- return prefs.getStringSet(PREF_INSTALLED_THEMES_PROCESSING, null);
- }
-
- public static void addThemeBeingProcessed(Context context, String pkgName) {
- SharedPreferences prefs = getSharedPreferences(context);
- if (prefs != null) {
- Set<String> current = prefs.getStringSet(PREF_INSTALLED_THEMES_PROCESSING, null);
- if (current != null && current.add(pkgName)) {
- prefs.edit().putStringSet(PREF_INSTALLED_THEMES_PROCESSING, current).apply();
- }
- } else {
- Log.w(TAG, "addThemeBeingProcessed: Unable to get shared preferences");
- }
- }
-
- public static void removeThemeBeingProcessed(Context context, String pkgName) {
- SharedPreferences prefs = getSharedPreferences(context);
- if (prefs != null) {
- Set<String> updatedThemes = new HashSet<String>();
- Set<String> current = prefs.getStringSet(PREF_INSTALLED_THEMES_PROCESSING, null);
- if (current != null) {
- updatedThemes.addAll(current);
- }
- if (updatedThemes.remove(pkgName)) {
- prefs.edit().putStringSet(PREF_INSTALLED_THEMES_PROCESSING, updatedThemes).apply();
- }
- } else {
- Log.w(TAG, "removeThemeBeingProcessed: Unable to get shared preferences");
- }
- }
-
public static boolean hasThemeBeenUpdated(Context context, String pkgName) {
Set<String> updatedThemes = getUpdatedThemes(context);
return updatedThemes != null && updatedThemes.contains(pkgName);