* @param bitmap Source where to extract from.
*/
public static WallpaperColors fromBitmap(@NonNull Bitmap bitmap) {
- return fromBitmap(bitmap, false /* computeHints */);
- }
-
- /**
- * @hide
- */
- public static WallpaperColors fromBitmap(@NonNull Bitmap bitmap, boolean computeHints) {
if (bitmap == null) {
throw new IllegalArgumentException("Bitmap can't be null");
}
}
}
- int hints = computeHints ? calculateDarkHints(bitmap) : 0;
+ int hints = calculateDarkHints(bitmap);
if (shouldRecycle) {
bitmap.recycle();
import static org.junit.Assert.assertTrue;
import android.app.WallpaperColors;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
assertEquals("OnComputeColors should have been deferred.",
0, eventCountdown.getCount());
}
-
- @Test
- public void testFromDrawableTest_doesntComputeHints() {
- WallpaperColors wallpaperColors = WallpaperColors.fromDrawable(
- new ColorDrawable(Color.BLACK));
- assertEquals("WallpaperColors should not support dark theme.", 0,
- wallpaperColors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_THEME);
-
- wallpaperColors = WallpaperColors.fromDrawable(
- new ColorDrawable(Color.WHITE));
- assertEquals("WallpaperColors should not support dark text.", 0,
- wallpaperColors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_TEXT);
- }
}