summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantiago Etchebehere <santie@google.com>2019-05-31 17:39:27 -0700
committerSantiago Etchebehere <santie@google.com>2019-05-31 17:39:27 -0700
commit7eb77bbf12a2e62584caf505bce810e4a5e17824 (patch)
treef078a9630a1e2c1d5245e943afc59f9bfd6a99c6
parentfeb02d4b944087c6ce366768d8f3fa0e52f0d0e3 (diff)
downloadThemePicker-7eb77bbf12a2e62584caf505bce810e4a5e17824.tar.gz
Properly handle default custom theme options
Bug: 134186220 Change-Id: Ib1c6b643275d35a35cf0e5b0a27890f80a8a57ac
-rw-r--r--src/com/android/customization/model/theme/ThemeBundle.java4
-rw-r--r--src/com/android/customization/model/theme/custom/IconOptionsProvider.java7
-rw-r--r--src/com/android/customization/model/theme/custom/ThemeComponentOption.java8
3 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/customization/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java
index 7c543d47..b3258deb 100644
--- a/src/com/android/customization/model/theme/ThemeBundle.java
+++ b/src/com/android/customization/model/theme/ThemeBundle.java
@@ -70,6 +70,7 @@ import java.util.Set;
*/
public class ThemeBundle implements CustomizationOption<ThemeBundle> {
+ private final static String EMPTY_JSON = "{}";
private final String mTitle;
private final PreviewInfo mPreviewInfo;
private final boolean mIsDefault;
@@ -144,7 +145,8 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> {
return false;
}
if (mIsDefault) {
- return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages());
+ return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages())
+ || EMPTY_JSON.equals(other.getSerializedPackages());
}
// Map#equals ensures keys and values are compared.
return mPackagesByCategory.equals(other.mPackagesByCategory);
diff --git a/src/com/android/customization/model/theme/custom/IconOptionsProvider.java b/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
index 73a4a22c..f7b669b1 100644
--- a/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
+++ b/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
@@ -86,7 +86,7 @@ public class IconOptionsProvider extends ThemeComponentOptionProvider<IconOption
}
for (String overlayPackage : mSysUiIconsOverlayPackages) {
- addOrUpdateOption(optionsByPrefix, overlayPackage, OVERLAY_CATEGORY_ICON_SYSUI);
+ addOrUpdateOption(optionsByPrefix, overlayPackage, OVERLAY_CATEGORY_ICON_SYSUI);
}
for (String overlayPackage : mSettingsIconsOverlayPackages) {
@@ -142,6 +142,11 @@ public class IconOptionsProvider extends ThemeComponentOptionProvider<IconOption
} catch (NameNotFoundException | NotFoundException e) {
Log.w(TAG, "Didn't find SystemUi package icons, will skip option", e);
}
+ option.addOverlayPackage(OVERLAY_CATEGORY_ICON_ANDROID, null);
+ option.addOverlayPackage(OVERLAY_CATEGORY_ICON_SYSUI, null);
+ option.addOverlayPackage(OVERLAY_CATEGORY_ICON_SETTINGS, null);
+ option.addOverlayPackage(OVERLAY_CATEGORY_ICON_LAUNCHER, null);
+ option.addOverlayPackage(OVERLAY_CATEGORY_ICON_THEMEPICKER, null);
mOptions.add(option);
}
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index 8966dc56..78131cc9 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -34,7 +34,6 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
-import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -61,7 +60,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Objects;
/**
@@ -92,11 +90,7 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
public abstract void bindPreview(ViewGroup container);
public Builder buildStep(Builder builder) {
- getOverlayPackages().forEach((category, packageName) -> {
- if (!TextUtils.isEmpty(packageName)) {
- builder.addOverlayPackage(category, packageName);
- }
- });
+ getOverlayPackages().forEach(builder::addOverlayPackage);
return builder;
}