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

Commit 4a47e477 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Dismiss desktop windowing education tooltips after 12 seconds.

Fixes: 392792134
Flag: com.android.window.flags.enable_desktop_windowing_app_handle_education
Test: atest AppHandleEducationControllerTest and manual test
Change-Id: Ifecf55879657a81cf09ed7790951726e987d3e37
parent a0f003ff
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationToolt
import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationTooltipController.TooltipEducationViewConfig
import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationTooltipController.TooltipEducationViewConfig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainCoroutineDispatcher
import kotlinx.coroutines.MainCoroutineDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filter
@@ -89,6 +90,8 @@ class AppHandleEducationController(
                        showEducation(captionState)
                        showEducation(captionState)
                        appHandleEducationDatastoreRepository
                        appHandleEducationDatastoreRepository
                            .updateAppHandleHintViewedTimestampMillis(true)
                            .updateAppHandleHintViewedTimestampMillis(true)
                        delay(TOOLTIP_VISIBLE_DURATION_MILLIS)
                        windowingEducationViewController.hideEducationTooltip()
                    }
                    }
            }
            }


@@ -110,6 +113,8 @@ class AppHandleEducationController(
                        showWindowingImageButtonTooltip(captionState as CaptionState.AppHandle)
                        showWindowingImageButtonTooltip(captionState as CaptionState.AppHandle)
                        appHandleEducationDatastoreRepository
                        appHandleEducationDatastoreRepository
                            .updateEnterDesktopModeHintViewedTimestampMillis(true)
                            .updateEnterDesktopModeHintViewedTimestampMillis(true)
                        delay(TOOLTIP_VISIBLE_DURATION_MILLIS)
                        windowingEducationViewController.hideEducationTooltip()
                    }
                    }
            }
            }


@@ -131,6 +136,8 @@ class AppHandleEducationController(
                        showExitWindowingTooltip(captionState as CaptionState.AppHeader)
                        showExitWindowingTooltip(captionState as CaptionState.AppHeader)
                        appHandleEducationDatastoreRepository
                        appHandleEducationDatastoreRepository
                            .updateExitDesktopModeHintViewedTimestampMillis(true)
                            .updateExitDesktopModeHintViewedTimestampMillis(true)
                        delay(TOOLTIP_VISIBLE_DURATION_MILLIS)
                        windowingEducationViewController.hideEducationTooltip()
                    }
                    }
            }
            }
        }
        }
