diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt index c45c66741d..7f9d8a390e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt @@ -27,6 +27,7 @@ import android.view.View import android.view.ViewGroup import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.animation.Interpolator +import android.window.OnBackInvokedDispatcher import androidx.core.view.updateLayoutParams import com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE import com.android.app.animation.Interpolators.EMPHASIZED_DECELERATE @@ -66,11 +67,14 @@ constructor( /** Container where the tooltip's body should be inflated. */ lateinit var content: ViewGroup private set + private lateinit var arrow: View /** Callback invoked when the tooltip is being closed. */ var onCloseCallback: () -> Unit = {} private var openCloseAnimator: AnimatorSet? = null + /** Used to set whether users can tap outside the current tooltip window to dismiss it */ + var allowTouchDismissal = true /** Animates the tooltip into view. */ fun show() { @@ -134,14 +138,25 @@ constructor( override fun isOfType(type: Int): Boolean = type and TYPE_TASKBAR_EDUCATION_DIALOG != 0 override fun onControllerInterceptTouchEvent(ev: MotionEvent?): Boolean { - if (ev?.action == ACTION_DOWN && !activityContext.dragLayer.isEventOverView(this, ev)) { + if ( + ev?.action == ACTION_DOWN && + !activityContext.dragLayer.isEventOverView(this, ev) && + allowTouchDismissal + ) { close(true) } return false } + override fun onAttachedToWindow() { + super.onAttachedToWindow() + findOnBackInvokedDispatcher() + ?.registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_DEFAULT, this) + } + override fun onDetachedFromWindow() { super.onDetachedFromWindow() + findOnBackInvokedDispatcher()?.unregisterOnBackInvokedCallback(this) Settings.Secure.putInt(mContext.contentResolver, LAUNCHER_TASKBAR_EDUCATION_SHOWING, 0) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt index 5cbd5c95f0..d57c4838d7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt @@ -86,10 +86,13 @@ open class TaskbarEduTooltipController(context: Context) : !activityContext.isPhoneMode && !activityContext.isTinyTaskbar } + private val isOpen: Boolean get() = tooltip?.isOpen ?: false + val isBeforeTooltipFeaturesStep: Boolean get() = isTooltipEnabled && tooltipStep <= TOOLTIP_STEP_FEATURES + private lateinit var controllers: TaskbarControllers // Keep track of whether the user has seen the Search Edu @@ -152,6 +155,7 @@ open class TaskbarEduTooltipController(context: Context) : tooltipStep = TOOLTIP_STEP_NONE inflateTooltip(R.layout.taskbar_edu_features) tooltip?.run { + allowTouchDismissal = false val splitscreenAnim = requireViewById(R.id.splitscreen_animation) val suggestionsAnim = requireViewById(R.id.suggestions_animation) val pinningAnim = requireViewById(R.id.pinning_animation) @@ -216,6 +220,7 @@ open class TaskbarEduTooltipController(context: Context) : inflateTooltip(R.layout.taskbar_edu_pinning) tooltip?.run { + allowTouchDismissal = true requireViewById(R.id.standalone_pinning_animation) .supportLightTheme() @@ -260,6 +265,7 @@ open class TaskbarEduTooltipController(context: Context) : userHasSeenSearchEdu = true inflateTooltip(R.layout.taskbar_edu_search) tooltip?.run { + allowTouchDismissal = true requireViewById(R.id.search_edu_animation).supportLightTheme() val eduSubtitle: TextView = requireViewById(R.id.search_edu_text) showDisclosureText(eduSubtitle) @@ -332,7 +338,9 @@ open class TaskbarEduTooltipController(context: Context) : } /** Closes the current [tooltip]. */ - fun hide() = tooltip?.close(true) + fun hide() { + tooltip?.close(true) + } /** Initializes [tooltip] with content from [contentResId]. */ private fun inflateTooltip(@LayoutRes contentResId: Int) {