summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorDClockaN <davor@losinj.com>2014-10-11 22:35:48 +0200
committerLorDClockaN <davor@losinj.com>2014-10-11 22:35:48 +0200
commit68dd8ac32e3432029cce1349ec897fca3a7882c8 (patch)
tree31f01cae55ce1f22bfa5847d065c0eeb43c36245
parent1cbc5830113a1ca2ad7fc390a1badfa3a34f8fdd (diff)
Revert "Themes: Let ThemeService handle all theme processing [2/3]"kitkat
This reverts commit 3da4d83f005700d6c9890f33ca5d3b2be95b4e69.
-rw-r--r--AndroidManifest.xml3
-rw-r--r--src/org/cyanogenmod/theme/chooser/AppReceiver.java31
-rw-r--r--src/org/cyanogenmod/theme/util/PreferenceUtils.java70
3 files changed, 5 insertions, 99 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0491a98..c2a1996 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -47,9 +47,6 @@
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
<data android:scheme="package" />
</intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.THEME_RESOURCES_CACHED" />
- </intent-filter>
</receiver>
<service android:name="org.cyanogenmod.theme.chooser.NotificationHijackingService"
diff --git a/src/org/cyanogenmod/theme/chooser/AppReceiver.java b/src/org/cyanogenmod/theme/chooser/AppReceiver.java
index 72719d3..f31fdbe 100644
--- a/src/org/cyanogenmod/theme/chooser/AppReceiver.java
+++ b/src/org/cyanogenmod/theme/chooser/AppReceiver.java
@@ -19,14 +19,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.ThemeManager;
import android.net.Uri;
import org.cyanogenmod.theme.util.NotificationHelper;
-import org.cyanogenmod.theme.util.PreferenceUtils;
-
-import java.util.Set;
public class AppReceiver extends BroadcastReceiver {
@@ -38,25 +33,14 @@ public class AppReceiver extends BroadcastReceiver {
boolean isReplacing = intent.getExtras().getBoolean(Intent.EXTRA_REPLACING, false);
if (Intent.ACTION_PACKAGE_ADDED.equals(action) && !isReplacing) {
- if (!isThemeBeingProcessed(context, pkgName)) {
- NotificationHelper.postThemeInstalledNotification(context, pkgName);
- } else {
- // store this package name so we know it's being processed
- PreferenceUtils.addThemeBeingProcessed(context, pkgName);
+ try {
+ if (isTheme(context, pkgName)) {
+ NotificationHelper.postThemeInstalledNotification(context, pkgName);
+ }
+ } catch (NameNotFoundException e) {
}
} else if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) {
NotificationHelper.cancelNotificationForPackage(context, pkgName);
- } else if (Intent.ACTION_THEME_RESOURCES_CACHED.equals(action)) {
- 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);
- }
}
}
@@ -71,9 +55,4 @@ public class AppReceiver extends BroadcastReceiver {
return false;
}
-
- private boolean isThemeBeingProcessed(Context context, String pkgName) {
- ThemeManager tm = (ThemeManager) context.getSystemService(Context.THEME_SERVICE);
- return tm.isThemeBeingProcessed(pkgName);
- }
}
diff --git a/src/org/cyanogenmod/theme/util/PreferenceUtils.java b/src/org/cyanogenmod/theme/util/PreferenceUtils.java
deleted file mode 100644
index 8198970..0000000
--- a/src/org/cyanogenmod/theme/util/PreferenceUtils.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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 org.cyanogenmod.theme.util;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.ThemeUtils;
-import android.content.res.Resources;
-import android.content.res.ThemeConfig;
-import android.text.TextUtils;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class PreferenceUtils {
- public static final String PREF_INSTALLED_THEMES_PROCESSING = "installed_themes_processing";
-
- public static SharedPreferences getSharedPreferences(Context context) {
- if (context == null) return null;
- return context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
- }
-
- 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> updatedThemes = new HashSet<String>();
- Set<String> current = prefs.getStringSet(PREF_INSTALLED_THEMES_PROCESSING, null);
- if (current != null) {
- updatedThemes.addAll(current);
- }
- if (updatedThemes.add(pkgName)) {
- prefs.edit().putStringSet(PREF_INSTALLED_THEMES_PROCESSING, updatedThemes).apply();
- }
- }
- }
-
- 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();
- }
- }
- }
-}