diff --git a/quickstep/res/values/override.xml b/quickstep/res/values/override.xml index 29779a711e..cba1f5bcd0 100644 --- a/quickstep/res/values/override.xml +++ b/quickstep/res/values/override.xml @@ -33,6 +33,8 @@ com.android.launcher3.taskbar.TaskbarModelCallbacksFactory + com.android.launcher3.taskbar.TaskbarViewCallbacksFactory + com.android.quickstep.LauncherRestoreEventLoggerImpl diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 7a69c556c0..f3db0eea43 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -120,8 +120,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * * Use {@link #getStashDuration()} to query duration */ - private static final long TASKBAR_STASH_DURATION = - InsetsController.ANIMATION_DURATION_RESIZE; + private static final long TASKBAR_STASH_DURATION = InsetsController.ANIMATION_DURATION_RESIZE; /** * How long to stash/unstash transient taskbar. diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index 666d98e9c9..d9e23309bd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -85,7 +85,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar private final TaskbarActivityContext mActivityContext; // Initialized in init. - private TaskbarViewController.TaskbarViewCallbacks mControllerCallbacks; + private TaskbarViewCallbacks mControllerCallbacks; private View.OnClickListener mIconClickListener; private View.OnLongClickListener mIconLongClickListener; @@ -258,7 +258,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar return mIconTouchSize; } - protected void init(TaskbarViewController.TaskbarViewCallbacks callbacks) { + protected void init(TaskbarViewCallbacks callbacks) { // set taskbar pane title so that accessibility service know it window and focuses. setAccessibilityPaneTitle(getContext().getString(R.string.taskbar_a11y_title)); mControllerCallbacks = callbacks; @@ -267,6 +267,10 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar if (mAllAppsButton != null) { mAllAppsButton.setOnClickListener(mControllerCallbacks.getAllAppsButtonClickListener()); + mAllAppsButton.setOnLongClickListener( + mControllerCallbacks.getAllAppsButtonLongClickListener()); + mAllAppsButton.setHapticFeedbackEnabled( + mControllerCallbacks.isAllAppsButtonHapticFeedbackEnabled()); } if (mTaskbarDivider != null) { mTaskbarDivider.setOnLongClickListener( diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java new file mode 100644 index 0000000000..486e53c818 --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2024 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.taskbar; + +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_ALLAPPS_BUTTON_LONG_PRESS; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP; + +import android.view.InputDevice; +import android.view.MotionEvent; +import android.view.View; + +/** + * Callbacks for {@link TaskbarView} to interact with its controller. + */ +public class TaskbarViewCallbacks { + + private final TaskbarActivityContext mActivity; + private final TaskbarControllers mControllers; + private final TaskbarView mTaskbarView; + + public TaskbarViewCallbacks(TaskbarActivityContext activity, TaskbarControllers controllers, + TaskbarView taskbarView) { + mActivity = activity; + mControllers = controllers; + mTaskbarView = taskbarView; + } + + public View.OnClickListener getIconOnClickListener() { + return mActivity.getItemOnClickListener(); + } + + public View.OnClickListener getAllAppsButtonClickListener() { + return v -> { + mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP); + mControllers.taskbarAllAppsController.toggle(); + }; + } + + public View.OnLongClickListener getAllAppsButtonLongClickListener() { + return v -> { + mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_ALLAPPS_BUTTON_LONG_PRESS); + return true; + }; + } + + public boolean isAllAppsButtonHapticFeedbackEnabled() { + return false; + } + + public View.OnLongClickListener getTaskbarDividerLongClickListener() { + return v -> { + mControllers.taskbarPinningController.showPinningView(v); + return true; + }; + } + + public View.OnTouchListener getTaskbarDividerRightClickListener() { + return (v, event) -> { + if (event.isFromSource(InputDevice.SOURCE_MOUSE) + && event.getButtonState() == MotionEvent.BUTTON_SECONDARY) { + mControllers.taskbarPinningController.showPinningView(v); + return true; + } + return false; + }; + } + + public View.OnLongClickListener getIconOnLongClickListener() { + return mControllers.taskbarDragController::startDragOnLongClick; + } + + /** Gets the hover listener for the provided icon view. */ + public View.OnHoverListener getIconOnHoverListener(View icon) { + return new TaskbarHoverToolTipController(mActivity, mTaskbarView, icon); + } + + /** + * Notifies launcher to update icon alignment. + */ + public void notifyIconLayoutBoundsChanged() { + mControllers.uiController.onIconLayoutBoundsChanged(); + } + + /** + * Notifies the taskbar scrim when the visibility of taskbar changes. + */ + public void notifyVisibilityChanged() { + mControllers.taskbarScrimViewController.onTaskbarVisibilityChanged( + mTaskbarView.getVisibility()); + } +} diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacksFactory.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacksFactory.kt new file mode 100644 index 0000000000..ba0f5a01b0 --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacksFactory.kt @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 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.taskbar + +import android.content.Context +import com.android.launcher3.R +import com.android.launcher3.util.ResourceBasedOverride +import com.android.launcher3.util.ResourceBasedOverride.Overrides + +/** Creates [TaskbarViewCallbacks] instances. */ +open class TaskbarViewCallbacksFactory : ResourceBasedOverride { + + open fun create( + activity: TaskbarActivityContext, + controllers: TaskbarControllers, + taskbarView: TaskbarView, + ): TaskbarViewCallbacks = TaskbarViewCallbacks(activity, controllers, taskbarView) + + companion object { + @JvmStatic + fun newInstance(context: Context): TaskbarViewCallbacksFactory { + return Overrides.getObject( + TaskbarViewCallbacksFactory::class.java, + context, + R.string.taskbar_view_callbacks_factory_class, + ) + } + } +} diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 614dc14b0f..5494853d2c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -26,7 +26,6 @@ import static com.android.launcher3.anim.AnimatedFloat.VALUE; import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION; import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP; import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_PERSISTENT; import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_TRANSIENT; import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE; @@ -41,7 +40,6 @@ import android.animation.ValueAnimator; import android.annotation.NonNull; import android.graphics.Rect; import android.util.Log; -import android.view.InputDevice; import android.view.MotionEvent; import android.view.View; import android.view.animation.Interpolator; @@ -193,7 +191,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar public void init(TaskbarControllers controllers) { mControllers = controllers; - mTaskbarView.init(new TaskbarViewCallbacks()); + mTaskbarView.init(TaskbarViewCallbacksFactory.newInstance(mActivity).create( + mActivity, mControllers, mTaskbarView)); mTaskbarView.getLayoutParams().height = mActivity.isPhoneMode() ? mActivity.getResources().getDimensionPixelSize(R.dimen.taskbar_phone_size) : mActivity.getDeviceProfile().taskbarHeight; @@ -891,66 +890,4 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mModelCallbacks.updateRunningApps(); } - /** - * Callbacks for {@link TaskbarView} to interact with its controller. - */ - public class TaskbarViewCallbacks { - private final float mSquaredTouchSlop = Utilities.squaredTouchSlop(mActivity); - - private float mDownX, mDownY; - private boolean mCanceledStashHint; - - public View.OnClickListener getIconOnClickListener() { - return mActivity.getItemOnClickListener(); - } - - public View.OnClickListener getAllAppsButtonClickListener() { - return v -> { - mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP); - mControllers.taskbarAllAppsController.toggle(); - }; - } - - public View.OnLongClickListener getTaskbarDividerLongClickListener() { - return v -> { - mControllers.taskbarPinningController.showPinningView(v); - return true; - }; - } - - public View.OnTouchListener getTaskbarDividerRightClickListener() { - return (v, event) -> { - if (event.isFromSource(InputDevice.SOURCE_MOUSE) - && event.getButtonState() == MotionEvent.BUTTON_SECONDARY) { - mControllers.taskbarPinningController.showPinningView(v); - return true; - } - return false; - }; - } - - public View.OnLongClickListener getIconOnLongClickListener() { - return mControllers.taskbarDragController::startDragOnLongClick; - } - - /** Gets the hover listener for the provided icon view. */ - public View.OnHoverListener getIconOnHoverListener(View icon) { - return new TaskbarHoverToolTipController(mActivity, mTaskbarView, icon); - } - - /** - * Notifies launcher to update icon alignment. - */ - public void notifyIconLayoutBoundsChanged() { - mControllers.uiController.onIconLayoutBoundsChanged(); - } - - /** - * Notifies the taskbar scrim when the visibility of taskbar changes. - */ - public void notifyVisibilityChanged() { - mControllers.taskbarScrimViewController.onTaskbarVisibilityChanged( - mTaskbarView.getVisibility()); - } - } } diff --git a/res/values/config.xml b/res/values/config.xml index 1b74238353..21d6024583 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -89,6 +89,7 @@ + diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 2a0f0302e4..2aabb7cd88 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -636,6 +636,9 @@ public class StatsLogManager implements ResourceBasedOverride { @UiEvent(doc = "User tapped taskbar All Apps button.") LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP(1057), + @UiEvent(doc = "User long pressed taskbar All Apps button.") + LAUNCHER_TASKBAR_ALLAPPS_BUTTON_LONG_PRESS(1607), + @UiEvent(doc = "User tapped on Share app system shortcut.") LAUNCHER_SYSTEM_SHORTCUT_APP_SHARE_TAP(1075),