ColourUtils { public static boolean isDark(@ColorInt int colorInt) { return ColorUtils.calculateLuminance(colorInt) < 0.6f; }  static boolean isDark(@ColorInt int colorInt); @ColorInt static int resolveColour(Context context, @AttrRes int attribute);  }
@Test public void isDark() { Context context = ApplicationProvider.getApplicationContext(); assertTrue(ColourUtils.isDark(ContextCompat.getColor(context, android.R.color.black))); assertFalse(ColourUtils.isDark(ContextCompat.getColor(context, android.R.color.white))); }