Java Code Examples for androidx.palette.graphics.Palette#getLightMutedColor()

The following examples show how to use androidx.palette.graphics.Palette#getLightMutedColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaletteExtraction.java    From StoryView with MIT License 5 votes vote down vote up
@Override
public void onPostExecute(Palette aPalette) {
    super.onPostExecute(aPalette);

    View view = viewWeakReference.get();
    if (view == null) return;

    GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{aPalette.getDarkVibrantColor(0), aPalette.getLightMutedColor(0)});
    drawable.setCornerRadius(0f);
    view.setBackground(drawable);
}
 
Example 2
Source File: AppSyncWorker.java    From zephyr with MIT License 5 votes vote down vote up
@ColorInt
private int getAppColor(@NonNull Palette palette, @ColorInt int defaultColor) {
    if (palette.getDarkVibrantSwatch() != null) {
        return palette.getDarkVibrantColor(defaultColor);
    }

    if (palette.getVibrantSwatch() != null) {
        return palette.getVibrantColor(defaultColor);
    }

    if (palette.getMutedSwatch() != null) {
        return palette.getMutedColor(defaultColor);
    }

    if (palette.getDarkMutedSwatch() != null) {
        return palette.getDarkMutedColor(defaultColor);
    }

    if (palette.getLightMutedSwatch() != null) {
        return palette.getLightMutedColor(defaultColor);
    }

    if (palette.getLightVibrantSwatch() != null) {
        return palette.getLightVibrantColor(defaultColor);
    }

    return defaultColor;
}
 
Example 3
Source File: SlideFragment.java    From gallery-app-android with MIT License 5 votes vote down vote up
@Override public void onGenerated(Palette palette) {
  hasPalette = true;
  target = null;
  int black = getResources().getColor(android.R.color.black);
  int white = getResources().getColor(android.R.color.white);
  colorDarkMuted = palette.getDarkMutedColor(black);
  colorVibrant = palette.getVibrantColor(white);
  colorLightMuted = palette.getLightMutedColor(white);
  applyColor();
  sendPalette();
}
 
Example 4
Source File: ChannelActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
private Target getLightThemeTarget() {
	return new Target() {
		@Override
		public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
			streamerImage.setImageBitmap(bitmap);

			Palette palette = 		Palette.from(bitmap).generate();
			int defaultColor = 		Service.getColorAttribute(R.attr.colorPrimary, R.color.primary, getBaseContext());
			int defaultDarkColor = 	Service.getColorAttribute(R.attr.colorPrimaryDark, R.color.primaryDark, getBaseContext());

			int vibrant = 		palette.getVibrantColor(defaultColor);
			int vibrantDark = 	palette.getDarkVibrantColor(defaultColor);
			int vibrantLight = 	palette.getLightVibrantColor(defaultColor);

			int muted = 	 palette.getMutedColor(defaultColor);
			int mutedDark =  palette.getDarkMutedColor(defaultColor);
			int mutedLight = palette.getLightMutedColor(defaultColor);

			Palette.Swatch swatch = null;

			if (vibrant != defaultColor) {
				swatch = palette.getVibrantSwatch();
			} else if (vibrantDark != defaultColor) {
				swatch = palette.getDarkVibrantSwatch();
			} else if (vibrantLight != defaultColor){
				swatch = palette.getLightVibrantSwatch();
			} else if (muted != defaultColor) {
				swatch = palette.getMutedSwatch();
			} else if (mutedDark != defaultColor) {
				swatch = palette.getDarkMutedSwatch();
			} else {
				swatch = palette.getLightMutedSwatch();
			}

			if (swatch != null) {
				float[] swatchValues = swatch.getHsl();
				float[] newSwatch = {swatchValues[0], (float) 0.85, (float) 0.85};
				float[] newSwatchComposite = {(swatchValues[0] + 180) % 360, newSwatch[1], newSwatch[2]};
				float[] newSwatchDark = {newSwatch[0], newSwatch[1], (float) 0.6};

				int newColorDark = Color.HSVToColor(newSwatchDark);
				int newColor = Color.HSVToColor(newSwatch);
				int compositeNewColor = Color.HSVToColor(newSwatchComposite);

				int primaryColor = Service.getBackgroundColorFromView(toolbar, defaultColor);
				int primaryColorDark = Service.getBackgroundColorFromView(mTabs, defaultDarkColor);

				Service.animateBackgroundColorChange(toolbar, newColor, primaryColor, COLOR_FADE_DURATION);
				Service.animateBackgroundColorChange(additionalToolbar, newColor, primaryColor, COLOR_FADE_DURATION);
				Service.animateBackgroundColorChange(mTabs, newColorDark, primaryColorDark, COLOR_FADE_DURATION);
				mFab.setBackgroundTintList(ColorStateList.valueOf(compositeNewColor));
				mTabs.setSelectedTabIndicatorColor(compositeNewColor);

				if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
					Window window = getWindow();
					window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
					window.setStatusBarColor(newColorDark);
				}
			}
		}

		@Override
		public void onBitmapFailed(Drawable errorDrawable) {}

		@Override
		public void onPrepareLoad(Drawable placeHolderDrawable) {}
	};
}