diff --git a/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java b/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java index f3b950b5155fb392a1175fd4a2be992c297b0066..1107329a2e780965c31166c53ae6f84a500b8c76 100644 --- a/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java +++ b/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java @@ -45,7 +45,9 @@ import com.android.customization.model.theme.custom.ThemeComponentOption.ColorOp import com.android.wallpaper.R; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Implementation of {@link ThemeComponentOptionProvider} that reads {@link ColorOption}s from @@ -91,24 +93,35 @@ public class ColorOptionsProvider extends ThemeComponentOptionProvider previewIcons, Drawable shape) { + Map optionMap = new HashMap<>(); + String skippedPackage = "org.lineageos.overlay.accent.black"; for (String overlayPackage : mOverlayPackages) { - try { - Resources overlayRes = getOverlayResources(overlayPackage); - int lightColor = overlayRes.getColor( - overlayRes.getIdentifier(ACCENT_COLOR_LIGHT_NAME, "color", overlayPackage), - null); - int darkColor = overlayRes.getColor( - overlayRes.getIdentifier(ACCENT_COLOR_DARK_NAME, "color", overlayPackage), - null); - PackageManager pm = mContext.getPackageManager(); - String label = pm.getApplicationInfo(overlayPackage, 0).loadLabel(pm).toString(); - ColorOption option = new ColorOption(overlayPackage, label, lightColor, darkColor); - option.setPreviewIcons(previewIcons); - option.setShapeDrawable(shape); - mOptions.add(option); - } catch (NameNotFoundException | NotFoundException e) { - Log.w(TAG, String.format("Couldn't load color overlay %s, will skip it", - overlayPackage), e); + if (!overlayPackage.equalsIgnoreCase(skippedPackage)) { + try { + PackageManager pm = mContext.getPackageManager(); + String label = pm.getApplicationInfo(overlayPackage, 0).loadLabel(pm).toString(); + if (!optionMap.containsKey(label.toLowerCase())) { + Resources overlayRes = getOverlayResources(overlayPackage); + int lightColor = overlayRes.getColor( + overlayRes.getIdentifier(ACCENT_COLOR_LIGHT_NAME, "color", overlayPackage), + null); + int darkColor = overlayRes.getColor( + overlayRes.getIdentifier(ACCENT_COLOR_DARK_NAME, "color", overlayPackage), + null); + ColorOption option = new ColorOption(overlayPackage, label, lightColor, darkColor); + option.setPreviewIcons(previewIcons); + option.setShapeDrawable(shape); + mOptions.add(option); + optionMap.put(label.toLowerCase(), option); + } + } catch (NameNotFoundException | NotFoundException e) { + Log.w(TAG, String.format("Couldn't load color overlay %s, will skip it", + overlayPackage), e); + } } } }