diff options
3 files changed, 33 insertions, 6 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/education/AppHandleEducationController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/education/AppHandleEducationController.kt index 3ce810a83632..39dc48d6d206 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/education/AppHandleEducationController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/education/AppHandleEducationController.kt @@ -37,6 +37,7 @@ import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationToolt import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationTooltipController.TooltipEducationViewConfig import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainCoroutineDispatcher +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.filter @@ -89,6 +90,8 @@ class AppHandleEducationController( showEducation(captionState) appHandleEducationDatastoreRepository .updateAppHandleHintViewedTimestampMillis(true) + delay(TOOLTIP_VISIBLE_DURATION_MILLIS) + windowingEducationViewController.hideEducationTooltip() } } @@ -110,6 +113,8 @@ class AppHandleEducationController( showWindowingImageButtonTooltip(captionState as CaptionState.AppHandle) appHandleEducationDatastoreRepository .updateEnterDesktopModeHintViewedTimestampMillis(true) + delay(TOOLTIP_VISIBLE_DURATION_MILLIS) + windowingEducationViewController.hideEducationTooltip() } } @@ -131,6 +136,8 @@ class AppHandleEducationController( showExitWindowingTooltip(captionState as CaptionState.AppHeader) appHandleEducationDatastoreRepository .updateExitDesktopModeHintViewedTimestampMillis(true) + delay(TOOLTIP_VISIBLE_DURATION_MILLIS) + windowingEducationViewController.hideEducationTooltip() } } } @@ -145,8 +152,6 @@ class AppHandleEducationController( val appHandleBounds = (captionState as CaptionState.AppHandle).globalAppHandleBounds val tooltipGlobalCoordinates = 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. val appHandleTooltipConfig = TooltipEducationViewConfig( @@ -323,6 +328,9 @@ class AppHandleEducationController( 400L, ) + val TOOLTIP_VISIBLE_DURATION_MILLIS: Long + get() = SystemProperties.getLong("persist.windowing_tooltip_visible_duration", 12000L) + val FORCE_SHOW_DESKTOP_MODE_EDUCATION: Boolean get() = SystemProperties.getBoolean( diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipController.kt index 4054de490add..7ffa74f89a52 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/education/DesktopWindowingEducationTooltipController.kt @@ -53,7 +53,6 @@ class DesktopWindowingEducationTooltipController( private val additionalSystemViewContainerFactory: AdditionalSystemViewContainer.Factory, private val displayController: DisplayController, ) : OnDisplayChangingListener { - // TODO: b/369384567 - Set tooltip color scheme to match LT/DT of app theme private var tooltipView: View? = null private var animator: PhysicsAnimator<View>? = null private val springConfig by lazy { @@ -90,7 +89,7 @@ class DesktopWindowingEducationTooltipController( } /** Hide the current education view if visible */ - private fun hideEducationTooltip() = animateHideTooltipTransition { cleanUp() } + fun hideEducationTooltip() = animateHideTooltipTransition { cleanUp() } /** Create education view by inflating layout provided. */ private fun createEducationTooltipView( diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/education/AppHandleEducationControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/education/AppHandleEducationControllerTest.kt index 493a8c83c48e..7d2a8082c43e 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/education/AppHandleEducationControllerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/education/AppHandleEducationControllerTest.kt @@ -29,6 +29,7 @@ import com.android.wm.shell.ShellTestCase import com.android.wm.shell.desktopmode.CaptionState 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.TOOLTIP_VISIBLE_DURATION_MILLIS import com.android.wm.shell.desktopmode.education.data.AppHandleEducationDatastoreRepository import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource @@ -128,6 +129,23 @@ class AppHandleEducationControllerTest : ShellTestCase() { @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 + @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_HANDLE_EDUCATION) fun init_appHandleVisibleAndMenuExpanded_shouldCallShowEducationTooltipAndMarkAsViewed() = testScope.runTest { setShouldShowDesktopModeEducation(true) @@ -368,8 +386,10 @@ class AppHandleEducationControllerTest : ShellTestCase() { * Class under test waits for some time before showing education, simulate advance time before * verifying or moving forward */ - private fun TestScope.waitForBufferDelay() { - advanceTimeBy(APP_HANDLE_EDUCATION_DELAY_BUFFER_MILLIS) + private fun TestScope.waitForBufferDelay( + delay: Long = APP_HANDLE_EDUCATION_DELAY_BUFFER_MILLIS + ) { + advanceTimeBy(delay) runCurrent() } |