From 620542254c9b63cd17d2deefb07ffd39d8a54623 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 3 Nov 2011 13:12:50 -0700 Subject: Altering touch feedback for qsb assets. (Bug: 5560273) - Removing some dead code Change-Id: If6f3ffcf28249ca08c23089acb5bcd501b455119 --- res/layout-port/search_bar.xml | 2 ++ res/values/attrs.xml | 6 +++++ src/com/android/launcher2/Cling.java | 6 ----- .../android/launcher2/HolographicLinearLayout.java | 31 +++++++++++++++++++++- .../android/launcher2/HolographicViewHelper.java | 19 ++++++------- src/com/android/launcher2/Utilities.java | 2 -- 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/res/layout-port/search_bar.xml b/res/layout-port/search_bar.xml index 5c20ec08e..09c6e0986 100644 --- a/res/layout-port/search_bar.xml +++ b/res/layout-port/search_bar.xml @@ -24,6 +24,7 @@ + + + + + + diff --git a/src/com/android/launcher2/Cling.java b/src/com/android/launcher2/Cling.java index 9f2758679..32b1de4ed 100644 --- a/src/com/android/launcher2/Cling.java +++ b/src/com/android/launcher2/Cling.java @@ -28,7 +28,6 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.view.View; import android.widget.FrameLayout; import com.android.launcher.R; @@ -54,8 +53,6 @@ public class Cling extends FrameLayout { private Drawable mHandTouchGraphic; private int mPunchThroughGraphicCenterRadius; private int mAppIconSize; - private int mTabBarHeight; - private int mTabBarHorizontalPadding; private int mButtonBarHeight; private float mRevealRadius; private int[] mPositionData; @@ -89,9 +86,6 @@ public class Cling extends FrameLayout { r.getDimensionPixelSize(R.dimen.clingPunchThroughGraphicCenterRadius); mAppIconSize = r.getDimensionPixelSize(R.dimen.app_icon_size); mRevealRadius = mAppIconSize * 1f; - mTabBarHeight = r.getDimensionPixelSize(R.dimen.apps_customize_tab_bar_height); - mTabBarHorizontalPadding = - r.getDimensionPixelSize(R.dimen.toolbar_button_horizontal_padding); mButtonBarHeight = r.getDimensionPixelSize(R.dimen.button_bar_height); mErasePaint = new Paint(); diff --git a/src/com/android/launcher2/HolographicLinearLayout.java b/src/com/android/launcher2/HolographicLinearLayout.java index 986a063e5..c6a8d6aff 100644 --- a/src/com/android/launcher2/HolographicLinearLayout.java +++ b/src/com/android/launcher2/HolographicLinearLayout.java @@ -17,13 +17,21 @@ package com.android.launcher2; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.StateListDrawable; import android.util.AttributeSet; +import android.widget.ImageView; import android.widget.LinearLayout; +import com.android.launcher.R; + public class HolographicLinearLayout extends LinearLayout { private final HolographicViewHelper mHolographicHelper; + private ImageView mImageView; + private int mImageViewId; public HolographicLinearLayout(Context context) { this(context, null); @@ -36,16 +44,37 @@ public class HolographicLinearLayout extends LinearLayout { public HolographicLinearLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HolographicLinearLayout, + defStyle, 0); + mImageViewId = a.getResourceId(R.styleable.HolographicLinearLayout_sourceImageViewId, -1); + a.recycle(); + setWillNotDraw(false); mHolographicHelper = new HolographicViewHelper(context); } + @Override + protected void drawableStateChanged() { + super.drawableStateChanged(); + + if (mImageView != null) { + Drawable d = mImageView.getDrawable(); + if (d instanceof StateListDrawable) { + StateListDrawable sld = (StateListDrawable) d; + sld.setState(getDrawableState()); + } + } + } + @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // One time call to generate the pressed/focused state -- must be called after // measure/layout - mHolographicHelper.generatePressedFocusedStates(this); + if (mImageView == null) { + mImageView = (ImageView) findViewById(mImageViewId); + } + mHolographicHelper.generatePressedFocusedStates(mImageView); } } diff --git a/src/com/android/launcher2/HolographicViewHelper.java b/src/com/android/launcher2/HolographicViewHelper.java index c68a5eaad..11e81b4d3 100644 --- a/src/com/android/launcher2/HolographicViewHelper.java +++ b/src/com/android/launcher2/HolographicViewHelper.java @@ -20,12 +20,12 @@ import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.PorterDuff; import android.graphics.drawable.StateListDrawable; -import android.view.View; +import android.widget.ImageView; public class HolographicViewHelper { - private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper(); private final Canvas mTempCanvas = new Canvas(); private boolean mStatesUpdated; @@ -39,16 +39,17 @@ public class HolographicViewHelper { /** * Generate the pressed/focused states if necessary. */ - void generatePressedFocusedStates(View v) { - if (!mStatesUpdated) { + void generatePressedFocusedStates(ImageView v) { + if (!mStatesUpdated && v != null) { mStatesUpdated = true; - Bitmap outline = createGlowingOutline(v, mTempCanvas, mHighlightColor, mHighlightColor); + Bitmap outline = createGlowingOutline(v, mTempCanvas); FastBitmapDrawable d = new FastBitmapDrawable(outline); StateListDrawable states = new StateListDrawable(); states.addState(new int[] {android.R.attr.state_pressed}, d); states.addState(new int[] {android.R.attr.state_focused}, d); - v.setBackgroundDrawable(states); + states.addState(new int[] {}, v.getDrawable()); + v.setImageDrawable(states); } } @@ -56,16 +57,16 @@ public class HolographicViewHelper { * Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location. * Responsibility for the bitmap is transferred to the caller. */ - private Bitmap createGlowingOutline(View v, Canvas canvas, int outlineColor, int glowColor) { + private Bitmap createGlowingOutline(ImageView v, Canvas canvas) { final int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS; final Bitmap b = Bitmap.createBitmap( v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888); canvas.setBitmap(b); canvas.save(); - v.draw(canvas); + v.getDrawable().draw(canvas); canvas.restore(); - mOutlineHelper.applyOuterBlur(b, canvas, outlineColor); + canvas.drawColor(mHighlightColor, PorterDuff.Mode.SRC_IN); canvas.setBitmap(null); return b; diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java index e5169a206..d7562a947 100644 --- a/src/com/android/launcher2/Utilities.java +++ b/src/com/android/launcher2/Utilities.java @@ -43,8 +43,6 @@ import com.android.launcher.R; final class Utilities { private static final String TAG = "Launcher.Utilities"; - private static final boolean TEXT_BURN = false; - private static int sIconWidth = -1; private static int sIconHeight = -1; private static int sIconTextureWidth = -1; -- cgit v1.2.3