/** * Test is a color is lighter than {@code this} * * @param other A color * @return {@code true} if {@code other} is lighter than {@code this}, else {@code false} */ public boolean isLighter(int other) { return getLuminance() > ColorUtils.calculateLuminance(other); }
/** * Convert this color into a Hue, Saturation, Value human readable string * * @return A string */ public String toHSVString() { return ColorUtils.toHsvString(mColor); }
/** * Test is a color is darker than {@code this} * * @param other A color * @return {@code true} if {@code other} is darker than {@code this}, else {@code false} */ public boolean isDarker(int other) { return getLuminance() < ColorUtils.calculateLuminance(other); }
@Override public String toString() { return ColorUtils.toARGBString(mColor); }
@Override public double getLuminance() { return ColorUtils.calculateLuminance(mColor); }
/** * @param brightBackground {@code true} if the background is bright, else {@code false} * @return A foreground text color to fit the background */ public static int getDisabledTextColor(boolean brightBackground) { int color = brightBackground ? Color.BLACK : Color.WHITE; int alpha = brightBackground ? TEXT_ALPHA_DISABLED_DARK : TEXT_ALPHA_DISABLED_LIGHT; return ColorUtils.setAlphaComponent(color, alpha); }
/** * @param brightBackground {@code true} if the background is bright, else {@code false} * @return A foreground text color to fit the background */ public static int getSecondaryTextColor(boolean brightBackground) { int color = brightBackground ? Color.BLACK : Color.WHITE; int alpha = brightBackground ? TEXT_ALPHA_SECONDARY_DARK : TEXT_ALPHA_SECONDARY_LIGHT; return ColorUtils.setAlphaComponent(color, alpha); }