Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea7427c6 authored by chihhangchuang's avatar chihhangchuang
Browse files

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
parent 2c1d7f41
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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);