public class NotificationColorUtil extends Object
Modifier and Type | Method and Description |
---|---|
static int |
ensureLargeTextContrast(int color,
int bg)
Finds a text color with sufficient contrast over bg that has the same hue as the original
color, assuming it is for large text.
|
static int |
ensureTextBackgroundColor(int color,
int textColor,
int hintColor)
Finds a background color for a text view with given text color and hint text color, that
has the same hue as the original color.
|
static NotificationColorUtil |
getInstance(Context context) |
CharSequence |
invertCharSequenceColors(CharSequence charSequence)
Inverts all the grayscale colors set by
TextAppearanceSpan s on
the text. |
boolean |
isGrayscaleIcon(Bitmap bitmap)
Checks whether a Bitmap is a small grayscale icon.
|
boolean |
isGrayscaleIcon(Context context,
Icon icon) |
boolean |
isGrayscaleIcon(Context context,
int drawableResId)
Checks whether a drawable with a resoure id is a small grayscale icon.
|
boolean |
isGrayscaleIcon(Drawable d)
Checks whether a Drawable is a small grayscale icon.
|
static int |
lightenColor(int baseColor,
int amount)
Lighten a color by a specified value
|
static int |
resolveColor(Context context,
int color)
Resolves to an actual color if it is
Notification.COLOR_DEFAULT |
static int |
resolveContrastColor(Context context,
int notificationColor)
Resolves a Notification's color such that it has enough contrast to be used as the
color for the Notification's action and header text.
|
public static NotificationColorUtil getInstance(Context context)
public boolean isGrayscaleIcon(Bitmap bitmap)
bitmap
- The bitmap to test.public boolean isGrayscaleIcon(Drawable d)
d
- The drawable to test.public boolean isGrayscaleIcon(Context context, int drawableResId)
context
- The context to load the drawable from.public CharSequence invertCharSequenceColors(CharSequence charSequence)
TextAppearanceSpan
s on
the text.charSequence
- The text to process.public static int ensureLargeTextContrast(int color, int bg)
public static int ensureTextBackgroundColor(int color, int textColor, int hintColor)
public static int resolveColor(Context context, int color)
Notification.COLOR_DEFAULT
public static int resolveContrastColor(Context context, int notificationColor)
notificationColor
- the color of the notification or Notification.COLOR_DEFAULT
public static int lightenColor(int baseColor, int amount)
baseColor
- the base color to lightenamount
- the amount to lighten the color from 0 to 100. This corresponds to the L
increase in the LAB color space.