Merge "Using color filter when animating the drop target instead to TransitionDrawable" into ub-launcher3-burnaby
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2011, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<transition xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/ic_launcher_info_normal" />
|
||||
<item android:drawable="@drawable/ic_launcher_info_active" />
|
||||
</transition>
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2007, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<transition xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/ic_launcher_remove_normal" />
|
||||
<item android:drawable="@drawable/ic_launcher_remove_active" />
|
||||
</transition>
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2007, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<transition xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/ic_launcher_uninstall_normal" />
|
||||
<item android:drawable="@drawable/ic_launcher_uninstall_active" />
|
||||
</transition>
|
||||
@@ -20,9 +20,9 @@
|
||||
<resources>
|
||||
<!-- The color tints to apply to the text and drag view when hovering
|
||||
over the delete target or the info target -->
|
||||
<color name="delete_target_hover_tint">#DAC1C1C1</color>
|
||||
<color name="uninstall_target_hover_tint">#DAF0592B</color>
|
||||
<color name="info_target_hover_tint">#DA009688</color>
|
||||
<color name="delete_target_hover_tint">#FFC1C1C1</color>
|
||||
<color name="uninstall_target_hover_tint">#FFF0592B</color>
|
||||
<color name="info_target_hover_tint">#FF009688</color>
|
||||
<color name="cling_scrim_background">#80000000</color>
|
||||
|
||||
<color name="focused_background">#80c6c5c5</color>
|
||||
|
||||
@@ -16,14 +16,20 @@
|
||||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.FloatArrayEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.TransitionDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -55,9 +61,11 @@ public abstract class ButtonDropTarget extends TextView
|
||||
protected int mHoverColor = 0;
|
||||
|
||||
protected ColorStateList mOriginalTextColor;
|
||||
protected TransitionDrawable mDrawable;
|
||||
protected Drawable mDrawable;
|
||||
|
||||
private AnimatorSet mCurrentColorAnim;
|
||||
private ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
|
||||
|
||||
private ObjectAnimator mCurrentColorAnim;
|
||||
|
||||
public ButtonDropTarget(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
@@ -86,8 +94,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
protected void setDrawable(int resId) {
|
||||
// We do not set the drawable in the xml as that inflates two drawables corresponding to
|
||||
// drawableLeft and drawableStart.
|
||||
mDrawable = (TransitionDrawable) getResources().getDrawable(resId);
|
||||
mDrawable.setCrossFadeEnabled(true);
|
||||
mDrawable = getResources().getDrawable(resId);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null);
|
||||
@@ -111,10 +118,13 @@ public abstract class ButtonDropTarget extends TextView
|
||||
public final void onDragEnter(DragObject d) {
|
||||
d.dragView.setColor(mHoverColor);
|
||||
if (Utilities.isLmpOrAbove()) {
|
||||
mDrawable.startTransition(DragView.COLOR_CHANGE_DURATION);
|
||||
animateTextColor(mHoverColor);
|
||||
} else {
|
||||
mDrawable.startTransition(0);
|
||||
if (mCurrentFilter == null) {
|
||||
mCurrentFilter = new ColorMatrix();
|
||||
}
|
||||
DragView.setColorScale(mHoverColor, mCurrentFilter);
|
||||
mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
|
||||
setTextColor(mHoverColor);
|
||||
}
|
||||
}
|
||||
@@ -124,12 +134,11 @@ public abstract class ButtonDropTarget extends TextView
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
protected void resetHoverColor() {
|
||||
protected void resetHoverColor() {
|
||||
if (Utilities.isLmpOrAbove()) {
|
||||
mDrawable.reverseTransition(DragView.COLOR_CHANGE_DURATION);
|
||||
animateTextColor(mOriginalTextColor.getDefaultColor());
|
||||
} else {
|
||||
mDrawable.resetTransition();
|
||||
mDrawable.setColorFilter(null);
|
||||
setTextColor(mOriginalTextColor);
|
||||
}
|
||||
}
|
||||
@@ -139,8 +148,32 @@ public abstract class ButtonDropTarget extends TextView
|
||||
if (mCurrentColorAnim != null) {
|
||||
mCurrentColorAnim.cancel();
|
||||
}
|
||||
mCurrentColorAnim = ObjectAnimator.ofArgb(this, "textColor", targetColor);
|
||||
|
||||
mCurrentColorAnim = new AnimatorSet();
|
||||
mCurrentColorAnim.setDuration(DragView.COLOR_CHANGE_DURATION);
|
||||
|
||||
if (mSrcFilter == null) {
|
||||
mSrcFilter = new ColorMatrix();
|
||||
mDstFilter = new ColorMatrix();
|
||||
mCurrentFilter = new ColorMatrix();
|
||||
}
|
||||
|
||||
DragView.setColorScale(getTextColor(), mSrcFilter);
|
||||
DragView.setColorScale(targetColor, mDstFilter);
|
||||
ValueAnimator anim1 = ValueAnimator.ofObject(
|
||||
new FloatArrayEvaluator(mCurrentFilter.getArray()),
|
||||
mSrcFilter.getArray(), mDstFilter.getArray());
|
||||
anim1.addUpdateListener(new AnimatorUpdateListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
|
||||
invalidate();
|
||||
}
|
||||
});
|
||||
|
||||
mCurrentColorAnim.play(anim1);
|
||||
mCurrentColorAnim.play(ObjectAnimator.ofArgb(this, "textColor", targetColor));
|
||||
mCurrentColorAnim.start();
|
||||
}
|
||||
|
||||
@@ -155,10 +188,10 @@ public abstract class ButtonDropTarget extends TextView
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public final void onDragStart(DragSource source, Object info, int dragAction) {
|
||||
mActive = supportsDrop(source, info);
|
||||
mDrawable.resetTransition();
|
||||
mDrawable.setColorFilter(null);
|
||||
if (mCurrentColorAnim != null) {
|
||||
mCurrentColorAnim.cancel();
|
||||
mCurrentColorAnim = null;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
// Get the hover color
|
||||
mHoverColor = getResources().getColor(R.color.delete_target_hover_tint);
|
||||
|
||||
setDrawable(R.drawable.remove_target_selector);
|
||||
setDrawable(R.drawable.ic_launcher_remove_normal);
|
||||
}
|
||||
|
||||
public static boolean supportsDrop(Object info) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.android.launcher3.util.Thunk;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DragView extends View {
|
||||
public static int COLOR_CHANGE_DURATION = 200;
|
||||
public static int COLOR_CHANGE_DURATION = 120;
|
||||
|
||||
@Thunk static float sDragAlpha = 1f;
|
||||
|
||||
@@ -249,8 +249,7 @@ public class DragView extends View {
|
||||
m1.setSaturation(0);
|
||||
|
||||
ColorMatrix m2 = new ColorMatrix();
|
||||
m2.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
|
||||
Color.blue(color) / 255f, Color.alpha(color) / 255f);
|
||||
setColorScale(color, m2);
|
||||
m1.postConcat(m2);
|
||||
|
||||
if (Utilities.isLmpOrAbove()) {
|
||||
@@ -355,4 +354,9 @@ public class DragView extends View {
|
||||
mDragLayer.removeView(DragView.this);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setColorScale(int color, ColorMatrix target) {
|
||||
target.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
|
||||
Color.blue(color) / 255f, Color.alpha(color) / 255f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class InfoDropTarget extends ButtonDropTarget {
|
||||
// Get the hover color
|
||||
mHoverColor = getResources().getColor(R.color.info_target_hover_tint);
|
||||
|
||||
setDrawable(R.drawable.info_target_selector);
|
||||
setDrawable(R.drawable.ic_launcher_info_normal);
|
||||
}
|
||||
|
||||
public static void startDetailsActivityForInfo(Object info, Launcher launcher) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
|
||||
// Get the hover color
|
||||
mHoverColor = getResources().getColor(R.color.uninstall_target_hover_tint);
|
||||
|
||||
setDrawable(R.drawable.uninstall_target_selector);
|
||||
setDrawable(R.drawable.ic_launcher_uninstall_normal);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||