Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8683a263 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/28102349'] into 24Q3-release.

Change-Id: I151b0b299990b21634a49ffc1b5a499bd30734b9
parents 34cee0d7 62462a50
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -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)
    }

+9 −1
Original line number Diff line number Diff line
@@ -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) {