summaryrefslogtreecommitdiffstats
path: root/src/com/cyngn
diff options
context:
space:
mode:
authorClark Scheff <clark@cyngn.com>2014-11-21 13:45:17 -0800
committerClark Scheff <clark@cyngn.com>2014-11-21 13:45:17 -0800
commit64fcb6101d9f28618e039797b70e20a42fd2b597 (patch)
tree3cd55ed78e33089fd6f4bef8cfa644675146d938 /src/com/cyngn
parent1766de5efa7775815a701a553a4791cfae415fcf (diff)
downloadpackages_apps_ThemeChooser-64fcb6101d9f28618e039797b70e20a42fd2b597.zip
packages_apps_ThemeChooser-64fcb6101d9f28618e039797b70e20a42fd2b597.tar.gz
packages_apps_ThemeChooser-64fcb6101d9f28618e039797b70e20a42fd2b597.tar.bz2
MyThemeFragment should only be applying changed components
The current logic sends all the comonents to the theme service, even when only one or two components changed in the MyThemeFragment. This patch will create a map of only the components that changed and pass those onto the ThemeService. This patch also fixes the issue with fillMissingComponentsWithDefault which should only be used for applying full themes. Change-Id: Id47e771e58afd6d2f5065820617b0c56cecc2405
Diffstat (limited to 'src/com/cyngn')
-rw-r--r--src/com/cyngn/theme/chooser/MyThemeFragment.java19
-rw-r--r--src/com/cyngn/theme/chooser/ThemeFragment.java15
2 files changed, 24 insertions, 10 deletions
diff --git a/src/com/cyngn/theme/chooser/MyThemeFragment.java b/src/com/cyngn/theme/chooser/MyThemeFragment.java
index a290b5d..3ccb8d2 100644
--- a/src/com/cyngn/theme/chooser/MyThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/MyThemeFragment.java
@@ -42,6 +42,7 @@ import com.cyngn.theme.util.TypefaceHelperCache;
import com.cyngn.theme.util.Utils;
import java.io.IOException;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -374,9 +375,23 @@ public class MyThemeFragment extends ThemeFragment {
@Override
protected Map<String, String> fillMissingComponentsWithDefault(
Map<String, String> originalMap) {
- if (mApplyThemeOnPopulated) return originalMap;
+ // Only the ThemeFragment should be altering this, for the MyThemeFragment this is not
+ // desirable as it changes components the user did not even touch.
+ return originalMap;
+ }
- return super.fillMissingComponentsWithDefault(originalMap);
+ @Override
+ protected Map<String, String> getComponentsToApply() {
+ Map<String, String> componentsToApply = new HashMap<String, String>();
+ // Only apply components that actually changed
+ for (String component : mCurrentTheme.keySet()) {
+ String currentPkg = mCurrentTheme.get(component);
+ String selectedPkg = mSelectedComponentsMap.get(component);
+ if (selectedPkg != null && !currentPkg.equals(selectedPkg)) {
+ componentsToApply.put(component, selectedPkg);
+ }
+ }
+ return componentsToApply;
}
@Override
diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java
index 0b346ac..76b14e2 100644
--- a/src/com/cyngn/theme/chooser/ThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/ThemeFragment.java
@@ -2074,9 +2074,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
mHandler.post(new Runnable() {
@Override
public void run() {
- if (mSelectedComponentsMap != null && mSelectedComponentsMap.size() > 0) {
+ final Map<String, String> componentsToApply = getComponentsToApply();
+ if (componentsToApply != null && componentsToApply.size() > 0) {
final Map<String, String> fullMap
- = fillMissingComponentsWithDefault(mSelectedComponentsMap);
+ = fillMissingComponentsWithDefault(componentsToApply);
ThemeManager tm = getThemeManager();
if (tm != null) {
tm.addClient(ThemeFragment.this);
@@ -2101,18 +2102,16 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
String component = entry.getKey();
String defaultPkg = entry.getValue();
if (!newMap.containsKey(component)) {
- // Don't use default wallpaper or lockscreen wallpaper if an external image
- // is suppose to be used.
- if (ThemesColumns.MODIFIES_LAUNCHER.equals(component) ||
- ThemesColumns.MODIFIES_LOCKSCREEN.equals(component)) {
- continue;
- }
newMap.put(component, defaultPkg);
}
}
return newMap;
}
+ protected Map<String, String> getComponentsToApply() {
+ return mSelectedComponentsMap;
+ }
+
private Runnable mApplyExternalWallpaperRunnable = new Runnable() {
@Override
public void run() {