Loading packages/SystemUI/ktfmt_includes.txt +0 −1 Original line number Original line Diff line number Diff line Loading @@ -485,7 +485,6 @@ -packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt -packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewInfo.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewInfo.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarRootView.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarRootView.kt -packages/SystemUI/src/com/android/systemui/toast/ToastDefaultAnimation.kt -packages/SystemUI/src/com/android/systemui/toast/ToastDefaultAnimation.kt -packages/SystemUI/src/com/android/systemui/toast/ToastLogger.kt -packages/SystemUI/src/com/android/systemui/toast/ToastLogger.kt Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -2362,6 +2362,8 @@ <string name="media_transfer_playing_different_device">Playing on <xliff:g id="deviceName" example="My Tablet">%1$s</xliff:g></string> <string name="media_transfer_playing_different_device">Playing on <xliff:g id="deviceName" example="My Tablet">%1$s</xliff:g></string> <!-- Text informing the user that the media transfer has failed because something went wrong. [CHAR LIsMIT=50] --> <!-- Text informing the user that the media transfer has failed because something went wrong. [CHAR LIsMIT=50] --> <string name="media_transfer_failed">Something went wrong. Try again.</string> <string name="media_transfer_failed">Something went wrong. Try again.</string> <!-- Text to indicate that a media transfer is currently in-progress, aka loading. [CHAR LIMIT=NONE] --> <string name="media_transfer_loading">Loading</string> <!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] --> <!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] --> <string name="controls_error_timeout">Inactive, check app</string> <string name="controls_error_timeout">Inactive, check app</string> Loading packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt +50 −44 Original line number Original line Diff line number Diff line Loading @@ -65,11 +65,11 @@ import javax.inject.Inject * in the list of notifications until the user dismisses them. * in the list of notifications until the user dismisses them. * * * Only one chipbar may be shown at a time. * Only one chipbar may be shown at a time. * TODO(b/245610654): Should we just display whichever chipbar was most recently requested, or do we * need to maintain a priority ordering? */ */ @SysUISingleton @SysUISingleton open class ChipbarCoordinator @Inject constructor( open class ChipbarCoordinator @Inject constructor( context: Context, context: Context, logger: ChipbarLogger, logger: ChipbarLogger, windowManager: WindowManager, windowManager: WindowManager, Loading @@ -84,7 +84,8 @@ open class ChipbarCoordinator @Inject constructor( private val vibratorHelper: VibratorHelper, private val vibratorHelper: VibratorHelper, wakeLockBuilder: WakeLock.Builder, wakeLockBuilder: WakeLock.Builder, systemClock: SystemClock, systemClock: SystemClock, ) : TemporaryViewDisplayController<ChipbarInfo, ChipbarLogger>( ) : TemporaryViewDisplayController<ChipbarInfo, ChipbarLogger>( context, context, logger, logger, windowManager, windowManager, Loading @@ -100,14 +101,10 @@ open class ChipbarCoordinator @Inject constructor( private lateinit var parent: ChipbarRootView private lateinit var parent: ChipbarRootView override val windowLayoutParams = commonWindowLayoutParams.apply { override val windowLayoutParams = gravity = Gravity.TOP.or(Gravity.CENTER_HORIZONTAL) commonWindowLayoutParams.apply { gravity = Gravity.TOP.or(Gravity.CENTER_HORIZONTAL) } } override fun updateView( override fun updateView(newInfo: ChipbarInfo, currentView: ViewGroup) { newInfo: ChipbarInfo, currentView: ViewGroup ) { logger.logViewUpdate( logger.logViewUpdate( newInfo.windowTitle, newInfo.windowTitle, newInfo.text.loadText(context), newInfo.text.loadText(context), Loading @@ -123,7 +120,8 @@ open class ChipbarCoordinator @Inject constructor( // Detect falsing touches on the chip. // Detect falsing touches on the chip. parent = currentView.requireViewById(R.id.chipbar_root_view) parent = currentView.requireViewById(R.id.chipbar_root_view) parent.touchHandler = object : Gefingerpoken { parent.touchHandler = object : Gefingerpoken { override fun onTouchEvent(ev: MotionEvent?): Boolean { override fun onTouchEvent(ev: MotionEvent?): Boolean { falsingCollector.onTouchEvent(ev) falsingCollector.onTouchEvent(ev) return false return false Loading Loading @@ -155,8 +153,10 @@ open class ChipbarCoordinator @Inject constructor( if (newInfo.endItem is ChipbarEndItem.Button) { if (newInfo.endItem is ChipbarEndItem.Button) { TextViewBinder.bind(buttonView, newInfo.endItem.text) TextViewBinder.bind(buttonView, newInfo.endItem.text) val onClickListener = View.OnClickListener { clickedView -> val onClickListener = if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return@OnClickListener View.OnClickListener { clickedView -> if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return@OnClickListener newInfo.endItem.onClickListener.onClick(clickedView) newInfo.endItem.onClickListener.onClick(clickedView) } } Loading @@ -168,21 +168,27 @@ open class ChipbarCoordinator @Inject constructor( // ---- Overall accessibility ---- // ---- Overall accessibility ---- val iconDesc = newInfo.startIcon.icon.contentDescription val iconDesc = newInfo.startIcon.icon.contentDescription val loadedIconDesc = if (iconDesc != null) { val loadedIconDesc = if (iconDesc != null) { "${iconDesc.loadContentDescription(context)} " "${iconDesc.loadContentDescription(context)} " } else { } else { "" "" } } val endItemDesc = if (newInfo.endItem is ChipbarEndItem.Loading) { ". ${context.resources.getString(R.string.media_transfer_loading)}." } else { "" } val chipInnerView = currentView.getInnerView() val chipInnerView = currentView.getInnerView() chipInnerView.contentDescription = "$loadedIconDesc${newInfo.text.loadText(context)}" chipInnerView.contentDescription = "$loadedIconDesc${newInfo.text.loadText(context)}$endItemDesc" chipInnerView.accessibilityLiveRegion = ACCESSIBILITY_LIVE_REGION_ASSERTIVE chipInnerView.accessibilityLiveRegion = ACCESSIBILITY_LIVE_REGION_ASSERTIVE maybeGetAccessibilityFocus(newInfo, currentView) maybeGetAccessibilityFocus(newInfo, currentView) // ---- Haptics ---- // ---- Haptics ---- newInfo.vibrationEffect?.let { newInfo.vibrationEffect?.let { vibratorHelper.vibrate(it) } vibratorHelper.vibrate(it) } } } private fun maybeGetAccessibilityFocus(info: ChipbarInfo?, view: ViewGroup) { private fun maybeGetAccessibilityFocus(info: ChipbarInfo?, view: ViewGroup) { Loading packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt +36 −2 Original line number Original line Diff line number Diff line Loading @@ -124,7 +124,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() { ) ) ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) val contentDescView = getChipbarView().getInnerView() assertThat(contentDescView.contentDescription.toString()).contains("loadedCD") assertThat(contentDescView.contentDescription.toString()).contains("loadedCD") assertThat(contentDescView.contentDescription.toString()).contains("text") assertThat(contentDescView.contentDescription.toString()).contains("text") } } Loading @@ -139,10 +139,42 @@ class ChipbarCoordinatorTest : SysuiTestCase() { ) ) ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) val contentDescView = getChipbarView().getInnerView() assertThat(contentDescView.contentDescription.toString()).isEqualTo("text") assertThat(contentDescView.contentDescription.toString()).isEqualTo("text") } } @Test fun displayView_contentDescription_endIsLoading() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")), Text.Loaded("text"), endItem = ChipbarEndItem.Loading, ) ) val contentDescView = getChipbarView().getInnerView() val loadingDesc = context.resources.getString(R.string.media_transfer_loading) assertThat(contentDescView.contentDescription.toString()).contains("text") assertThat(contentDescView.contentDescription.toString()).contains(loadingDesc) } @Test fun displayView_contentDescription_endNotLoading() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")), Text.Loaded("text"), endItem = ChipbarEndItem.Error, ) ) val contentDescView = getChipbarView().getInnerView() val loadingDesc = context.resources.getString(R.string.media_transfer_loading) assertThat(contentDescView.contentDescription.toString()).contains("text") assertThat(contentDescView.contentDescription.toString()).doesNotContain(loadingDesc) } @Test @Test fun displayView_loadedIcon_correctlyRendered() { fun displayView_loadedIcon_correctlyRendered() { val drawable = context.getDrawable(R.drawable.ic_celebration)!! val drawable = context.getDrawable(R.drawable.ic_celebration)!! Loading Loading @@ -417,6 +449,8 @@ class ChipbarCoordinatorTest : SysuiTestCase() { ) ) } } private fun ViewGroup.getInnerView() = this.requireViewById<ViewGroup>(R.id.chipbar_inner) private fun ViewGroup.getStartIconView() = this.requireViewById<ImageView>(R.id.start_icon) private fun ViewGroup.getStartIconView() = this.requireViewById<ImageView>(R.id.start_icon) private fun ViewGroup.getChipText(): String = private fun ViewGroup.getChipText(): String = Loading Loading
packages/SystemUI/ktfmt_includes.txt +0 −1 Original line number Original line Diff line number Diff line Loading @@ -485,7 +485,6 @@ -packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt -packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewInfo.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewInfo.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarRootView.kt -packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarRootView.kt -packages/SystemUI/src/com/android/systemui/toast/ToastDefaultAnimation.kt -packages/SystemUI/src/com/android/systemui/toast/ToastDefaultAnimation.kt -packages/SystemUI/src/com/android/systemui/toast/ToastLogger.kt -packages/SystemUI/src/com/android/systemui/toast/ToastLogger.kt Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -2362,6 +2362,8 @@ <string name="media_transfer_playing_different_device">Playing on <xliff:g id="deviceName" example="My Tablet">%1$s</xliff:g></string> <string name="media_transfer_playing_different_device">Playing on <xliff:g id="deviceName" example="My Tablet">%1$s</xliff:g></string> <!-- Text informing the user that the media transfer has failed because something went wrong. [CHAR LIsMIT=50] --> <!-- Text informing the user that the media transfer has failed because something went wrong. [CHAR LIsMIT=50] --> <string name="media_transfer_failed">Something went wrong. Try again.</string> <string name="media_transfer_failed">Something went wrong. Try again.</string> <!-- Text to indicate that a media transfer is currently in-progress, aka loading. [CHAR LIMIT=NONE] --> <string name="media_transfer_loading">Loading</string> <!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] --> <!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] --> <string name="controls_error_timeout">Inactive, check app</string> <string name="controls_error_timeout">Inactive, check app</string> Loading
packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt +50 −44 Original line number Original line Diff line number Diff line Loading @@ -65,11 +65,11 @@ import javax.inject.Inject * in the list of notifications until the user dismisses them. * in the list of notifications until the user dismisses them. * * * Only one chipbar may be shown at a time. * Only one chipbar may be shown at a time. * TODO(b/245610654): Should we just display whichever chipbar was most recently requested, or do we * need to maintain a priority ordering? */ */ @SysUISingleton @SysUISingleton open class ChipbarCoordinator @Inject constructor( open class ChipbarCoordinator @Inject constructor( context: Context, context: Context, logger: ChipbarLogger, logger: ChipbarLogger, windowManager: WindowManager, windowManager: WindowManager, Loading @@ -84,7 +84,8 @@ open class ChipbarCoordinator @Inject constructor( private val vibratorHelper: VibratorHelper, private val vibratorHelper: VibratorHelper, wakeLockBuilder: WakeLock.Builder, wakeLockBuilder: WakeLock.Builder, systemClock: SystemClock, systemClock: SystemClock, ) : TemporaryViewDisplayController<ChipbarInfo, ChipbarLogger>( ) : TemporaryViewDisplayController<ChipbarInfo, ChipbarLogger>( context, context, logger, logger, windowManager, windowManager, Loading @@ -100,14 +101,10 @@ open class ChipbarCoordinator @Inject constructor( private lateinit var parent: ChipbarRootView private lateinit var parent: ChipbarRootView override val windowLayoutParams = commonWindowLayoutParams.apply { override val windowLayoutParams = gravity = Gravity.TOP.or(Gravity.CENTER_HORIZONTAL) commonWindowLayoutParams.apply { gravity = Gravity.TOP.or(Gravity.CENTER_HORIZONTAL) } } override fun updateView( override fun updateView(newInfo: ChipbarInfo, currentView: ViewGroup) { newInfo: ChipbarInfo, currentView: ViewGroup ) { logger.logViewUpdate( logger.logViewUpdate( newInfo.windowTitle, newInfo.windowTitle, newInfo.text.loadText(context), newInfo.text.loadText(context), Loading @@ -123,7 +120,8 @@ open class ChipbarCoordinator @Inject constructor( // Detect falsing touches on the chip. // Detect falsing touches on the chip. parent = currentView.requireViewById(R.id.chipbar_root_view) parent = currentView.requireViewById(R.id.chipbar_root_view) parent.touchHandler = object : Gefingerpoken { parent.touchHandler = object : Gefingerpoken { override fun onTouchEvent(ev: MotionEvent?): Boolean { override fun onTouchEvent(ev: MotionEvent?): Boolean { falsingCollector.onTouchEvent(ev) falsingCollector.onTouchEvent(ev) return false return false Loading Loading @@ -155,8 +153,10 @@ open class ChipbarCoordinator @Inject constructor( if (newInfo.endItem is ChipbarEndItem.Button) { if (newInfo.endItem is ChipbarEndItem.Button) { TextViewBinder.bind(buttonView, newInfo.endItem.text) TextViewBinder.bind(buttonView, newInfo.endItem.text) val onClickListener = View.OnClickListener { clickedView -> val onClickListener = if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return@OnClickListener View.OnClickListener { clickedView -> if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return@OnClickListener newInfo.endItem.onClickListener.onClick(clickedView) newInfo.endItem.onClickListener.onClick(clickedView) } } Loading @@ -168,21 +168,27 @@ open class ChipbarCoordinator @Inject constructor( // ---- Overall accessibility ---- // ---- Overall accessibility ---- val iconDesc = newInfo.startIcon.icon.contentDescription val iconDesc = newInfo.startIcon.icon.contentDescription val loadedIconDesc = if (iconDesc != null) { val loadedIconDesc = if (iconDesc != null) { "${iconDesc.loadContentDescription(context)} " "${iconDesc.loadContentDescription(context)} " } else { } else { "" "" } } val endItemDesc = if (newInfo.endItem is ChipbarEndItem.Loading) { ". ${context.resources.getString(R.string.media_transfer_loading)}." } else { "" } val chipInnerView = currentView.getInnerView() val chipInnerView = currentView.getInnerView() chipInnerView.contentDescription = "$loadedIconDesc${newInfo.text.loadText(context)}" chipInnerView.contentDescription = "$loadedIconDesc${newInfo.text.loadText(context)}$endItemDesc" chipInnerView.accessibilityLiveRegion = ACCESSIBILITY_LIVE_REGION_ASSERTIVE chipInnerView.accessibilityLiveRegion = ACCESSIBILITY_LIVE_REGION_ASSERTIVE maybeGetAccessibilityFocus(newInfo, currentView) maybeGetAccessibilityFocus(newInfo, currentView) // ---- Haptics ---- // ---- Haptics ---- newInfo.vibrationEffect?.let { newInfo.vibrationEffect?.let { vibratorHelper.vibrate(it) } vibratorHelper.vibrate(it) } } } private fun maybeGetAccessibilityFocus(info: ChipbarInfo?, view: ViewGroup) { private fun maybeGetAccessibilityFocus(info: ChipbarInfo?, view: ViewGroup) { Loading
packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt +36 −2 Original line number Original line Diff line number Diff line Loading @@ -124,7 +124,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() { ) ) ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) val contentDescView = getChipbarView().getInnerView() assertThat(contentDescView.contentDescription.toString()).contains("loadedCD") assertThat(contentDescView.contentDescription.toString()).contains("loadedCD") assertThat(contentDescView.contentDescription.toString()).contains("text") assertThat(contentDescView.contentDescription.toString()).contains("text") } } Loading @@ -139,10 +139,42 @@ class ChipbarCoordinatorTest : SysuiTestCase() { ) ) ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) val contentDescView = getChipbarView().getInnerView() assertThat(contentDescView.contentDescription.toString()).isEqualTo("text") assertThat(contentDescView.contentDescription.toString()).isEqualTo("text") } } @Test fun displayView_contentDescription_endIsLoading() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")), Text.Loaded("text"), endItem = ChipbarEndItem.Loading, ) ) val contentDescView = getChipbarView().getInnerView() val loadingDesc = context.resources.getString(R.string.media_transfer_loading) assertThat(contentDescView.contentDescription.toString()).contains("text") assertThat(contentDescView.contentDescription.toString()).contains(loadingDesc) } @Test fun displayView_contentDescription_endNotLoading() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")), Text.Loaded("text"), endItem = ChipbarEndItem.Error, ) ) val contentDescView = getChipbarView().getInnerView() val loadingDesc = context.resources.getString(R.string.media_transfer_loading) assertThat(contentDescView.contentDescription.toString()).contains("text") assertThat(contentDescView.contentDescription.toString()).doesNotContain(loadingDesc) } @Test @Test fun displayView_loadedIcon_correctlyRendered() { fun displayView_loadedIcon_correctlyRendered() { val drawable = context.getDrawable(R.drawable.ic_celebration)!! val drawable = context.getDrawable(R.drawable.ic_celebration)!! Loading Loading @@ -417,6 +449,8 @@ class ChipbarCoordinatorTest : SysuiTestCase() { ) ) } } private fun ViewGroup.getInnerView() = this.requireViewById<ViewGroup>(R.id.chipbar_inner) private fun ViewGroup.getStartIconView() = this.requireViewById<ImageView>(R.id.start_icon) private fun ViewGroup.getStartIconView() = this.requireViewById<ImageView>(R.id.start_icon) private fun ViewGroup.getChipText(): String = private fun ViewGroup.getChipText(): String = Loading