summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2014-06-13 22:42:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-11 08:41:11 +0000
commitec464ed728dd334d4866360fa18fc7407d7d1970 (patch)
treedbe4bf85ac4e076a0183c7cc1d48046a1cddabc9 /packages
parent7bb38dbb3c588d14a14f5012a6fd76405e502521 (diff)
parent743d5c95f3a107639c0ff22f099cab2624da3e27 (diff)
downloadframeworks_base-ec464ed728dd334d4866360fa18fc7407d7d1970.zip
frameworks_base-ec464ed728dd334d4866360fa18fc7407d7d1970.tar.gz
frameworks_base-ec464ed728dd334d4866360fa18fc7407d7d1970.tar.bz2
Merge "Clipping the task bar against the task view."
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/Task.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskBarView.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskThumbnailView.java39
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java27
9 files changed, 84 insertions, 24 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index 3e61f87..8dcdcdb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -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);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 05c3252..d66968b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -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)
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index 433dcb4..3b8c6c9 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -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;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index 47a506c..f366ef0 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -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;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index d019037..6f79683 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -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 */
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskBarView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskBarView.java
index aae345b..7f7a435 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskBarView.java
@@ -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();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index b503c36..deac114 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -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++) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskThumbnailView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskThumbnailView.java
index 8a9250a..dc8a420 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskThumbnailView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskThumbnailView.java
@@ -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
- }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index ffd4135..f84d564 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -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) {