@Test public void isColorDark_forExampleLightColors_returnsFalse() { @ColorInt int middleGray = 0x888888; @ColorInt int offWhite = 0xfaebd7; @ColorInt int lightCyan = 0x8feffb; @ColorInt int lightYellow = 0xfcf4b2; @ColorInt int lightBlue = 0x9cdbff; assertFalse(ViewUtils.isColorDark(middleGray)); assertFalse(ViewUtils.isColorDark(offWhite)); assertFalse(ViewUtils.isColorDark(lightCyan)); assertFalse(ViewUtils.isColorDark(lightYellow)); assertFalse(ViewUtils.isColorDark(lightBlue)); assertFalse(ViewUtils.isColorDark(Color.WHITE)); }
static boolean isColorDark(@ColorInt int color){ double luminescence = 0.299* Color.red(color) + 0.587*Color.green(color) + 0.114* Color.blue(color); double luminescencePercentage = luminescence / 255; return luminescencePercentage <= 0.5; }
ViewUtils { static boolean isColorDark(@ColorInt int color){ double luminescence = 0.299* Color.red(color) + 0.587*Color.green(color) + 0.114* Color.blue(color); double luminescencePercentage = luminescence / 255; return luminescencePercentage <= 0.5; } }
ViewUtils { static boolean isColorDark(@ColorInt int color){ double luminescence = 0.299* Color.red(color) + 0.587*Color.green(color) + 0.114* Color.blue(color); double luminescencePercentage = luminescence / 255; return luminescencePercentage <= 0.5; }  }
ViewUtils { static boolean isColorDark(@ColorInt int color){ double luminescence = 0.299* Color.red(color) + 0.587*Color.green(color) + 0.114* Color.blue(color); double luminescencePercentage = luminescence / 255; return luminescencePercentage <= 0.5; }   }
ViewUtils { static boolean isColorDark(@ColorInt int color){ double luminescence = 0.299* Color.red(color) + 0.587*Color.green(color) + 0.114* Color.blue(color); double luminescencePercentage = luminescence / 255; return luminescencePercentage <= 0.5; }    }