Adding shadows to the focus state and fab button. (Bug 16950262)

- Fixing regression where we weren't resetting the dim colors properly.

Change-Id: Ib95cc96d40f80bc22b7ecd7c816d5cbaa9b592c5
This commit is contained in:
Winson Chung
2014-08-18 17:09:45 -07:00
committed by Dan Sandler
parent 1bd805c943
commit f95c7f5727
3 changed files with 68 additions and 24 deletions

View File

@@ -69,6 +69,7 @@
android:layout_gravity="bottom|right"
android:layout_marginRight="15dp"
android:layout_marginBottom="15dp"
android:translationZ="3dp"
android:contentDescription="@string/recents_lock_to_app_button_label"
android:background="@drawable/recents_lock_to_task_button_bg">
<ImageView

View File

@@ -21,12 +21,14 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import com.android.systemui.R;
@@ -129,6 +131,14 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
mHeaderView = (TaskViewHeader) findViewById(R.id.task_view_bar);
mThumbnailView = (TaskViewThumbnail) findViewById(R.id.task_view_thumbnail);
mActionButtonView = findViewById(R.id.lock_to_app_fab);
mActionButtonView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
// Set the outline to match the FAB background
outline.setOval(0, 0, mActionButtonView.getWidth(),
mActionButtonView.getHeight());
}
});
if (mFooterView != null) {
mFooterView.setCallbacks(this);
}
@@ -469,7 +479,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
boolean occludesLaunchTarget) {
if (isLaunchingTask) {
// Disable the thumbnail clip and animate the bar out for the window animation out
mHeaderView.startLaunchTaskAnimation(mThumbnailView.disableTaskBarClipAsRunnable(), r);
mHeaderView.startLaunchTaskAnimation(mThumbnailView.disableTaskBarClipAsRunnable(), r,
mIsFocused);
// Animate the thumbnail alpha back into full opacity for the window animation out
mThumbnailView.startLaunchTaskAnimation();
@@ -624,7 +635,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
public void setDim(int dim) {
mDim = dim;
// Defer setting hardware layers if we have not yet measured, or there is no dim to draw
if (getMeasuredWidth() > 0 && getMeasuredHeight() > 0 && dim > 0) {
if (getMeasuredWidth() > 0 && getMeasuredHeight() > 0) {
if (mDimAnimator != null) {
mDimAnimator.removeAllListeners();
mDimAnimator.cancel();
@@ -828,6 +839,10 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
} else if (v == mHeaderView.mDismissButton) {
dismissTask();
} else {
if (v == mActionButtonView) {
// Reset the translation of the action button before we animate it out
mActionButtonView.setTranslationZ(0f);
}
mCb.onTaskViewClicked(tv, tv.getTask(),
(v == mFooterView || v == mActionButtonView));
}

View File

@@ -18,7 +18,9 @@ package com.android.systemui.recents.views;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -59,7 +61,8 @@ class TaskViewHeader extends FrameLayout {
ColorDrawable mBackgroundColor;
Drawable mLightDismissDrawable;
Drawable mDarkDismissDrawable;
ValueAnimator mBackgroundColorAnimator;
AnimatorSet mFocusAnimator;
ValueAnimator backgroundColorAnimator;
boolean mIsFullscreen;
boolean mCurrentPrimaryColorIsDark;
@@ -117,6 +120,14 @@ class TaskViewHeader extends FrameLayout {
@Override
protected void onFinishInflate() {
// Set the outline provider
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRect(0, 0, getMeasuredWidth(), getMeasuredHeight());
}
});
// Initialize the icon and description views
mApplicationIcon = (ImageView) findViewById(R.id.application_icon);
mActivityDescription = (TextView) findViewById(R.id.activity_description);
@@ -222,7 +233,12 @@ class TaskViewHeader extends FrameLayout {
}
/** Animates this task bar as it exits recents */
void startLaunchTaskAnimation(Runnable preAnimRunnable, final Runnable postAnimRunnable) {
void startLaunchTaskAnimation(Runnable preAnimRunnable, final Runnable postAnimRunnable,
boolean isFocused) {
if (isFocused) {
onTaskViewFocusChanged(false);
}
// Animate the task bar out of the first task view
animate()
.translationY(-getMeasuredHeight())
@@ -278,10 +294,10 @@ class TaskViewHeader extends FrameLayout {
/** Notifies the associated TaskView has been focused. */
void onTaskViewFocusChanged(boolean focused) {
boolean isRunning = false;
if (mBackgroundColorAnimator != null) {
isRunning = mBackgroundColorAnimator.isRunning();
mBackgroundColorAnimator.removeAllUpdateListeners();
mBackgroundColorAnimator.cancel();
if (mFocusAnimator != null) {
isRunning = mFocusAnimator.isRunning();
mFocusAnimator.removeAllListeners();
mFocusAnimator.cancel();
}
if (focused) {
int secondaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark);
@@ -302,42 +318,54 @@ class TaskViewHeader extends FrameLayout {
// Pulse the background color
int currentColor = mBackgroundColor.getColor();
int lightPrimaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark);
mBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), lightPrimaryColor,
currentColor);
mBackgroundColorAnimator.addListener(new AnimatorListenerAdapter() {
ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(),
lightPrimaryColor, currentColor);
backgroundColor.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mBackground.setState(new int[] {});
mBackground.setState(new int[]{});
}
});
mBackgroundColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBackgroundColor.setColor((Integer) animation.getAnimatedValue());
}
});
mBackgroundColorAnimator.setRepeatCount(ValueAnimator.INFINITE);
mBackgroundColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
mBackgroundColorAnimator.setStartDelay(750);
mBackgroundColorAnimator.setDuration(750);
mBackgroundColorAnimator.start();
backgroundColor.setRepeatCount(ValueAnimator.INFINITE);
backgroundColor.setRepeatMode(ValueAnimator.REVERSE);
// Pulse the translation
ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 15f);
translation.setRepeatCount(ValueAnimator.INFINITE);
translation.setRepeatMode(ValueAnimator.REVERSE);
mFocusAnimator = new AnimatorSet();
mFocusAnimator.playTogether(backgroundColor, translation);
mFocusAnimator.setStartDelay(750);
mFocusAnimator.setDuration(750);
mFocusAnimator.start();
} else {
if (isRunning) {
// Restore the background color
int currentColor = mBackgroundColor.getColor();
mBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor,
mCurrentPrimaryColor);
mBackgroundColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(),
currentColor, mCurrentPrimaryColor);
backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBackgroundColor.setColor((Integer) animation.getAnimatedValue());
}
});
mBackgroundColorAnimator.setRepeatCount(0);
mBackgroundColorAnimator.setDuration(150);
mBackgroundColorAnimator.start();
// Restore the translation
ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 0f);
mFocusAnimator = new AnimatorSet();
mFocusAnimator.playTogether(backgroundColor, translation);
mFocusAnimator.setDuration(150);
mFocusAnimator.start();
} else {
mBackground.setState(new int[] {});
setTranslationZ(0f);
}
}
}