Re-enabling task based filtering in Recents using package name.

- Also front-loading creating the new thumbnail when animating up from Recents
This commit is contained in:
Winson Chung
2014-06-17 17:56:17 -07:00
parent 06795630f6
commit e0e45bc26d
8 changed files with 86 additions and 53 deletions

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 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.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight" />

View File

@@ -34,7 +34,8 @@
android:layout_height="@dimen/recents_task_view_application_icon_size"
android:layout_marginStart="8dp"
android:layout_gravity="center_vertical|start"
android:padding="8dp" />
android:padding="8dp"
android:background="@drawable/recents_button_bg" />
<TextView
android:id="@+id/activity_description"
android:layout_width="match_parent"
@@ -57,6 +58,7 @@
android:layout_marginEnd="4dp"
android:layout_gravity="center_vertical|end"
android:padding="18dp"
android:background="@drawable/recents_button_bg"
android:visibility="invisible"
android:src="@drawable/recents_dismiss_light" />
</com.android.systemui.recents.views.TaskBarView>

View File

@@ -111,9 +111,9 @@
<!-- The duration in seconds to wait before the dismiss buttons are shown. -->
<integer name="recents_task_bar_dismiss_delay_seconds">3</integer>
<!-- The min animation duration for animating views that are currently visible. -->
<integer name="recents_filter_animate_current_views_min_duration">175</integer>
<integer name="recents_filter_animate_current_views_duration">250</integer>
<!-- The min animation duration for animating views that are newly visible. -->
<integer name="recents_filter_animate_new_views_min_duration">125</integer>
<integer name="recents_filter_animate_new_views_duration">250</integer>
<!-- The min animation duration for animating the task bar in. -->
<integer name="recents_animate_task_bar_enter_duration">275</integer>
<!-- The animation delay for animating the first task in. This should roughly be the animation

View File

