summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-11-07 14:14:55 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-07 14:14:55 -0800
commita0654a3523cecfaa0800086753b8738ce3bc1d35 (patch)
treed27200db013de944ffb8f19fa8e5218971590b7b
parent6c53e555e9358ea41aec28d8098623a35f24e32f (diff)
parent620542254c9b63cd17d2deefb07ffd39d8a54623 (diff)
downloadandroid_packages_apps_Trebuchet-a0654a3523cecfaa0800086753b8738ce3bc1d35.tar.gz
android_packages_apps_Trebuchet-a0654a3523cecfaa0800086753b8738ce3bc1d35.tar.bz2
android_packages_apps_Trebuchet-a0654a3523cecfaa0800086753b8738ce3bc1d35.zip
Merge "Altering touch feedback for qsb assets. (Bug: 5560273)" into ics-mr1
-rw-r--r--res/layout-port/search_bar.xml2
-rw-r--r--res/values/attrs.xml6
-rw-r--r--src/com/android/launcher2/Cling.java6
-rw-r--r--src/com/android/launcher2/HolographicLinearLayout.java31
-rw-r--r--src/com/android/launcher2/HolographicViewHelper.java19
-rw-r--r--src/com/android/launcher2/Utilities.java2
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 @@
<!-- Global search icon -->
<com.android.launcher2.HolographicLinearLayout
style="@style/SearchButton"
+ launcher:sourceImageViewId="@+id/search_button"
android:id="@+id/search_button_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -45,6 +46,7 @@
<!-- Voice search icon -->
<com.android.launcher2.HolographicLinearLayout
style="@style/SearchButton.Voice"
+ launcher:sourceImageViewId="@+id/voice_button"
android:id="@+id/voice_button_container"
android:layout_width="@dimen/search_bar_height"
android:layout_height="match_parent"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 800aeaa5c..5fe1abde0 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -80,6 +80,12 @@
<attr name="strokeWidth" format="float" />
</declare-styleable>
+ <!-- HolographicLinearLayout specific attributes. -->
+ <declare-styleable name="HolographicLinearLayout">
+ <!-- The source view to generate and apply the drawable states to/from -->
+ <attr name="sourceImageViewId" format="integer" />
+ </declare-styleable>
+
<!-- PagedViewIcon specific attributes. These attributes are used to customize
a PagedViewIcon view in XML files. -->
<declare-styleable name="PagedViewIcon">
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;