From c275326e40d9f6bda083a7b6058f0839b21a2d5d Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Tue, 16 Jul 2024 19:06:55 -0700 Subject: [PATCH] Remove unused methods Bug: 353303621 Test: compiles Flag: NONE Removing code Change-Id: Ibfdc983c5d29d8e928e4277dac285d4e62bdc1fd --- .../launcher3/graphics/IconPalette.java | 98 ------------------- 1 file changed, 98 deletions(-) diff --git a/src/com/android/launcher3/graphics/IconPalette.java b/src/com/android/launcher3/graphics/IconPalette.java index 778b32a863..00f1c675da 100644 --- a/src/com/android/launcher3/graphics/IconPalette.java +++ b/src/com/android/launcher3/graphics/IconPalette.java @@ -16,22 +16,15 @@ package com.android.launcher3.graphics; -import android.app.Notification; import android.content.Context; import android.graphics.Color; -import android.util.Log; -import androidx.core.graphics.ColorUtils; - -import com.android.launcher3.R; import com.android.launcher3.util.Themes; /** * Contains colors based on the dominant color of an icon. */ public class IconPalette { - - private static final boolean DEBUG = false; private static final String TAG = "IconPalette"; private static final float MIN_PRELOAD_COLOR_SATURATION = 0.2f; @@ -54,95 +47,4 @@ public class IconPalette { } return result; } - - /** - * Resolves a color such that it has enough contrast to be used as the - * color of an icon or text on the given background color. - * - * @return a color of the same hue with enough contrast against the background. - * - * This was copied from com.android.internal.util.NotificationColorUtil. - */ - public static int resolveContrastColor(Context context, int color, int background) { - final int resolvedColor = resolveColor(context, color); - - int contrastingColor = ensureTextContrast(resolvedColor, background); - - if (contrastingColor != resolvedColor) { - if (DEBUG){ - Log.w(TAG, String.format( - "Enhanced contrast of notification for %s " + - "%s (over background) by changing #%s to %s", - context.getPackageName(), - contrastChange(resolvedColor, contrastingColor, background), - Integer.toHexString(resolvedColor), Integer.toHexString(contrastingColor))); - } - } - return contrastingColor; - } - - /** - * Resolves {@param color} to an actual color if it is {@link Notification#COLOR_DEFAULT} - * - * This was copied from com.android.internal.util.NotificationColorUtil. - */ - private static int resolveColor(Context context, int color) { - if (color == Notification.COLOR_DEFAULT) { - return context.getColor(R.color.notification_icon_default_color); - } - return color; - } - - /** For debugging. This was copied from com.android.internal.util.NotificationColorUtil. */ - private static String contrastChange(int colorOld, int colorNew, int bg) { - return String.format("from %.2f:1 to %.2f:1", - ColorUtils.calculateContrast(colorOld, bg), - ColorUtils.calculateContrast(colorNew, bg)); - } - - /** - * Finds a text color with sufficient contrast over bg that has the same hue as the original - * color. - * - * This was copied from com.android.internal.util.NotificationColorUtil. - */ - private static int ensureTextContrast(int color, int bg) { - return findContrastColor(color, bg, 4.5); - } - /** - * Finds a suitable color such that there's enough contrast. - * - * @param fg the color to start searching from. - * @param bg the color to ensure contrast against. - * @param minRatio the minimum contrast ratio required. - * @return a color with the same hue as {@param color}, potentially darkened to meet the - * contrast ratio. - * - * This was copied from com.android.internal.util.NotificationColorUtil. - */ - private static int findContrastColor(int fg, int bg, double minRatio) { - if (ColorUtils.calculateContrast(fg, bg) >= minRatio) { - return fg; - } - - double[] lab = new double[3]; - ColorUtils.colorToLAB(bg, lab); - double bgL = lab[0]; - ColorUtils.colorToLAB(fg, lab); - double fgL = lab[0]; - boolean isBgDark = bgL < 50; - - double low = isBgDark ? fgL : 0, high = isBgDark ? 100 : fgL; - final double a = lab[1], b = lab[2]; - for (int i = 0; i < 15 && high - low > 0.00001; i++) { - final double l = (low + high) / 2; - fg = ColorUtils.LABToColor(l, a, b); - if (ColorUtils.calculateContrast(fg, bg) > minRatio) { - if (isBgDark) high = l; else low = l; - } else { - if (isBgDark) low = l; else high = l; - } - } - return ColorUtils.LABToColor(low, a, b); - } }