@Test public void isColorDark_forExampleDarkColors_returnsTrue() { @ColorInt int logoBlue = 0x6772e5; @ColorInt int slate = 0x525f7f; @ColorInt int darkPurple = 0x6b3791; @ColorInt int darkishRed = 0x9e2146; assertTrue(ViewUtils.isColorDark(logoBlue)); assertTrue(ViewUtils.isColorDark(slate)); assertTrue(ViewUtils.isColorDark(darkPurple)); assertTrue(ViewUtils.isColorDark(darkishRed)); assertTrue(ViewUtils.isColorDark(Color.BLACK)); }
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; }    }