diff options
author | chihhangchuang <chihhangchuang@google.com> | 2020-06-01 23:11:07 +0800 |
---|---|---|
committer | chihhangchuang <chihhangchuang@google.com> | 2020-06-01 23:11:07 +0800 |
commit | ea7427c63214a34d1687ff5526ef7ffc88c5eccf (patch) | |
tree | ac44fc8e251b058521e0e99edf7e0dac4cb07dce /src/com/android/customization/model/theme | |
parent | 2c1d7f41e1ce40007f4a970cab6c9fad3938c678 (diff) | |
download | ThemePicker-ea7427c63214a34d1687ff5526ef7ffc88c5eccf.tar.gz |
Fix create duplicated custom bug
It's existing in old picker, not a regression. See analysis: b/157723282#comment3
Video of fixing, create same theme as custom1: https://drive.google.com/file/d/1m7RvAIs-EY8Um5BHUfRHSK2yzpHfozFF/view?usp=sharing
Test: Manually
Fixes: 157723282
Change-Id: I6dfbc7655e5de563b49b92fad075e185f2a92017
Diffstat (limited to 'src/com/android/customization/model/theme')
-rw-r--r-- | src/com/android/customization/model/theme/ThemeBundle.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/customization/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java index 8cb2865c..43b07ff5 100644 --- a/src/com/android/customization/model/theme/ThemeBundle.java +++ b/src/com/android/customization/model/theme/ThemeBundle.java @@ -62,6 +62,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** * Represents a Theme component available in the system as a "persona" bundle. @@ -87,7 +88,7 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { mTitle = title; mIsDefault = isDefault; mPreviewInfo = previewInfo; - mPackagesByCategory = Collections.unmodifiableMap(overlayPackages); + mPackagesByCategory = Collections.unmodifiableMap(removeNullValues(overlayPackages)); } @Override @@ -214,6 +215,13 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> { } } + private Map<String, String> removeNullValues(Map<String, String> map) { + return map.entrySet() + .stream() + .filter(entry -> entry.getValue() != null) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + protected CharSequence getContentDescription(Context context) { if (mContentDescription == null) { CharSequence defaultName = context.getString(R.string.default_theme_title); |