import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.AppWidgetProviderChangedEvent;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
+import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
-import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
import com.android.systemui.recents.events.activity.LaunchTaskFailedEvent;
import com.android.systemui.recents.events.ui.ResizeTaskEvent;
import com.android.systemui.recents.events.ui.ShowApplicationInfoEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
+import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent;
mRecentsView.disableLayersForOneFrame();
}
- if (launchState.startHidden) {
- launchState.startHidden = false;
- mRecentsView.setStackViewVisibility(View.INVISIBLE);
- } else {
- mRecentsView.setStackViewVisibility(View.VISIBLE);
- }
-
// Notify that recents is now visible
SystemServicesProxy ssp = Recents.getSystemServices();
EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, ssp, true));
}
public final void onBusEvent(EnterRecentsWindowLastAnimationFrameEvent event) {
- mRecentsView.setStackViewVisibility(View.VISIBLE);
+ EventBus.getDefault().send(new UpdateFreeformTaskViewVisibilityEvent(true));
mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
+ mRecentsView.invalidate();
}
public final void onBusEvent(ExitRecentsWindowFirstAnimationFrameEvent event) {
- mRecentsView.setStackViewVisibility(View.INVISIBLE);
+ if (mRecentsView.isLastTaskLaunchedFreeform()) {
+ EventBus.getDefault().send(new UpdateFreeformTaskViewVisibilityEvent(false));
+ }
mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
+ mRecentsView.invalidate();
}
public final void onBusEvent(CancelEnterRecentsWindowAnimationEvent event) {
public boolean launchedFromSearchHome;
public boolean launchedReuseTaskStackViews;
public boolean launchedHasConfigurationChanged;
- public boolean startHidden;
+ public boolean launchedViaDragGesture;
public int launchedToTaskId;
public int launchedNumVisibleTasks;
public int launchedNumVisibleThumbnails;
launchState.launchedNumVisibleTasks = vr.numVisibleTasks;
launchState.launchedNumVisibleThumbnails = vr.numVisibleThumbnails;
launchState.launchedHasConfigurationChanged = false;
- launchState.startHidden = topTask != null && topTask.stackId == FREEFORM_WORKSPACE_STACK_ID
- || mDraggingInRecents;
+ launchState.launchedViaDragGesture = mDraggingInRecents;
Intent intent = new Intent();
intent.setClassName(RECENTS_PACKAGE, RECENTS_ACTIVITY);
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package com.android.systemui.recents.events.ui;
+
+import com.android.systemui.recents.events.EventBus;
+
+/**
+ * This is sent to update the visibility of all visible freeform task views.
+ */
+public class UpdateFreeformTaskViewVisibilityEvent extends EventBus.Event {
+
+ public final boolean visible;
+
+ public UpdateFreeformTaskViewVisibilityEvent(boolean visible) {
+ this.visible = visible;
+ }
+}
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivity;
+import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsAppWidgetHostView;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
+import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEndedEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragDropTargetChangedEvent;
private static final String TAG = "RecentsView";
private static final boolean DEBUG = false;
- private int mStackViewVisibility = View.VISIBLE;
-
LayoutInflater mInflater;
Handler mHandler;
- ArrayList<TaskStack> mStacks;
TaskStackView mTaskStackView;
RecentsAppWidgetHostView mSearchBar;
+ boolean mAwaitingFirstLayout = true;
+ boolean mLastTaskLaunchedWasFreeform;
RecentsTransitionHelper mTransitionHelper;
RecentsViewTouchHandler mTouchHandler;
mTaskStackView.setCallbacks(this);
addView(mTaskStackView);
}
- mTaskStackView.setVisibility(mStackViewVisibility);
// Trigger a new layout
requestLayout();
}
+ /**
+ * Returns whether the last task launched was in the freeform stack or not.
+ */
+ public boolean isLastTaskLaunchedFreeform() {
+ return mLastTaskLaunchedWasFreeform;
+ }
+
/** Gets the next task in the stack - or if the last - the top task */
public Task getNextTaskOrTopTask(Task taskToSearch) {
Task returnTask = null;
mDragView.layout(left, top, left + mDragView.getMeasuredWidth(),
top + mDragView.getMeasuredHeight());
}
+
+ if (mAwaitingFirstLayout) {
+ mAwaitingFirstLayout = false;
+
+ // If launched via dragging from the nav bar, then we should translate the whole view
+ // down offscreen
+ RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
+ if (launchState.launchedViaDragGesture) {
+ setTranslationY(getMeasuredHeight());
+ }
+ }
}
@Override
public void onTaskViewClicked(final TaskStackView stackView, final TaskView tv,
final TaskStack stack, final Task task, final boolean lockToTask,
final Rect bounds, int destinationStack) {
+ mLastTaskLaunchedWasFreeform = SystemServicesProxy.isFreeformStack(task.key.stackId);
mTransitionHelper.launchTaskFromRecents(stack, task, stackView, tv, lockToTask, bounds,
destinationStack);
}
}
public final void onBusEvent(DraggingInRecentsEvent event) {
- setStackViewVisibility(View.VISIBLE);
setTranslationY(event.distanceFromTop - mTaskStackView.getTaskViews().get(0).getY());
}
}
}
- public void setStackViewVisibility(int stackViewVisibility) {
- mStackViewVisibility = stackViewVisibility;
- if (mTaskStackView != null) {
- mTaskStackView.setVisibility(stackViewVisibility);
- invalidate();
+ public final void onBusEvent(RecentsVisibilityChangedEvent event) {
+ if (!event.visible) {
+ // Reset the view state
+ mAwaitingFirstLayout = true;
+ mLastTaskLaunchedWasFreeform = false;
}
}
}
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
+import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragDropTargetChangedEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent;
}
mStackScroller.reset();
mLayoutAlgorithm.reset();
+ requestLayout();
}
/** Requests that the views be synchronized with the model */
for (int i = taskViewCount - 1; i >= 0; i--) {
TaskView tv = taskViews.get(i);
Task task = tv.getTask();
- boolean occludesLaunchTarget = (launchTargetTask != null) &&
- launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
- tv.prepareEnterRecentsAnimation(task.isLaunchTarget, occludesLaunchTarget,
+ boolean hideTask = false;
+ boolean occludesLaunchTarget = false;
+ if (launchTargetTask != null) {
+ occludesLaunchTarget = launchTargetTask.group.isTaskAboveTask(task,
+ launchTargetTask);
+ hideTask = SystemServicesProxy.isFreeformStack(launchTargetTask.key.stackId) &&
+ SystemServicesProxy.isFreeformStack(task.key.stackId);
+ }
+ tv.prepareEnterRecentsAnimation(task.isLaunchTarget, hideTask, occludesLaunchTarget,
offscreenY);
}
mEnterAnimationComplete = true;
}
+ public final void onBusEvent(UpdateFreeformTaskViewVisibilityEvent event) {
+ List<TaskView> taskViews = getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = 0; i < taskViewCount; i++) {
+ TaskView tv = taskViews.get(i);
+ Task task = tv.getTask();
+ if (SystemServicesProxy.isFreeformStack(task.key.stackId)) {
+ tv.setVisibility(event.visible ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
+ }
+
/**
* Removes the task from the stack, and updates the focus to the next task in the stack if the
* removed TaskView was focused.
}
/** Gets the task */
- Task getTask() {
+ public Task getTask() {
return mTask;
}
mActionButtonView.setAlpha(1f);
mActionButtonView.setTranslationZ(mActionButtonTranslationZ);
}
+ setVisibility(View.VISIBLE);
}
/**
/** Prepares this task view for the enter-recents animations. This is called earlier in the
* first layout because the actual animation into recents may take a long time. */
- void prepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask,
- boolean occludesLaunchTarget, int offscreenY) {
+ void prepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask, boolean hideTask,
+ boolean occludesLaunchTarget, int offscreenY) {
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
int initialDim = getDim();
- if (launchState.launchedHasConfigurationChanged) {
+ if (hideTask) {
+ setVisibility(View.INVISIBLE);
+ } else if (launchState.launchedHasConfigurationChanged) {
// Just load the views as-is
} else if (launchState.launchedFromAppWithThumbnail) {
if (isTaskViewLaunchTargetTask) {