@@ -145,8 +152,6 @@ class AppHandleEducationController(
        val appHandleBounds = (captionState as CaptionState.AppHandle).globalAppHandleBounds
        val appHandleBounds = (captionState as CaptionState.AppHandle).globalAppHandleBounds
        val tooltipGlobalCoordinates =
        val tooltipGlobalCoordinates =
            Point(appHandleBounds.left + appHandleBounds.width() / 2, appHandleBounds.bottom)
            Point(appHandleBounds.left + appHandleBounds.width() / 2, appHandleBounds.bottom)
        // TODO: b/370546801 - Differentiate between user dismissing the tooltip vs following the
        // cue.
        // Populate information important to inflate app handle education tooltip.
        // Populate information important to inflate app handle education tooltip.
        val appHandleTooltipConfig =
        val appHandleTooltipConfig =
            TooltipEducationViewConfig(
            TooltipEducationViewConfig(
@@ -323,6 +328,9 @@ class AppHandleEducationController(
                    400L,
                    400L,
                )
                )


        val TOOLTIP_VISIBLE_DURATION_MILLIS: Long
            get() = SystemProperties.getLong("persist.windowing_tooltip_visible_duration", 12000L)

        val FORCE_SHOW_DESKTOP_MODE_EDUCATION: Boolean
        val FORCE_SHOW_DESKTOP_MODE_EDUCATION: Boolean
            get() =
            get() =
                SystemProperties.getBoolean(
                SystemProperties.getBoolean(
+1 −2
Original line number Original line Diff line number Diff line
@@ -53,7 +53,6 @@ class DesktopWindowingEducationTooltipController(
    private val additionalSystemViewContainerFactory: AdditionalSystemViewContainer.Factory,
    private val additionalSystemViewContainerFactory: AdditionalSystemViewContainer.Factory,
    private val displayController: DisplayController,
    private val displayController: DisplayController,
) : OnDisplayChangingListener {
) : OnDisplayChangingListener {
  // TODO: b/369384567 - Set tooltip color scheme to match LT/DT of app theme
  private var tooltipView: View? = null
  private var tooltipView: View? = null
  private var animator: PhysicsAnimator<View>? = null
  private var animator: PhysicsAnimator<View>? = null
  private val springConfig by lazy {
  private val springConfig by lazy {
@@ -90,7 +89,7 @@ class DesktopWindowingEducationTooltipController(
  }
  }


  /** Hide the current education view if visible */
  /** Hide the current education view if visible */
  private fun hideEducationTooltip() = animateHideTooltipTransition { cleanUp() }
  fun hideEducationTooltip() = animateHideTooltipTransition { cleanUp() }


  /** Create education view by inflating layout provided. */
  /** Create education view by inflating layout provided. */
  private fun createEducationTooltipView(
  private fun createEducationTooltipView(
+22 −2
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.desktopmode.CaptionState
import com.android.wm.shell.desktopmode.CaptionState
import com.android.wm.shell.desktopmode.WindowDecorCaptionHandleRepository
import com.android.wm.shell.desktopmode.WindowDecorCaptionHandleRepository
import com.android.wm.shell.desktopmode.education.AppHandleEducationController.Companion.APP_HANDLE_EDUCATION_DELAY_MILLIS
import com.android.wm.shell.desktopmode.education.AppHandleEducationController.Companion.APP_HANDLE_EDUCATION_DELAY_MILLIS
import com.android.wm.shell.desktopmode.education.AppHandleEducationController.Companion.TOOLTIP_VISIBLE_DURATION_MILLIS
import com.android.wm.shell.desktopmode.education.data.AppHandleEducationDatastoreRepository
import com.android.wm.shell.desktopmode.education.data.AppHandleEducationDatastoreRepository
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource
@@ -126,6 +127,23 @@ class AppHandleEducationControllerTest : ShellTestCase() {
                .updateAppHandleHintViewedTimestampMillis(eq(true))
                .updateAppHandleHintViewedTimestampMillis(eq(true))
        }
        }


    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_HANDLE_EDUCATION)
    fun init_appHandleEducationVisible_afterDelayTooltipShouldBeDismissed() =
        testScope.runTest {
            // App handle is visible. Should show education tooltip.
            setShouldShowDesktopModeEducation(true)
            // Simulate app handle visible.
            testCaptionStateFlow.value = createAppHandleState()
            // Wait for first tooltip to showup.
            waitForBufferDelay()

            // Wait until tooltip gets dismissed
            waitForBufferDelay(TOOLTIP_VISIBLE_DURATION_MILLIS + 1000L)

            verify(mockTooltipController, times(1)).hideEducationTooltip()
        }

    @Test
    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_HANDLE_EDUCATION)
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_HANDLE_EDUCATION)
    fun init_appHandleVisibleAndMenuExpanded_shouldCallShowEducationTooltipAndMarkAsViewed() =
    fun init_appHandleVisibleAndMenuExpanded_shouldCallShowEducationTooltipAndMarkAsViewed() =
@@ -368,8 +386,10 @@ class AppHandleEducationControllerTest : ShellTestCase() {
     * Class under test waits for some time before showing education, simulate advance time before
     * Class under test waits for some time before showing education, simulate advance time before
     * verifying or moving forward
     * verifying or moving forward
     */
     */
    private fun TestScope.waitForBufferDelay() {
    private fun TestScope.waitForBufferDelay(
        advanceTimeBy(APP_HANDLE_EDUCATION_DELAY_BUFFER_MILLIS)
        delay: Long = APP_HANDLE_EDUCATION_DELAY_BUFFER_MILLIS
    ) {
        advanceTimeBy(delay)
        runCurrent()
        runCurrent()
    }
    }