Merge "Allow dragging to dock single tasks." into nyc-dev
This commit is contained in:
@@ -749,7 +749,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
||||
public final void onBusEvent(AllTaskViewsDismissedEvent event) {
|
||||
SystemServicesProxy ssp = Recents.getSystemServices();
|
||||
if (ssp.hasDockedTask()) {
|
||||
mRecentsView.showEmptyView(R.string.recents_empty_message_dismissed_all);
|
||||
mRecentsView.showEmptyView(event.msgResId);
|
||||
} else {
|
||||
// Just go straight home (no animation necessary because there are no more task views)
|
||||
dismissRecentsToHome(false /* animateTaskViews */);
|
||||
|
||||
@@ -22,5 +22,10 @@ import com.android.systemui.recents.events.EventBus;
|
||||
* This is sent whenever all the task views in a stack have been dismissed.
|
||||
*/
|
||||
public class AllTaskViewsDismissedEvent extends EventBus.Event {
|
||||
// Simple event
|
||||
|
||||
public final int msgResId;
|
||||
|
||||
public AllTaskViewsDismissedEvent(int msgResId) {
|
||||
this.msgResId = msgResId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
|
||||
if (row.getViewType() == TASK_ROW_VIEW_TYPE) {
|
||||
TaskRow taskRow = (TaskRow) row;
|
||||
Task task = taskRow.task;
|
||||
mStack.removeTask(task, AnimationProps.IMMEDIATE);
|
||||
mStack.removeTask(task, AnimationProps.IMMEDIATE, false /* fromDockGesture */);
|
||||
EventBus.getDefault().send(new DeleteTaskDataEvent(task));
|
||||
i = removeTaskRow(i);
|
||||
}
|
||||
@@ -326,7 +326,7 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
|
||||
public void onTaskRemoved(Task task, int position) {
|
||||
// Since this is removed from the history, we need to update the stack as well to ensure
|
||||
// that the model is correct. Since the stack is hidden, we can update it immediately.
|
||||
mStack.removeTask(task, AnimationProps.IMMEDIATE);
|
||||
mStack.removeTask(task, AnimationProps.IMMEDIATE, false /* fromDockGesture */);
|
||||
removeTaskRow(position);
|
||||
if (mRows.isEmpty()) {
|
||||
dismissHistory();
|
||||
|
||||
@@ -219,7 +219,7 @@ public class TaskStack {
|
||||
* Notifies when a task has been removed from the stack.
|
||||
*/
|
||||
void onStackTaskRemoved(TaskStack stack, Task removedTask, boolean wasFrontMostTask,
|
||||
Task newFrontMostTask, AnimationProps animation);
|
||||
Task newFrontMostTask, AnimationProps animation, boolean fromDockGesture);
|
||||
|
||||
/**
|
||||
* Notifies when a task has been removed from the history.
|
||||
@@ -513,14 +513,15 @@ public class TaskStack {
|
||||
* Removes a task from the stack, with an additional {@param animation} hint to the callbacks on
|
||||
* how they should update themselves.
|
||||
*/
|
||||
public void removeTask(Task t, AnimationProps animation) {
|
||||
public void removeTask(Task t, AnimationProps animation, boolean fromDockGesture) {
|
||||
if (mStackTaskList.contains(t)) {
|
||||
boolean wasFrontMostTask = (getStackFrontMostTask(false /* includeFreeform */) == t);
|
||||
removeTaskImpl(mStackTaskList, t);
|
||||
Task newFrontMostTask = getStackFrontMostTask(false /* includeFreeform */);
|
||||
if (mCb != null) {
|
||||
// Notify that a task has been removed
|
||||
mCb.onStackTaskRemoved(this, t, wasFrontMostTask, newFrontMostTask, animation);
|
||||
mCb.onStackTaskRemoved(this, t, wasFrontMostTask, newFrontMostTask, animation,
|
||||
fromDockGesture);
|
||||
}
|
||||
} else if (mHistoryTaskList.contains(t)) {
|
||||
removeTaskImpl(mHistoryTaskList, t);
|
||||
@@ -558,9 +559,9 @@ public class TaskStack {
|
||||
if (notifyStackChanges) {
|
||||
// If we are notifying, then remove the task now, otherwise the raw task list
|
||||
// will be reset at the end of this method
|
||||
removeTask(task, AnimationProps.IMMEDIATE);
|
||||
removeTask(task, AnimationProps.IMMEDIATE, false /* fromDockGesture */);
|
||||
mCb.onStackTaskRemoved(this, task, i == (taskCount - 1), null,
|
||||
AnimationProps.IMMEDIATE);
|
||||
AnimationProps.IMMEDIATE, false /* fromDockGesture */);
|
||||
}
|
||||
}
|
||||
task.setGroup(null);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class TaskStackHorizontalGridView extends HorizontalGridView implements T
|
||||
|
||||
@Override
|
||||
public void onStackTaskRemoved(TaskStack stack, Task removedTask, boolean wasFrontMostTask,
|
||||
Task newFrontMostTask, AnimationProps animation) {
|
||||
Task newFrontMostTask, AnimationProps animation, boolean fromDockGesture) {
|
||||
getAdapter().notifyItemRemoved(stack.getStackTasks().indexOf(removedTask));
|
||||
if (mFocusedTask == removedTask) {
|
||||
resetFocusedTask(removedTask);
|
||||
@@ -144,7 +144,9 @@ public class TaskStackHorizontalGridView extends HorizontalGridView implements T
|
||||
if (mStack.getStackTaskCount() == 0) {
|
||||
boolean shouldFinishActivity = (mStack.getStackTaskCount() == 0);
|
||||
if (shouldFinishActivity) {
|
||||
EventBus.getDefault().send(new AllTaskViewsDismissedEvent());
|
||||
EventBus.getDefault().send(new AllTaskViewsDismissedEvent(fromDockGesture
|
||||
? R.string.recents_empty_message
|
||||
: R.string.recents_empty_message_dismissed_all));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,7 +632,8 @@ public class RecentsView extends FrameLayout {
|
||||
AnimationProps stackAnim = new AnimationProps(
|
||||
TaskStackView.DEFAULT_SYNC_STACK_DURATION,
|
||||
Interpolators.FAST_OUT_SLOW_IN);
|
||||
mTaskStackView.getStack().removeTask(event.task, stackAnim);
|
||||
mTaskStackView.getStack().removeTask(event.task, stackAnim,
|
||||
true /* fromDockGesture */);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -150,8 +150,7 @@ public class RecentsViewTouchHandler {
|
||||
mTaskView.setTranslationY(y);
|
||||
|
||||
mVisibleDockStates.clear();
|
||||
if (ActivityManager.supportsMultiWindow() &&
|
||||
!ssp.hasDockedTask() && mRv.getTaskStack().getTaskCount() > 1) {
|
||||
if (ActivityManager.supportsMultiWindow() && !ssp.hasDockedTask()) {
|
||||
if (!event.task.isDockable) {
|
||||
Toast.makeText(mRv.getContext(), R.string.recents_drag_non_dockable_task_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -1395,7 +1395,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
|
||||
*/
|
||||
@Override
|
||||
public void onStackTaskRemoved(TaskStack stack, Task removedTask, boolean wasFrontMostTask,
|
||||
Task newFrontMostTask, AnimationProps animation) {
|
||||
Task newFrontMostTask, AnimationProps animation, boolean fromDockGesture) {
|
||||
if (mFocusedTask == removedTask) {
|
||||
resetFocusedTask(removedTask);
|
||||
}
|
||||
@@ -1426,7 +1426,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
|
||||
|
||||
// If there are no remaining tasks, then just close recents
|
||||
if (mStack.getTaskCount() == 0) {
|
||||
EventBus.getDefault().send(new AllTaskViewsDismissedEvent());
|
||||
EventBus.getDefault().send(new AllTaskViewsDismissedEvent(fromDockGesture
|
||||
? R.string.recents_empty_message
|
||||
: R.string.recents_empty_message_dismissed_all));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1599,7 +1601,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
|
||||
tv.dismissTask();
|
||||
} else {
|
||||
// Otherwise, remove the task from the stack immediately
|
||||
mStack.removeTask(t, AnimationProps.IMMEDIATE);
|
||||
mStack.removeTask(t, AnimationProps.IMMEDIATE, false /* fromDockGesture */);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1937,7 +1939,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
|
||||
|
||||
// Remove the task from the stack
|
||||
mStack.removeTask(task, new AnimationProps(DEFAULT_SYNC_STACK_DURATION,
|
||||
Interpolators.FAST_OUT_SLOW_IN));
|
||||
Interpolators.FAST_OUT_SLOW_IN), false /* fromDockGesture */);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user