Merge "Altering touch feedback for qsb assets. (Bug: 5560273)" into ics-mr1
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user