Skip to content

Commit ec396d6

Browse files
author
Winson Chung
committed
Initial changes to add task affiliation styling. (Bug 16656169)
- Fixing issue with launch-in-background animation
1 parent 256e1a6 commit ec396d6

File tree

15 files changed

+107
-50
lines changed

15 files changed

+107
-50
lines changed

core/java/android/app/ActivityManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,13 @@ public static class RecentTaskInfo implements Parcelable {
700700
*/
701701
public int affiliatedTaskId;
702702

703+
/**
704+
* Task affiliation color of the source task with the affiliated task id.
705+
*
706+
* @hide
707+
*/
708+
public int affiliatedTaskColor;
709+
703710
public RecentTaskInfo() {
704711
}
705712

@@ -732,6 +739,7 @@ public void writeToParcel(Parcel dest, int flags) {
732739
dest.writeLong(firstActiveTime);
733740
dest.writeLong(lastActiveTime);
734741
dest.writeInt(affiliatedTaskId);
742+
dest.writeInt(affiliatedTaskColor);
735743
}
736744

737745
public void readFromParcel(Parcel source) {
@@ -747,6 +755,7 @@ public void readFromParcel(Parcel source) {
747755
firstActiveTime = source.readLong();
748756
lastActiveTime = source.readLong();
749757
affiliatedTaskId = source.readInt();
758+
affiliatedTaskColor = source.readInt();
750759
}
751760

752761
public static final Creator<RecentTaskInfo> CREATOR

core/res/res/anim/launch_task_behind_source.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@
3737
android:interpolator="@interpolator/fast_out_slow_in"
3838
android:duration="350" />
3939

40-
<alpha android:fromAlpha="1.0" android:toAlpha="1.6"
40+
<alpha android:fromAlpha="1.0" android:toAlpha="1.6666666666"
4141
android:fillEnabled="true" android:fillBefore="false" android:fillAfter="true"
4242
android:interpolator="@interpolator/decelerate_cubic"
4343
android:startOffset="433"
4444
android:duration="133"/>
4545

46-
<translate android:fromYDelta="0%" android:toYDelta="-10%"
46+
<translate android:fromYDelta="0%" android:toYDelta="-8.8888888888%"
4747
android:fillEnabled="true" android:fillBefore="false" android:fillAfter="true"
4848
android:interpolator="@interpolator/decelerate_cubic"
4949
android:startOffset="433"
5050
android:duration="350"/>
5151

52-
<scale android:fromXScale="1.0" android:toXScale="1.1"
53-
android:fromYScale="1.0" android:toYScale="1.1"
52+
<scale android:fromXScale="1.0" android:toXScale="1.1111111111"
53+
android:fromYScale="1.0" android:toYScale="1.1111111111"
5454
android:fillEnabled="true" android:fillBefore="false" android:fillAfter="true"
5555
android:pivotX="50%p" android:pivotY="50%p"
5656
android:interpolator="@interpolator/decelerate_cubic"

packages/SystemUI/res/layout/recents_task_view.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
android:layout_width="match_parent"
1919
android:layout_height="match_parent"
2020
android:focusable="true">
21-
<com.android.systemui.recents.views.TaskThumbnailView
21+
<com.android.systemui.recents.views.TaskViewThumbnail
2222
android:id="@+id/task_view_thumbnail"
2323
android:layout_width="match_parent"
2424
android:layout_height="match_parent" />
25-
<com.android.systemui.recents.views.TaskBarView
25+
<com.android.systemui.recents.views.TaskViewHeader
2626
android:id="@+id/task_view_bar"
2727
android:layout_width="match_parent"
2828
android:layout_height="@dimen/recents_task_bar_height"
@@ -61,7 +61,7 @@
6161
android:background="@drawable/recents_button_bg"
6262
android:visibility="invisible"
6363
android:src="@drawable/recents_dismiss_light" />
64-
</com.android.systemui.recents.views.TaskBarView>
64+
</com.android.systemui.recents.views.TaskViewHeader>
6565
<FrameLayout
6666
android:id="@+id/lock_to_app_fab"
6767
android:layout_width="48dp"

packages/SystemUI/res/values/dimens.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@
237237
in dps over one second of time. -->
238238
<dimen name="recents_animation_movement_in_dps_per_second">800dp</dimen>
239239

240+
<!-- The min alpha to apply to a task affiliation group color. -->
241+
<item name="recents_task_affiliation_color_min_alpha_percentage" format="float" type="dimen">0.6</item>
242+
240243
<!-- Space reserved for the cards behind the top card in the top stack -->
241244
<dimen name="top_stack_peek_amount">12dp</dimen>
242245

packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class RecentsConfiguration {
8686
public int taskBarViewLightTextColor;
8787
public int taskBarViewDarkTextColor;
8888
public int taskBarViewHighlightColor;
89+
public float taskBarViewAffiliationColorMinAlpha;
8990

9091
/** Task bar size & animations */
9192
public int taskBarHeight;
@@ -221,6 +222,9 @@ void update(Context context) {
221222
res.getColor(R.color.recents_task_bar_dark_text_color);
222223
taskBarViewHighlightColor =
223224
res.getColor(R.color.recents_task_bar_highlight_color);
225+
TypedValue affMinAlphaPctValue = new TypedValue();
226+
res.getValue(R.dimen.recents_task_affiliation_color_min_alpha_percentage, affMinAlphaPctValue, true);
227+
taskBarViewAffiliationColorMinAlpha = affMinAlphaPctValue.getFloat();
224228

225229
// Task bar size & animations
226230
taskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height);

packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ public SpaceNode reload(Context context, int preloadCount) {
339339

340340
// Create a new task
341341
Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, t.affiliatedTaskId,
342-
activityLabel, activityIcon, activityColor, t.userId, t.firstActiveTime,
343-
t.lastActiveTime, (i == (taskCount - 1)), config.lockToAppEnabled);
342+
t.affiliatedTaskColor, activityLabel, activityIcon, activityColor, t.userId,
343+
t.firstActiveTime, t.lastActiveTime, (i == (taskCount - 1)),
344+
config.lockToAppEnabled);
344345

345346
// Preload the specified number of apps
346347
if (i >= (taskCount - preloadCount)) {
@@ -381,7 +382,7 @@ public SpaceNode reload(Context context, int preloadCount) {
381382
}
382383

383384
// Simulate the groupings that we describe
384-
stack.createAffiliatedGroupings();
385+
stack.createAffiliatedGroupings(config);
385386

386387
// Start the task loader and add all the tasks we need to load
387388
mLoader.start(context);
@@ -405,11 +406,11 @@ public static TaskStack getShallowTaskStack(SystemServicesProxy ssp) {
405406
ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent(), t.userId);
406407
if (info == null) continue;
407408

408-
stack.addTask(new Task(t.persistentId, true, t.baseIntent, t.affiliatedTaskId, null,
409-
null, 0, 0, t.firstActiveTime, t.lastActiveTime, (i == (taskCount - 1)),
410-
config.lockToAppEnabled));
409+
stack.addTask(new Task(t.persistentId, true, t.baseIntent, t.affiliatedTaskId,
410+
t.affiliatedTaskColor, null, null, 0, 0, t.firstActiveTime, t.lastActiveTime,
411+
(i == (taskCount - 1)), config.lockToAppEnabled));
411412
}
412-
stack.createAffiliatedGroupings();
413+
stack.createAffiliatedGroupings(config);
413414
return stack;
414415
}
415416

packages/SystemUI/src/com/android/systemui/recents/model/Task.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public String toString() {
7777
public TaskKey key;
7878
public TaskGrouping group;
7979
public int taskAffiliation;
80+
public int taskAffiliationColor;
8081
public boolean isLaunchTarget;
8182
public Drawable applicationIcon;
8283
public Drawable activityIcon;
@@ -95,16 +96,19 @@ public Task() {
9596
// Only used by RecentsService for task rect calculations.
9697
}
9798

98-
public Task(int id, boolean isActive, Intent intent, int taskAffiliation, String activityTitle,
99-
Drawable activityIcon, int colorPrimary, int userId,
99+
public Task(int id, boolean isActive, Intent intent, int taskAffiliation, int taskAffiliationColor,
100+
String activityTitle, Drawable activityIcon, int colorPrimary, int userId,
100101
long firstActiveTime, long lastActiveTime, boolean lockToThisTask,
101102
boolean lockToTaskEnabled) {
103+
boolean isInAffiliationGroup = (taskAffiliation != id);
104+
boolean hasAffiliationGroupColor = isInAffiliationGroup && (taskAffiliationColor != 0);
102105
this.key = new TaskKey(id, intent, userId, firstActiveTime, lastActiveTime);
103106
this.taskAffiliation = taskAffiliation;
107+
this.taskAffiliationColor = taskAffiliationColor;
104108
this.activityLabel = activityTitle;
105109
this.activityIcon = activityIcon;
106-
this.colorPrimary = colorPrimary;
107-
this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(colorPrimary,
110+
this.colorPrimary = hasAffiliationGroupColor ? taskAffiliationColor : colorPrimary;
111+
this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary,
108112
Color.WHITE) > 3f;
109113
this.isActive = isActive;
110114
this.lockToThisTask = lockToTaskEnabled && lockToThisTask;

packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package com.android.systemui.recents.model;
1818

19+
import android.graphics.Color;
1920
import com.android.systemui.recents.Constants;
21+
import com.android.systemui.recents.RecentsConfiguration;
2022
import com.android.systemui.recents.misc.NamedCounter;
2123

2224
import java.util.ArrayList;
@@ -320,7 +322,7 @@ public TaskGrouping getGroupWithAffiliation(int affiliation) {
320322
/**
321323
* Temporary: This method will simulate affiliation groups by
322324
*/
323-
public void createAffiliatedGroupings() {
325+
public void createAffiliatedGroupings(RecentsConfiguration config) {
324326
if (Constants.DebugFlags.App.EnableSimulatedTaskGroups) {
325327
HashMap<Task.TaskKey, Task> taskMap = new HashMap<Task.TaskKey, Task>();
326328
// Sort all tasks by increasing firstActiveTime of the task
@@ -387,6 +389,7 @@ public int compare(Task.TaskKey taskKey, Task.TaskKey taskKey2) {
387389
mTaskList.set(tasks);
388390
} else {
389391
// Create the task groups
392+
HashMap<Task.TaskKey, Task> tasksMap = new HashMap<Task.TaskKey, Task>();
390393
ArrayList<Task> tasks = mTaskList.getTasks();
391394
int taskCount = tasks.size();
392395
for (int i = 0; i < taskCount; i++) {
@@ -401,6 +404,28 @@ public int compare(Task.TaskKey taskKey, Task.TaskKey taskKey2) {
401404
addGroup(group);
402405
}
403406
group.addTask(t);
407+
tasksMap.put(t.key, t);
408+
}
409+
// Update the task colors for each of the groups
410+
float minAlpha = config.taskBarViewAffiliationColorMinAlpha;
411+
int taskGroupCount = mGroups.size();
412+
for (int i = 0; i < taskGroupCount; i++) {
413+
TaskGrouping group = mGroups.get(i);
414+
taskCount = group.getTaskCount();
415+
// Ignore the groups that only have one task
416+
if (taskCount <= 1) continue;
417+
// Calculate the group color distribution
418+
int affiliationColor = tasksMap.get(group.mTaskKeys.get(0)).taskAffiliationColor;
419+
float alphaStep = (1f - minAlpha) / taskCount;
420+
float alpha = 1f;
421+
for (int j = 0; j < taskCount; j++) {
422+
Task t = tasksMap.get(group.mTaskKeys.get(j));
423+
t.colorPrimary = Color.rgb(
424+
(int) (alpha * Color.red(affiliationColor) + (1f - alpha) * 0xFF),
425+
(int) (alpha * Color.green(affiliationColor) + (1f - alpha) * 0xFF),
426+
(int) (alpha * Color.blue(affiliationColor) + (1f - alpha) * 0xFF));
427+
alpha -= alphaStep;
428+
}
404429
}
405430
}
406431
}

packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void clipTaskViews() {
330330
// We can reuse the current task transforms to find the task rects
331331
TaskViewTransform transform = mCurrentTaskTransforms.get(mStack.indexOfTask(tv.getTask()));
332332
TaskViewTransform nextTransform = mCurrentTaskTransforms.get(mStack.indexOfTask(nextTv.getTask()));
333-
clipBottom = transform.rect.bottom - nextTransform.rect.top - 200;
333+
clipBottom = transform.rect.bottom - nextTransform.rect.top;
334334
}
335335
}
336336
tv.getViewBounds().setClipBottom(clipBottom);
@@ -430,9 +430,8 @@ public boolean onTouchEvent(MotionEvent ev) {
430430
public void computeScroll() {
431431
mStackScroller.computeScroll();
432432
// Synchronize the views
433-
if (synchronizeStackViewsWithModel()) {
434-
clipTaskViews();
435-
}
433+
synchronizeStackViewsWithModel();
434+
clipTaskViews();
436435
}
437436

438437
/** Computes the stack and task rects */

packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
/* A task view */
4141
public class TaskView extends FrameLayout implements Task.TaskCallbacks,
42-
TaskFooterView.TaskFooterViewCallbacks, View.OnClickListener, View.OnLongClickListener {
42+
TaskViewFooter.TaskFooterViewCallbacks, View.OnClickListener, View.OnLongClickListener {
4343
/** The TaskView callbacks */
4444
interface TaskViewCallbacks {
4545
public void onTaskViewAppIconClicked(TaskView tv);
@@ -67,9 +67,9 @@ interface TaskViewCallbacks {
6767
AnimateableViewBounds mViewBounds;
6868
Paint mLayerPaint = new Paint();
6969

70-
TaskThumbnailView mThumbnailView;
71-
TaskBarView mBarView;
72-
TaskFooterView mFooterView;
70+
TaskViewThumbnail mThumbnailView;
71+
TaskViewHeader mBarView;
72+
TaskViewFooter mFooterView;
7373
View mActionButtonView;
7474
TaskViewCallbacks mCb;
7575

@@ -124,8 +124,8 @@ AnimateableViewBounds getViewBounds() {
124124
@Override
125125
protected void onFinishInflate() {
126126
// Bind the views
127-
mBarView = (TaskBarView) findViewById(R.id.task_view_bar);
128-
mThumbnailView = (TaskThumbnailView) findViewById(R.id.task_view_thumbnail);
127+
mBarView = (TaskViewHeader) findViewById(R.id.task_view_bar);
128+
mThumbnailView = (TaskViewThumbnail) findViewById(R.id.task_view_thumbnail);
129129
mActionButtonView = findViewById(R.id.lock_to_app_fab);
130130
if (mFooterView != null) {
131131
mFooterView.setCallbacks(this);
@@ -712,7 +712,7 @@ void setTouchEnabled(boolean enabled) {
712712
setOnClickListener(enabled ? this : null);
713713
}
714714

715-
/**** TaskFooterView.TaskFooterViewCallbacks ****/
715+
/**** TaskViewFooter.TaskFooterViewCallbacks ****/
716716

717717
@Override
718718
public void onTaskFooterHeightChanged(int height, int maxHeight) {

0 commit comments

Comments
 (0)