From 32e9492d3d5d0fae297af88865cfc3cfc22e27c1 Mon Sep 17 00:00:00 2001 From: linus_lee Date: Tue, 2 Sep 2014 18:57:39 -0700 Subject: Eleven: Add blurring behind the now playing and the queue fragments and fixes a few bugs In addition to blurring, hide non-english headers, and fix the gripper colors Change-Id: I6899a5d1d3bb8c6c7711652a618b1bdc47abcb1f --- src/com/cyngn/eleven/widgets/BlurScrimImage.java | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/com/cyngn/eleven/widgets/BlurScrimImage.java (limited to 'src/com/cyngn/eleven/widgets') diff --git a/src/com/cyngn/eleven/widgets/BlurScrimImage.java b/src/com/cyngn/eleven/widgets/BlurScrimImage.java new file mode 100644 index 0000000..e9be8f9 --- /dev/null +++ b/src/com/cyngn/eleven/widgets/BlurScrimImage.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2014 Cyanogen, Inc. + */ +package com.cyngn.eleven.widgets; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.TransitionDrawable; +import android.util.AttributeSet; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import com.cyngn.eleven.R; +import com.cyngn.eleven.cache.ImageFetcher; +import com.cyngn.eleven.cache.ImageWorker; + +public class BlurScrimImage extends FrameLayout { + private ImageView mImageView; + + public BlurScrimImage(Context context, AttributeSet attrs) { + super(context, attrs); + } + + + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + mImageView = (ImageView)findViewById(R.id.blurImage); + } + + public ImageView getImageView() { + return mImageView; + } + + /** + * Transitions the image to the default state (default blur artwork) + */ + public void transitionToDefaultState() { + Bitmap blurredBitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.default_artwork_blur)).getBitmap(); + + TransitionDrawable imageTransition = ImageWorker.createImageTransitionDrawable(getResources(), + mImageView.getDrawable(), blurredBitmap, ImageWorker.FADE_IN_TIME_SLOW, true, true); + + TransitionDrawable paletteTransition = ImageWorker.createPaletteTransition(this, + Color.TRANSPARENT); + + + setTransitionDrawable(imageTransition, paletteTransition); + } + + /** + * Sets the transition drawable + * @param imageTransition the transition for the imageview + * @param paletteTransition the transition for the scrim overlay + */ + public void setTransitionDrawable(TransitionDrawable imageTransition, + TransitionDrawable paletteTransition) { + setBackground(paletteTransition); + mImageView.setImageDrawable(imageTransition); + } + + /** + * Loads the current artwork into this BlurScrimImage + * @param imageFetcher an ImageFetcher instance + */ + public void loadBlurImage(ImageFetcher imageFetcher) { + imageFetcher.loadCurrentBlurredArtwork(this); + } +} -- cgit v1.2.3