@@ -30,7 +30,7 @@ public class Constants {
// Enables the screenshot app->Recents transition
public static final boolean EnableScreenshotAppTransition = false;
// Enables the filtering of tasks according to their grouping
public static final boolean EnableTaskFiltering = false;
public static final boolean EnableTaskFiltering = true;
// Enables clipping of tasks against each other
public static final boolean EnableTaskStackClipping = true;
// Enables the use of theme colors as the task bar background

View File

@@ -47,8 +47,8 @@ public class RecentsConfiguration {
public Interpolator quintOutInterpolator;
/** Filtering */
public int filteringCurrentViewsMinAnimDuration;
public int filteringNewViewsMinAnimDuration;
public int filteringCurrentViewsAnimDuration;
public int filteringNewViewsAnimDuration;
/** Insets */
public Rect systemInsets = new Rect();
@@ -151,10 +151,10 @@ public class RecentsConfiguration {
res.getDimensionPixelSize(R.dimen.recents_animation_movement_in_dps_per_second);
// Filtering
filteringCurrentViewsMinAnimDuration =
res.getInteger(R.integer.recents_filter_animate_current_views_min_duration);
filteringNewViewsMinAnimDuration =
res.getInteger(R.integer.recents_filter_animate_new_views_min_duration);
filteringCurrentViewsAnimDuration =
res.getInteger(R.integer.recents_filter_animate_current_views_duration);
filteringNewViewsAnimDuration =
res.getInteger(R.integer.recents_filter_animate_new_views_duration);
// Insets
displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);

View File

@@ -396,6 +396,43 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
mCb.onTaskLaunching(isTaskInStackBounds);
}
// Upfront the processing of the thumbnail
TaskViewTransform transform;
View sourceView = tv;
int offsetX = 0;
int offsetY = 0;
int stackScroll = stackView.getStackScroll();
if (tv == null) {
// If there is no actual task view, then use the stack view as the source view
// and then offset to the expected transform rect, but bound this to just
// outside the display rect (to ensure we don't animate from too far away)
sourceView = stackView;
transform = stackView.getStackTransform(stack.indexOfTask(task), stackScroll);
offsetX = transform.rect.left;
offsetY = Math.min(transform.rect.top, mConfig.displayRect.height());
} else {
transform = stackView.getStackTransform(stack.indexOfTask(task), stackScroll);
}
// Compute the thumbnail to scale up from
ActivityOptions opts = null;
int thumbnailWidth = transform.rect.width();
int thumbnailHeight = transform.rect.height();
if (task.thumbnail != null && thumbnailWidth > 0 && thumbnailHeight > 0 &&
task.thumbnail.getWidth() > 0 && task.thumbnail.getHeight() > 0) {
// Resize the thumbnail to the size of the view that we are animating from
Bitmap b = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight,
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
c.drawBitmap(task.thumbnail,
new Rect(0, 0, task.thumbnail.getWidth(), task.thumbnail.getHeight()),
new Rect(0, 0, thumbnailWidth, thumbnailHeight), null);
c.setBitmap(null);
opts = ActivityOptions.makeThumbnailScaleUpAnimation(sourceView,
b, offsetX, offsetY);
}
final ActivityOptions launchOpts = opts;
final Runnable launchRunnable = new Runnable() {
@Override
public void run() {
@@ -404,45 +441,10 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
Constants.Log.App.TimeRecentsLaunchKey, "preStartActivity");
}
TaskViewTransform transform;
View sourceView = tv;
int offsetX = 0;
int offsetY = 0;
int stackScroll = stackView.getStackScroll();
if (tv == null) {
// If there is no actual task view, then use the stack view as the source view
// and then offset to the expected transform rect, but bound this to just
// outside the display rect (to ensure we don't animate from too far away)
sourceView = stackView;
transform = stackView.getStackTransform(stack.indexOfTask(task), stackScroll);
offsetX = transform.rect.left;
offsetY = Math.min(transform.rect.top, mConfig.displayRect.height());
} else {
transform = stackView.getStackTransform(stack.indexOfTask(task), stackScroll);
}
// Compute the thumbnail to scale up from
ActivityOptions opts = null;
int thumbnailWidth = transform.rect.width();
int thumbnailHeight = transform.rect.height();
if (task.thumbnail != null && thumbnailWidth > 0 && thumbnailHeight > 0 &&
task.thumbnail.getWidth() > 0 && task.thumbnail.getHeight() > 0) {
// Resize the thumbnail to the size of the view that we are animating from
Bitmap b = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight,
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
c.drawBitmap(task.thumbnail,
new Rect(0, 0, task.thumbnail.getWidth(), task.thumbnail.getHeight()),
new Rect(0, 0, thumbnailWidth, thumbnailHeight), null);
c.setBitmap(null);
opts = ActivityOptions.makeThumbnailScaleUpAnimation(sourceView,
b, offsetX, offsetY);
}
if (task.isActive) {
// Bring an active task to the foreground
RecentsTaskLoader.getInstance().getSystemServicesProxy()
.moveTaskToFront(task.key.id, opts);
.moveTaskToFront(task.key.id, launchOpts);
} else {
// Launch the activity anew with the desired animation
Intent i = new Intent(task.key.baseIntent);
@@ -451,8 +453,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
| Intent.FLAG_ACTIVITY_NEW_TASK);
try {
UserHandle taskUser = new UserHandle(task.userId);
if (opts != null) {
getContext().startActivityAsUser(i, opts.toBundle(), taskUser);
if (launchOpts != null) {
getContext().startActivityAsUser(i, launchOpts.toBundle(), taskUser);
} else {
getContext().startActivityAsUser(i, taskUser);
}

View File

@@ -23,6 +23,7 @@ import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewPropertyAnimator;
@@ -91,6 +92,13 @@ class TaskBarView extends FrameLayout {
mApplicationIcon = (ImageView) findViewById(R.id.application_icon);
mActivityDescription = (TextView) findViewById(R.id.activity_description);
mDismissButton = (ImageView) findViewById(R.id.dismiss_task);
// Hide the backgrounds if they are ripple drawables
if (!Constants.DebugFlags.App.EnableTaskFiltering) {
if (mApplicationIcon.getBackground() instanceof RippleDrawable) {
mApplicationIcon.setBackground(null);
}
}
}
@Override

View File

@@ -958,6 +958,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
ArrayList<TaskView> childrenToRemoveOut) {
// Animate all of the existing views out of view (if they are not in the visible range in
// the new stack) or to their final positions in the new stack
int offset = 0;
int movement = 0;
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
@@ -982,10 +983,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
movement = Math.max(movement, Math.abs(toTransform.translationY -
(int) tv.getTranslationY()));
}
childViewTransformsOut.put(tv, new Pair(0, toTransform));
int startDelay = offset *
Constants.Values.TaskStackView.FilterStartDelay;
childViewTransformsOut.put(tv, new Pair(startDelay, toTransform));
offset++;
}
return Utilities.calculateTranslationAnimationDuration(movement,
mConfig.filteringCurrentViewsMinAnimDuration);
return mConfig.filteringCurrentViewsAnimDuration;
}
/**
@@ -1023,8 +1027,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
}
}
return Utilities.calculateTranslationAnimationDuration(movement,
mConfig.filteringNewViewsMinAnimDuration);
return mConfig.filteringNewViewsAnimDuration;
}
/** Orchestrates the animations of the current child views and any new views. */