Prevent Taskbar edu dismissal from touching outside of the window.

In an effort to encourage users to look at Taskbar edu more thoroughly,
this change makes it so users have to press the 'Done' button explicitly
to close the taskbar edu window. This change also adds the ability for
it to be dismissed by the back gesture. It only applies to the features
edu, and not other taskbar educations.

Fix: 349612575
Test: Manually run all versions of taskbar edu and ensure that the edu only goes away with back gesture, swipe up or clicking on the DONE button
Flag: EXEMPT bugfix
Change-Id: I9c456b9efddc6de5f292d6a14b1ce9daee7efaa3
This commit is contained in:
Saumya Prakash
2024-06-28 19:04:26 +00:00
parent 20a077029c
commit 17339843e7
2 changed files with 25 additions and 2 deletions
@@ -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)
}
@@ -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<LottieAnimationView>(R.id.splitscreen_animation)
val suggestionsAnim = requireViewById<LottieAnimationView>(R.id.suggestions_animation)
val pinningAnim = requireViewById<LottieAnimationView>(R.id.pinning_animation)
@@ -216,6 +220,7 @@ open class TaskbarEduTooltipController(context: Context) :
inflateTooltip(R.layout.taskbar_edu_pinning)
tooltip?.run {
allowTouchDismissal = true
requireViewById<LottieAnimationView>(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<LottieAnimationView>(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) {