diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java new file mode 100644 index 0000000000..f2c9455f6a --- /dev/null +++ b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -0,0 +1,88 @@ +/* + * 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.uioverrides; + +import static android.view.View.VISIBLE; + +import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; + +import android.view.View; + +import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherStateManager; +import com.android.launcher3.LauncherStateManager.StateHandler; +import com.android.launcher3.uioverrides.RecentsViewStateController; +import com.android.launcher3.util.TouchController; + +/** + * Provides recents-related {@link UiFactory} logic and classes. + */ +public final class RecentsUiFactory { + + // Scale recents takes before animating in + private static final float RECENTS_PREPARE_SCALE = 1.33f; + + private RecentsUiFactory() {} + + /** + * Creates and returns a touch controller for swiping recents tasks. + * + * @param launcher the launcher activity + * @return the touch controller for recents tasks + */ + public static TouchController createTaskSwipeController(Launcher launcher) { + // We leave all input handling to the view itself. + return null; + } + + /** + * Creates and returns the controller responsible for recents view state transitions. + * + * @param launcher the launcher activity + * @return state handler for recents + */ + public static StateHandler createRecentsViewStateController(Launcher launcher) { + //TODO Override RecentsViewStateController on low RAM. + return new RecentsViewStateController(launcher); + } + + /** + * Prepare the recents view to animate in. + * + * @param launcher the launcher activity + */ + public static void prepareToShowRecents(Launcher launcher) { + View overview = launcher.getOverviewPanel(); + if (overview.getVisibility() != VISIBLE) { + SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE); + } + } + + /** + * Clean-up logic that occurs when recents is no longer in use/visible. + * + * @param launcher the launcher activity + */ + public static void resetRecents(Launcher launcher) {} + + /** + * Recents logic that triggers when launcher state changes or launcher activity stops/resumes. + * + * @param launcher the launcher activity + */ + public static void onLauncherStateOrResumeChanged(Launcher launcher) {} +} diff --git a/quickstep/recents_ui_overrides/src/.keep b/quickstep/recents_ui_overrides/src/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java new file mode 100644 index 0000000000..f18f43c4c4 --- /dev/null +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -0,0 +1,113 @@ +/* + * 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.uioverrides; + +import static android.view.View.VISIBLE; + +import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; +import static com.android.launcher3.LauncherState.NORMAL; +import static com.android.launcher3.LauncherState.OVERVIEW; + +import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherState; +import com.android.launcher3.LauncherStateManager.StateHandler; +import com.android.launcher3.anim.AnimatorPlaybackController; +import com.android.launcher3.util.TouchController; +import com.android.quickstep.views.RecentsView; + +/** + * Provides recents-related {@link UiFactory} logic and classes. + */ +public final class RecentsUiFactory { + + // Scale recents takes before animating in + private static final float RECENTS_PREPARE_SCALE = 1.33f; + + private RecentsUiFactory() {} + + /** + * Creates and returns a touch controller for swiping recents tasks. + * + * @param launcher the launcher activity + * @return the touch controller for recents tasks + */ + public static TouchController createTaskSwipeController(Launcher launcher) { + return new LauncherTaskViewController(launcher); + } + + /** + * Creates and returns the controller responsible for recents view state transitions. + * + * @param launcher the launcher activity + * @return state handler for recents + */ + public static StateHandler createRecentsViewStateController(Launcher launcher) { + return new RecentsViewStateController(launcher); + } + + /** + * Prepare the recents view to animate in. + * + * @param launcher the launcher activity + */ + public static void prepareToShowRecents(Launcher launcher) { + RecentsView overview = launcher.getOverviewPanel(); + if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) { + SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE); + } + } + + /** + * Clean-up logic that occurs when recents is no longer in use/visible. + * + * @param launcher the launcher activity + */ + public static void resetRecents(Launcher launcher) { + RecentsView recents = launcher.getOverviewPanel(); + recents.reset(); + } + + /** + * Recents logic that triggers when launcher state changes or launcher activity stops/resumes. + * + * @param launcher the launcher activity + */ + public static void onLauncherStateOrResumeChanged(Launcher launcher) { + LauncherState state = launcher.getStateManager().getState(); + if (state == NORMAL) { + launcher.getOverviewPanel().setSwipeDownShouldLaunchApp(false); + } + } + + private static final class LauncherTaskViewController extends + TaskViewTouchController { + + LauncherTaskViewController(Launcher activity) { + super(activity); + } + + @Override + protected boolean isRecentsInteractive() { + return mActivity.isInState(OVERVIEW); + } + + @Override + protected void onUserControlledAnimationCreated(AnimatorPlaybackController animController) { + mActivity.getStateManager().setCurrentUserControlledAnimation(animController); + } + } +} diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index 0ef67c41cd..3aa6482d6d 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -16,10 +16,8 @@ package com.android.launcher3.uioverrides; -import static android.view.View.VISIBLE; import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON; -import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; @@ -41,7 +39,6 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.Utilities; -import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.UiThreadHelper; @@ -49,7 +46,6 @@ import com.android.launcher3.util.UiThreadHelper.AsyncCommand; import com.android.quickstep.OverviewInteractionState; import com.android.quickstep.RecentsModel; import com.android.quickstep.util.RemoteFadeOutAnimationListener; -import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.ActivityCompat; import com.android.systemui.shared.system.WindowManagerWrapper; @@ -83,7 +79,11 @@ public class UiFactory { && !launcher.getDeviceProfile().isVerticalBarLayout()) { list.add(new StatusBarTouchController(launcher)); } - list.add(new LauncherTaskViewController(launcher)); + TouchController taskSwipeController = + RecentsUiFactory.createTaskSwipeController(launcher); + if (taskSwipeController != null) { + list.add(taskSwipeController); + } return list.toArray(new TouchController[list.size()]); } @@ -93,7 +93,8 @@ public class UiFactory { public static StateHandler[] getStateHandler(Launcher launcher) { return new StateHandler[] {launcher.getAllAppsController(), launcher.getWorkspace(), - new RecentsViewStateController(launcher), new BackButtonAlphaHandler(launcher)}; + RecentsUiFactory.createRecentsViewStateController(launcher), + new BackButtonAlphaHandler(launcher)}; } /** @@ -113,8 +114,7 @@ public class UiFactory { } public static void resetOverview(Launcher launcher) { - RecentsView recents = launcher.getOverviewPanel(); - recents.reset(); + RecentsUiFactory.resetRecents(launcher); } public static void onCreate(Launcher launcher) { @@ -186,9 +186,7 @@ public class UiFactory { visible ? 1 : 0, profile.hotseatBarSizePx); } - if (state == NORMAL) { - launcher.getOverviewPanel().setSwipeDownShouldLaunchApp(false); - } + RecentsUiFactory.onLauncherStateOrResumeChanged(launcher); } public static void onTrimMemory(Context context, int level) { @@ -242,26 +240,6 @@ public class UiFactory { } public static void prepareToShowOverview(Launcher launcher) { - RecentsView overview = launcher.getOverviewPanel(); - if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) { - SCALE_PROPERTY.set(overview, 1.33f); - } - } - - private static class LauncherTaskViewController extends TaskViewTouchController { - - public LauncherTaskViewController(Launcher activity) { - super(activity); - } - - @Override - protected boolean isRecentsInteractive() { - return mActivity.isInState(OVERVIEW); - } - - @Override - protected void onUserControlledAnimationCreated(AnimatorPlaybackController animController) { - mActivity.getStateManager().setCurrentUserControlledAnimation(animController); - } + RecentsUiFactory.prepareToShowRecents(launcher); } }