summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2014-11-22 11:22:50 -0800
committerd34d <clark@cyngn.com>2014-11-22 11:28:09 -0800
commitf6cf65b7da5e3cfd04e052672dc5116b5c219a7d (patch)
treef4e0ec0879e690918fa815495af7ca73edcb815b /src
parent64fcb6101d9f28618e039797b70e20a42fd2b597 (diff)
downloadpackages_apps_ThemeChooser-f6cf65b7da5e3cfd04e052672dc5116b5c219a7d.zip
packages_apps_ThemeChooser-f6cf65b7da5e3cfd04e052672dc5116b5c219a7d.tar.gz
packages_apps_ThemeChooser-f6cf65b7da5e3cfd04e052672dc5116b5c219a7d.tar.bz2
Revert "Fix theme installed notification not showing up"
This reverts commit a4d0390b36adc5089b1819712de7c6d7b78ac54f. We ned to keep track of themes that are installed and being processed by the theme service. Themes are processed on boot and can cause false positives if we assume receiving this broadcast constitutes a theme being installed. The root cause for not showing install notifications was due to the Set being null when the preference for themes being processed does not exist. We correct this by create a new Set if it is null. Change-Id: I1e762abb6248b282f076a1cf014fc7864f6ce0a3
Diffstat (limited to 'src')
-rw-r--r--src/com/cyngn/theme/chooser/AppReceiver.java19
-rw-r--r--src/com/cyngn/theme/util/PreferenceUtils.java36
2 files changed, 47 insertions, 8 deletions
diff --git a/src/com/cyngn/theme/chooser/AppReceiver.java b/src/com/cyngn/theme/chooser/AppReceiver.java
index 024496c..920dc4d 100644
--- a/src/com/cyngn/theme/chooser/AppReceiver.java
+++ b/src/com/cyngn/theme/chooser/AppReceiver.java
@@ -16,6 +16,8 @@ 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
@@ -28,11 +30,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) {
@@ -60,11 +62,12 @@ 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);
- try {
- if (result >= 0 && isTheme(context, themePkgName)) {
- NotificationHelper.postThemeInstalledNotification(context, themePkgName);
- }
- } catch (NameNotFoundException e) {
+ Set<String> processingThemes =
+ PreferenceUtils.getInstalledThemesBeingProcessed(context);
+ if (processingThemes != null &&
+ processingThemes.contains(themePkgName) && result >= 0) {
+ NotificationHelper.postThemeInstalledNotification(context, themePkgName);
+ PreferenceUtils.removeThemeBeingProcessed(context, themePkgName);
}
}
}
diff --git a/src/com/cyngn/theme/util/PreferenceUtils.java b/src/com/cyngn/theme/util/PreferenceUtils.java
index 58a1561..b5d1af4 100644
--- a/src/com/cyngn/theme/util/PreferenceUtils.java
+++ b/src/com/cyngn/theme/util/PreferenceUtils.java
@@ -81,6 +81,42 @@ 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 = new HashSet<String>(1);
+ if (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);