Merge "Clipping the task bar against the task view."
This commit is contained in:
@@ -492,6 +492,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
||||
Rect taskRect = getAnimationTaskRect(recentTasks);
|
||||
boolean useThumbnailTransition = !isTopTaskHome &&
|
||||
hasValidTaskRects();
|
||||
boolean hasRecentTasks = !recentTasks.isEmpty();
|
||||
|
||||
if (useThumbnailTransition) {
|
||||
// Try starting with a thumbnail transition
|
||||
@@ -506,14 +507,14 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
||||
// Fall through below to the non-thumbnail transition
|
||||
useThumbnailTransition = false;
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no thumbnail transition, then just use a generic transition
|
||||
if (!useThumbnailTransition) {
|
||||
if (Constants.DebugFlags.App.EnableHomeTransition) {
|
||||
} else {
|
||||
// If there is no thumbnail transition, but is launching from home into recents, then
|
||||
// use a quick home transition and do the animation from home
|
||||
if (hasRecentTasks && Constants.DebugFlags.App.EnableHomeTransition) {
|
||||
ActivityOptions opts = getHomeTransitionActivityOptions();
|
||||
startAlternateRecentsActivity(opts, EXTRA_FROM_HOME);
|
||||
} else {
|
||||
// Otherwise we do the normal fade from an unknown source
|
||||
ActivityOptions opts = getUnknownTransitionActivityOptions();
|
||||
startAlternateRecentsActivity(opts, null);
|
||||
}
|
||||
|
||||
@@ -179,8 +179,13 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
mRecentsView.setBSP(root);
|
||||
}
|
||||
|
||||
// Hide the scrim by default when we enter recents
|
||||
mNavBarScrimView.setVisibility(View.INVISIBLE);
|
||||
if (mConfig.shouldAnimateNavBarScrim()) {
|
||||
// Hide the scrim if we animate into Recents with window transitions
|
||||
mNavBarScrimView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
// Show the scrim if we animate into Recents without window transitions
|
||||
mNavBarScrimView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// Add the default no-recents layout
|
||||
if (stacks.size() == 1 && stacks.get(0).getTaskCount() == 0) {
|
||||
@@ -560,7 +565,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
|
||||
public void onEnterAnimationTriggered() {
|
||||
// Fade in the scrim
|
||||
if (mConfig.hasNavBarScrim()) {
|
||||
if (mConfig.shouldAnimateNavBarScrim() && mConfig.hasNavBarScrim()) {
|
||||
mNavBarScrimView.setVisibility(View.VISIBLE);
|
||||
mNavBarScrimView.setAlpha(0f);
|
||||
mNavBarScrimView.animate().alpha(1f)
|
||||
|
||||
@@ -255,6 +255,11 @@ public class RecentsConfiguration {
|
||||
return searchBarAppWidgetId >= 0;
|
||||
}
|
||||
|
||||
/** Returns whether the nav bar scrim should be animated when shown for the first time. */
|
||||
public boolean shouldAnimateNavBarScrim() {
|
||||
return !launchedFromHome && !launchedFromAppWithScreenshot;
|
||||
}
|
||||
|
||||
/** Returns whether the nav bar scrim should be visible. */
|
||||
public boolean hasNavBarScrim() {
|
||||
return !transposeRecentsLayoutWithOrientation || !isLandscape;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.systemui.recents.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
||||
@@ -73,7 +73,6 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
|
||||
super(context);
|
||||
mConfig = RecentsConfiguration.getInstance();
|
||||
mInflater = LayoutInflater.from(context);
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
/** Sets the callbacks */
|
||||
|
||||
@@ -144,9 +144,6 @@ class TaskBarView extends FrameLayout {
|
||||
setBackgroundColor(mConfig.taskBarViewDefaultBackgroundColor);
|
||||
mActivityDescription.setTextColor(mConfig.taskBarViewDefaultTextColor);
|
||||
}
|
||||
if (animate) {
|
||||
// XXX: Investigate how expensive it will be to create a second bitmap and crossfade
|
||||
}
|
||||
}
|
||||
|
||||
/** Unbinds the bar view from the task */
|
||||
@@ -163,7 +160,7 @@ class TaskBarView extends FrameLayout {
|
||||
}
|
||||
|
||||
/** Animates this task bar as it enters recents */
|
||||
public void animateOnEnterRecents(int delay) {
|
||||
public void animateOnEnterRecents(int delay, Runnable postAnimRunnable) {
|
||||
// Animate the task bar of the first task view
|
||||
setVisibility(View.VISIBLE);
|
||||
setTranslationY(-getMeasuredHeight());
|
||||
@@ -173,11 +170,12 @@ class TaskBarView extends FrameLayout {
|
||||
.setInterpolator(mConfig.fastOutSlowInInterpolator)
|
||||
.setDuration(mConfig.taskBarEnterAnimDuration)
|
||||
.withLayer()
|
||||
.withEndAction(postAnimRunnable)
|
||||
.start();
|
||||
}
|
||||
|
||||
/** Animates this task bar as it exits recents */
|
||||
public void animateOnLaunchingTask(final Runnable r) {
|
||||
public void animateOnLaunchingTask(Runnable preAnimRunnable, final Runnable postAnimRunnable) {
|
||||
// Animate the task bar out of the first task view
|
||||
animate()
|
||||
.translationY(-getMeasuredHeight())
|
||||
@@ -185,10 +183,11 @@ class TaskBarView extends FrameLayout {
|
||||
.setInterpolator(mConfig.fastOutLinearInInterpolator)
|
||||
.setDuration(mConfig.taskBarExitAnimDuration)
|
||||
.withLayer()
|
||||
.withStartAction(preAnimRunnable)
|
||||
.withEndAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
post(r);
|
||||
post(postAnimRunnable);
|
||||
}
|
||||
})
|
||||
.start();
|
||||
|
||||
@@ -175,7 +175,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
|
||||
mStackViewsDirty = true;
|
||||
}
|
||||
|
||||
// XXX: Optimization: Use a mapping of Task -> View
|
||||
/** Finds the child view given a specific task */
|
||||
private TaskView getChildViewForTask(Task t) {
|
||||
int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
|
||||
@@ -17,15 +17,23 @@
|
||||
package com.android.systemui.recents.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import com.android.systemui.recents.model.Task;
|
||||
|
||||
|
||||
/** The task thumbnail view */
|
||||
public class TaskThumbnailView extends ImageView {
|
||||
|
||||
Task mTask;
|
||||
|
||||
// Task bar clipping
|
||||
Rect mClipRect;
|
||||
boolean mClipTaskBar = true;
|
||||
|
||||
public TaskThumbnailView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -43,14 +51,39 @@ public class TaskThumbnailView extends ImageView {
|
||||
setScaleType(ScaleType.FIT_XY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (mClipTaskBar && (mClipRect != null)) {
|
||||
// Apply the clip rect
|
||||
canvas.clipRect(mClipRect);
|
||||
}
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
/** Updates the clip rect based on the given task bar. */
|
||||
void updateTaskBarClip(View taskBar) {
|
||||
// If mClipTaskBar is unset first, then we don't bother setting mTaskBar
|
||||
if (mClipTaskBar) {
|
||||
int top = (int) Math.max(0, taskBar.getTranslationY() +
|
||||
taskBar.getMeasuredHeight() - 1);
|
||||
mClipRect = new Rect(0, top, getMeasuredWidth(), getMeasuredHeight());
|
||||
invalidate(0, 0, taskBar.getMeasuredWidth(), taskBar.getMeasuredHeight() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/** Disables the task bar clipping. */
|
||||
void disableClipTaskBarView() {
|
||||
mClipTaskBar = false;
|
||||
if (mClipRect != null) {
|
||||
invalidate(0, 0, mClipRect.width(), mClipRect.top);
|
||||
}
|
||||
}
|
||||
|
||||
/** Binds the thumbnail view to the task */
|
||||
void rebindToTask(Task t, boolean animate) {
|
||||
mTask = t;
|
||||
if (t.thumbnail != null) {
|
||||
setImageBitmap(t.thumbnail);
|
||||
if (animate) {
|
||||
// XXX: Investigate how expensive it will be to create a second bitmap and crossfade
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import com.android.systemui.R;
|
||||
@@ -76,6 +75,18 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
|
||||
updateDimOverlayFromScale();
|
||||
}
|
||||
};
|
||||
Runnable mEnableThumbnailClip = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mThumbnailView.updateTaskBarClip(mBarView);
|
||||
}
|
||||
};
|
||||
Runnable mDisableThumbnailClip = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mThumbnailView.disableClipTaskBarView();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public TaskView(Context context) {
|
||||
@@ -105,8 +116,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
|
||||
mClipViewInStack = true;
|
||||
|
||||
// Bind the views
|
||||
mThumbnailView = (TaskThumbnailView) findViewById(R.id.task_view_thumbnail);
|
||||
mBarView = (TaskBarView) findViewById(R.id.task_view_bar);
|
||||
mThumbnailView = (TaskThumbnailView) findViewById(R.id.task_view_thumbnail);
|
||||
|
||||
if (mTaskDataLoaded) {
|
||||
onTaskDataLoaded(false);
|
||||
@@ -276,7 +287,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
|
||||
@Override
|
||||
public void run() {
|
||||
// Animate the task bar of the first task view
|
||||
mBarView.animateOnEnterRecents(0);
|
||||
mBarView.animateOnEnterRecents(0, mEnableThumbnailClip);
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
@@ -290,19 +301,23 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
|
||||
.setInterpolator(mConfig.linearOutSlowInInterpolator)
|
||||
.setDuration(475)
|
||||
.withLayer()
|
||||
.withEndAction(mEnableThumbnailClip)
|
||||
.start();
|
||||
}
|
||||
|
||||
} else if (mConfig.launchedFromAppWithThumbnail) {
|
||||
if (ctx.isFrontMost) {
|
||||
// Animate the task bar of the first task view
|
||||
mBarView.animateOnEnterRecents(mConfig.taskBarEnterAnimDelay);
|
||||
mBarView.animateOnEnterRecents(mConfig.taskBarEnterAnimDelay, mEnableThumbnailClip);
|
||||
|
||||
// Animate the dim into view as well
|
||||
ObjectAnimator anim = ObjectAnimator.ofInt(this, "dim", getDimOverlayFromScale());
|
||||
anim.setStartDelay(mConfig.taskBarEnterAnimDelay);
|
||||
anim.setDuration(mConfig.taskBarEnterAnimDuration);
|
||||
anim.setInterpolator(mConfig.fastOutLinearInInterpolator);
|
||||
anim.start();
|
||||
} else {
|
||||
mEnableThumbnailClip.run();
|
||||
}
|
||||
|
||||
} else if (mConfig.launchedFromHome) {
|
||||
@@ -318,6 +333,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
|
||||
.setInterpolator(mConfig.quintOutInterpolator)
|
||||
.setDuration(mConfig.taskViewEnterFromHomeDuration)
|
||||
.withLayer()
|
||||
.withEndAction(mEnableThumbnailClip)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
@@ -347,7 +363,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
|
||||
|
||||
/** Animates this task view as it exits recents */
|
||||
public void animateOnLaunchingTask(final Runnable r) {
|
||||
mBarView.animateOnLaunchingTask(r);
|
||||
// Disable the thumbnail clip and animate the bar out
|
||||
mBarView.animateOnLaunchingTask(mDisableThumbnailClip, r);
|
||||
|
||||
// Animate the dim
|
||||
if (mDim > 0) {
|
||||
|
||||
Reference in New Issue
Block a user