diff --git a/go/quickstep/src/com/android/launcher3/LauncherRecentsToActivityHelper.java b/go/quickstep/src/com/android/launcher3/LauncherRecentsToActivityHelper.java new file mode 100644 index 0000000000..c12da946f8 --- /dev/null +++ b/go/quickstep/src/com/android/launcher3/LauncherRecentsToActivityHelper.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2019 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.launcher3; + +import static com.android.launcher3.LauncherState.NORMAL; + +import com.android.quickstep.RecentsToActivityHelper; + +/** + * {@link RecentsToActivityHelper} for when the recents implementation is contained in + * {@link Launcher}. + */ +public final class LauncherRecentsToActivityHelper implements RecentsToActivityHelper { + + private final Launcher mLauncher; + + public LauncherRecentsToActivityHelper(Launcher launcher) { + mLauncher = launcher; + } + + @Override + public void leaveRecents() { + mLauncher.getStateManager().goToState(NORMAL); + } +} diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index f1cb75b9d1..784af7d11a 100644 --- a/go/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -23,6 +23,7 @@ import android.util.FloatProperty; import androidx.annotation.NonNull; import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherRecentsToActivityHelper; import com.android.quickstep.views.IconRecentsView; /** @@ -33,6 +34,8 @@ public final class RecentsViewStateController extends public RecentsViewStateController(@NonNull Launcher launcher) { super(launcher); + launcher.getOverviewPanel().setRecentsToActivityHelper( + new LauncherRecentsToActivityHelper(launcher)); } @Override diff --git a/go/quickstep/src/com/android/quickstep/FallbackRecentsToActivityHelper.java b/go/quickstep/src/com/android/quickstep/FallbackRecentsToActivityHelper.java new file mode 100644 index 0000000000..a845f93a9d --- /dev/null +++ b/go/quickstep/src/com/android/quickstep/FallbackRecentsToActivityHelper.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2019 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.quickstep; + +/** + * {@link RecentsToActivityHelper} for when we are using the fallback recents in + * {@link BaseRecentsActivity}. + */ +public final class FallbackRecentsToActivityHelper implements RecentsToActivityHelper { + + BaseRecentsActivity mActivity; + + public FallbackRecentsToActivityHelper(BaseRecentsActivity activity) { + mActivity = activity; + } + + @Override + public void leaveRecents() { + mActivity.startHome(); + } +} diff --git a/go/quickstep/src/com/android/quickstep/RecentsActivity.java b/go/quickstep/src/com/android/quickstep/RecentsActivity.java index a186aaa839..c814a71f08 100644 --- a/go/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/go/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -36,6 +36,7 @@ public final class RecentsActivity extends BaseRecentsActivity { setContentView(R.layout.fallback_recents_activity); mRecentsRootView = findViewById(R.id.drag_layer); mIconRecentsView = findViewById(R.id.overview_panel); + mIconRecentsView.setRecentsToActivityHelper(new FallbackRecentsToActivityHelper(this)); } @Override diff --git a/go/quickstep/src/com/android/quickstep/RecentsToActivityHelper.java b/go/quickstep/src/com/android/quickstep/RecentsToActivityHelper.java new file mode 100644 index 0000000000..8f3b707fe1 --- /dev/null +++ b/go/quickstep/src/com/android/quickstep/RecentsToActivityHelper.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 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.quickstep; + +/** + * Generic interface providing methods to the recents implementation that allow it to callback to + * the containing activity. + */ +public interface RecentsToActivityHelper { + + /** + * The default action to take when leaving/closing recents. In general, this should be used to + * go to the appropriate home state. + */ + void leaveRecents(); +} diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index 8c7177babe..e294282c3e 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -26,12 +26,14 @@ import android.view.View; import android.view.ViewDebug; import android.widget.FrameLayout; +import androidx.annotation.NonNull; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver; import com.android.launcher3.R; +import com.android.quickstep.RecentsToActivityHelper; import com.android.quickstep.TaskAdapter; import com.android.quickstep.TaskInputController; import com.android.quickstep.TaskListLoader; @@ -87,6 +89,7 @@ public final class IconRecentsView extends FrameLayout { private final TaskAdapter mTaskAdapter; private final TaskInputController mTaskInputController; + private RecentsToActivityHelper mActivityHelper; private float mTranslationYFactor; private RecyclerView mTaskRecyclerView; private View mEmptyView; @@ -127,6 +130,15 @@ public final class IconRecentsView extends FrameLayout { } } + /** + * Set activity helper for the view to callback to. + * + * @param helper the activity helper + */ + public void setRecentsToActivityHelper(@NonNull RecentsToActivityHelper helper) { + mActivityHelper = helper; + } + /** * Logic for when we know we are going to overview/recents and will be putting up the recents * view. This should be used to prepare recents (e.g. load any task data, etc.) before it @@ -160,7 +172,7 @@ public final class IconRecentsView extends FrameLayout { int taskListSize = mTaskLoader.getCurrentTaskList().size(); if (mEmptyView.getVisibility() != VISIBLE && taskListSize == 0) { crossfadeViews(mEmptyView, mTaskRecyclerView); - // TODO: Go to home. + mActivityHelper.leaveRecents(); } if (mTaskRecyclerView.getVisibility() != VISIBLE && taskListSize > 0) { crossfadeViews(mTaskRecyclerView, mEmptyView);