From 931845fcb3823ce175fcfc7c6ce2d9751102c331 Mon Sep 17 00:00:00 2001 From: Winson Date: Wed, 24 Feb 2016 19:38:41 -0800 Subject: [PATCH] Dev preview changes for incompatible apps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Disable drop targets when picking up a task that can’t be docked, and show toast notifying user (for now) - When a task is docked, update the task headers for non-dockable tasks to indicate that they don’t support multi window. Update these headers every time the multi window state changes. Bug: 26774190 Change-Id: I020dcbac9b1230dba166eecaa12366986e684f9e --- .../res/layout/recents_task_view_header.xml | 42 ++++++++++++++----- packages/SystemUI/res/values/strings.xml | 4 ++ .../systemui/recents/RecentsActivity.java | 21 +++++----- .../activity/TaskStackUpdatedEvent.java | 4 +- .../recents/model/RecentsTaskLoadPlan.java | 4 +- .../android/systemui/recents/model/Task.java | 8 +++- .../systemui/recents/views/RecentsView.java | 6 ++- .../views/RecentsViewTouchHandler.java | 17 +++++--- .../systemui/recents/views/TaskStackView.java | 22 ++++++++-- .../recents/views/TaskViewHeader.java | 10 +++++ 10 files changed, 101 insertions(+), 37 deletions(-) diff --git a/packages/SystemUI/res/layout/recents_task_view_header.xml b/packages/SystemUI/res/layout/recents_task_view_header.xml index 2e415612c19af..fa6575824552e 100644 --- a/packages/SystemUI/res/layout/recents_task_view_header.xml +++ b/packages/SystemUI/res/layout/recents_task_view_header.xml @@ -30,21 +30,41 @@ android:paddingBottom="8dp" android:paddingStart="12dp" android:paddingEnd="16dp" /> - + android:layout_marginEnd="56dp" + android:orientation="vertical"> + + + History Clear + + This app does not support multi-window + + App does not support multi-window Split Horizontal diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index c2a6108d931d1..c41098f3c0eeb 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -528,17 +528,16 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD @Override public void onMultiWindowChanged(boolean inMultiWindow) { super.onMultiWindowChanged(inMultiWindow); - if (!inMultiWindow) { - RecentsTaskLoader loader = Recents.getTaskLoader(); - RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); - launchOpts.loadIcons = false; - launchOpts.loadThumbnails = false; - launchOpts.onlyLoadForCache = true; - RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this); - loader.preloadTasks(loadPlan, -1, false); - loader.loadTasks(this, loadPlan, launchOpts); - EventBus.getDefault().send(new TaskStackUpdatedEvent(loadPlan.getTaskStack())); - } + RecentsTaskLoader loader = Recents.getTaskLoader(); + RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); + launchOpts.loadIcons = false; + launchOpts.loadThumbnails = false; + launchOpts.onlyLoadForCache = true; + RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this); + loader.preloadTasks(loadPlan, -1, false); + loader.loadTasks(this, loadPlan, launchOpts); + EventBus.getDefault().send(new TaskStackUpdatedEvent(loadPlan.getTaskStack(), + inMultiWindow)); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java index f87f6de3be7c7..0d614e8c675c5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java +++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java @@ -28,8 +28,10 @@ public class TaskStackUpdatedEvent extends EventBus.AnimatedEvent { * A new TaskStack instance representing the latest stack state. */ public final TaskStack stack; + public final boolean inMultiWindow; - public TaskStackUpdatedEvent(TaskStack stack) { + public TaskStackUpdatedEvent(TaskStack stack, boolean inMultiWindow) { this.stack = stack; + this.inMultiWindow = inMultiWindow; } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java index 824231ae2fc19..6fef8a24fff3a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java @@ -198,8 +198,8 @@ public class RecentsTaskLoadPlan { // Add the task to the stack Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon, thumbnail, title, contentDescription, dismissDescription, activityColor, - backgroundColor, !isStackTask, isLaunchTarget, isSystemApp, t.bounds, - t.taskDescription); + backgroundColor, !isStackTask, isLaunchTarget, isSystemApp, t.isDockable, + t.bounds, t.taskDescription); allTasks.add(task); affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1); 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 8ed6dd78a357a..e5d4f1bf50bc0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java @@ -168,6 +168,8 @@ public class Task { public boolean isHistorical; @ViewDebug.ExportedProperty(category="recents") public boolean isSystemApp; + @ViewDebug.ExportedProperty(category="recents") + public boolean isDockable; private ArrayList mCallbacks = new ArrayList<>(); @@ -178,8 +180,8 @@ public class Task { public Task(TaskKey key, int affiliationTaskId, int affiliationColor, Drawable icon, Bitmap thumbnail, String title, String contentDescription, String dismissDescription, int colorPrimary, int colorBackground, - boolean isHistorical, boolean isLaunchTarget, boolean isSystemApp, Rect bounds, - ActivityManager.TaskDescription taskDescription) { + boolean isHistorical, boolean isLaunchTarget, boolean isSystemApp, + boolean isDockable, Rect bounds, ActivityManager.TaskDescription taskDescription) { boolean isInAffiliationGroup = (affiliationTaskId != key.id); boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0); this.key = key; @@ -199,6 +201,7 @@ public class Task { this.isLaunchTarget = isLaunchTarget; this.isHistorical = isHistorical; this.isSystemApp = isSystemApp; + this.isDockable = isDockable; } /** Copies the other task. */ @@ -219,6 +222,7 @@ public class Task { this.isLaunchTarget = o.isLaunchTarget; this.isHistorical = o.isHistorical; this.isSystemApp = o.isSystemApp; + this.isDockable = o.isDockable; } /** 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 2e456277406ac..5dde92698f789 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -663,8 +663,10 @@ public class RecentsView extends FrameLayout { } public final void onBusEvent(TaskStackUpdatedEvent event) { - mStack.setTasks(event.stack.computeAllTasksList(), true /* notifyStackChanges */); - mStack.createAffiliatedGroupings(getContext()); + if (!event.inMultiWindow) { + mStack.setTasks(event.stack.computeAllTasksList(), true /* notifyStackChanges */); + mStack.createAffiliatedGroupings(getContext()); + } } public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java index 016d9370364d3..079d7b9148f09 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java @@ -21,7 +21,9 @@ import android.graphics.Point; import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.ViewDebug; +import android.widget.Toast; +import com.android.systemui.R; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.events.EventBus; @@ -148,11 +150,16 @@ public class RecentsViewTouchHandler { mVisibleDockStates.clear(); if (!ssp.hasDockedTask() && mRv.getTaskStack().getTaskCount() > 1) { - // Add the dock state drop targets (these take priority) - TaskStack.DockState[] dockStates = getDockStatesForCurrentOrientation(); - for (TaskStack.DockState dockState : dockStates) { - registerDropTargetForCurrentDrag(dockState); - mVisibleDockStates.add(dockState); + if (!event.task.isDockable) { + Toast.makeText(mRv.getContext(), R.string.recents_drag_non_dockable_task_message, + Toast.LENGTH_SHORT).show(); + } else { + // Add the dock state drop targets (these take priority) + TaskStack.DockState[] dockStates = getDockStatesForCurrentOrientation(); + for (TaskStack.DockState dockState : dockStates) { + registerDropTargetForCurrentDrag(dockState); + mVisibleDockStates.add(dockState); + } } } 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 d71d70f3819b6..afa5188d2a2dc 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -1830,12 +1830,28 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } public final void onBusEvent(TaskStackUpdatedEvent event) { - // Scroll the stack to the front after it has been updated + if (!event.inMultiWindow) { + // Scroll the stack to the front after it has been updated + event.addPostAnimationCallback(new Runnable() { + @Override + public void run() { + mStackScroller.animateScroll(mLayoutAlgorithm.mMaxScrollP, + null /* postScrollRunnable */); + } + }); + } + // When the multi-window state changes, rebind all task view headers again to update their + // dockable state event.addPostAnimationCallback(new Runnable() { @Override public void run() { - mStackScroller.animateScroll(mLayoutAlgorithm.mMaxScrollP, - null /* postScrollRunnable */); + List taskViews = getTaskViews(); + int taskViewCount = taskViews.size(); + for (int i = 0; i < taskViewCount; i++) { + TaskView tv = taskViews.get(i); + tv.getHeaderView().rebindToTask(tv.getTask(), tv.mTouchExplorationEnabled, + tv.mIsDisabledInSafeMode); + } } }); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java index 0543dd5db3791..05a85278db169 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java @@ -139,6 +139,7 @@ public class TaskViewHeader extends FrameLayout // Header views ImageView mIconView; TextView mTitleView; + TextView mSubTitleView; ImageView mMoveTaskButton; ImageView mDismissButton; ViewStub mAppOverlayViewStub; @@ -237,6 +238,7 @@ public class TaskViewHeader extends FrameLayout mIconView.setClickable(false); mIconView.setOnLongClickListener(this); mTitleView = (TextView) findViewById(R.id.title); + mSubTitleView = (TextView) findViewById(R.id.sub_title); mDismissButton = (ImageView) findViewById(R.id.dismiss_task); if (ssp.hasFreeformWorkspaceSupport()) { mMoveTaskButton = (ImageView) findViewById(R.id.move_task); @@ -367,6 +369,7 @@ public class TaskViewHeader extends FrameLayout /** Binds the bar view to the task */ public void rebindToTask(Task t, boolean touchExplorationEnabled, boolean disabledInSafeMode) { + SystemServicesProxy ssp = Recents.getSystemServices(); mTask = t; // If an activity icon is defined, then we use that as the primary icon to show in the bar, @@ -384,6 +387,13 @@ public class TaskViewHeader extends FrameLayout mTitleView.setContentDescription(t.contentDescription); mTitleView.setTextColor(t.useLightOnPrimaryColor ? mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor); + if (!t.isDockable && ssp.hasDockedTask()) { + mSubTitleView.setVisibility(View.VISIBLE); + mSubTitleView.setTextColor(t.useLightOnPrimaryColor ? + mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor); + } else { + mSubTitleView.setVisibility(View.GONE); + } mDismissButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightDismissDrawable : mDarkDismissDrawable); mDismissButton.setContentDescription(t.dismissDescription);