Loading packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt +0 −2 Original line number Original line Diff line number Diff line Loading @@ -142,8 +142,6 @@ class MediaTttChipControllerReceiver @Inject constructor( } } override fun updateView(newInfo: ChipReceiverInfo, currentView: ViewGroup) { override fun updateView(newInfo: ChipReceiverInfo, currentView: ViewGroup) { super.updateView(newInfo, currentView) val iconInfo = MediaTttUtils.getIconInfoFromPackageName( val iconInfo = MediaTttUtils.getIconInfoFromPackageName( context, newInfo.routeInfo.clientPackageName, logger context, newInfo.routeInfo.clientPackageName, logger ) ) Loading packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttChipControllerSender.kt +2 −4 Original line number Original line Diff line number Diff line Loading @@ -132,8 +132,6 @@ open class MediaTttChipControllerSender @Inject constructor( newInfo: ChipSenderInfo, newInfo: ChipSenderInfo, currentView: ViewGroup currentView: ViewGroup ) { ) { super.updateView(newInfo, currentView) val chipState = newInfo.state val chipState = newInfo.state // Detect falsing touches on the chip. // Detect falsing touches on the chip. Loading Loading @@ -210,10 +208,10 @@ open class MediaTttChipControllerSender @Inject constructor( // animateChipOut matches the animateChipIn. // animateChipOut matches the animateChipIn. } } override fun shouldIgnoreViewRemoval(removalReason: String): Boolean { override fun shouldIgnoreViewRemoval(info: ChipSenderInfo, removalReason: String): Boolean { // Don't remove the chip if we're in progress or succeeded, since the user should still be // Don't remove the chip if we're in progress or succeeded, since the user should still be // able to see the status of the transfer. (But do remove it if it's finally timed out.) // able to see the status of the transfer. (But do remove it if it's finally timed out.) val transferStatus = info?.state?.transferStatus val transferStatus = info.state.transferStatus if ( if ( (transferStatus == TransferStatus.IN_PROGRESS || (transferStatus == TransferStatus.IN_PROGRESS || transferStatus == TransferStatus.SUCCEEDED) && transferStatus == TransferStatus.SUCCEEDED) && Loading packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt +30 −34 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,6 @@ import android.view.accessibility.AccessibilityManager import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_TEXT import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_TEXT import androidx.annotation.CallSuper import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.DelayableExecutor Loading Loading @@ -87,17 +86,8 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora */ */ internal abstract val windowLayoutParams: WindowManager.LayoutParams internal abstract val windowLayoutParams: WindowManager.LayoutParams /** The view currently being displayed. Null if the view is not being displayed. */ /** A container for all the display-related objects. Null if the view is not being displayed. */ private var view: ViewGroup? = null private var displayInfo: DisplayInfo? = null /** The view controller for [view]. Null if the view is not being displayed. */ private var viewController: TouchableRegionViewController? = null /** The info currently being displayed. Null if the view is not being displayed. */ internal var info: T? = null // TODO(b/245610654): We should probably group [view], [viewController], and [info] together // into one object since they're either all null or all non-null. /** A [Runnable] that, when run, will cancel the pending timeout of the view. */ /** A [Runnable] that, when run, will cancel the pending timeout of the view. */ private var cancelViewTimeout: Runnable? = null private var cancelViewTimeout: Runnable? = null Loading @@ -109,10 +99,11 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora * display the correct information in the view. * display the correct information in the view. */ */ fun displayView(newInfo: T) { fun displayView(newInfo: T) { val currentView = view val currentDisplayInfo = displayInfo if (currentView != null) { if (currentDisplayInfo != null) { updateView(newInfo, currentView) currentDisplayInfo.info = newInfo updateView(currentDisplayInfo.info, currentDisplayInfo.view) } else { } else { // The view is new, so set up all our callbacks and inflate the view // The view is new, so set up all our callbacks and inflate the view configurationController.addCallback(displayScaleListener) configurationController.addCallback(displayScaleListener) Loading Loading @@ -149,24 +140,24 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora val newView = LayoutInflater val newView = LayoutInflater .from(context) .from(context) .inflate(viewLayoutRes, null) as ViewGroup .inflate(viewLayoutRes, null) as ViewGroup view = newView val newViewController = TouchableRegionViewController(newView, this::getTouchableRegion) val newViewController = TouchableRegionViewController(newView, this::getTouchableRegion) newViewController.init() newViewController.init() viewController = newViewController updateView(newInfo, newView) // We don't need to hold on to the view controller since we never set anything additional // on it -- it will be automatically cleaned up when the view is detached. val newDisplayInfo = DisplayInfo(newView, newInfo) displayInfo = newDisplayInfo updateView(newDisplayInfo.info, newDisplayInfo.view) windowManager.addView(newView, windowLayoutParams) windowManager.addView(newView, windowLayoutParams) animateViewIn(newView) animateViewIn(newView) } } /** Removes then re-inflates the view. */ /** Removes then re-inflates the view. */ private fun reinflateView() { private fun reinflateView() { val currentInfo = info val currentViewInfo = displayInfo ?: return if (view == null || currentInfo == null) { return } windowManager.removeView(view) windowManager.removeView(currentViewInfo.view) inflateAndUpdateView(currentInfo) inflateAndUpdateView(currentViewInfo.info) } } private val displayScaleListener = object : ConfigurationController.ConfigurationListener { private val displayScaleListener = object : ConfigurationController.ConfigurationListener { Loading @@ -182,21 +173,20 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora * change, etc.) * change, etc.) */ */ fun removeView(removalReason: String) { fun removeView(removalReason: String) { if (shouldIgnoreViewRemoval(removalReason)) { val currentDisplayInfo = displayInfo ?: return if (shouldIgnoreViewRemoval(currentDisplayInfo.info, removalReason)) { return return } } val currentView = view ?: return val currentView = currentDisplayInfo.view animateViewOut(currentView) { windowManager.removeView(currentView) } animateViewOut(currentView) { windowManager.removeView(currentView) } logger.logChipRemoval(removalReason) logger.logChipRemoval(removalReason) configurationController.removeCallback(displayScaleListener) configurationController.removeCallback(displayScaleListener) // Re-set the view to null immediately (instead as part of the animation end runnable) so // Re-set to null immediately (instead as part of the animation end runnable) so // that if a new view event comes in while this view is animating out, we still display the // that if a new view event comes in while this view is animating out, we still display the // new view appropriately. // new view appropriately. view = null displayInfo = null viewController = null info = null // No need to time the view out since it's already gone // No need to time the view out since it's already gone cancelViewTimeout?.run() cancelViewTimeout?.run() } } Loading @@ -206,15 +196,12 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora * * * Allows subclasses to keep the view visible for longer in certain circumstances. * Allows subclasses to keep the view visible for longer in certain circumstances. */ */ open fun shouldIgnoreViewRemoval(removalReason: String): Boolean = false open fun shouldIgnoreViewRemoval(info: T, removalReason: String): Boolean = false /** /** * A method implemented by subclasses to update [currentView] based on [newInfo]. * A method implemented by subclasses to update [currentView] based on [newInfo]. */ */ @CallSuper abstract fun updateView(newInfo: T, currentView: ViewGroup) open fun updateView(newInfo: T, currentView: ViewGroup) { info = newInfo } /** /** * Fills [outRect] with the touchable region of this view. This will be used by WindowManager * Fills [outRect] with the touchable region of this view. This will be used by WindowManager Loading @@ -237,6 +224,15 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora internal open fun animateViewOut(view: ViewGroup, onAnimationEnd: Runnable) { internal open fun animateViewOut(view: ViewGroup, onAnimationEnd: Runnable) { onAnimationEnd.run() onAnimationEnd.run() } } /** A container for all the display-related state objects. */ private inner class DisplayInfo( /** The view currently being displayed. */ val view: ViewGroup, /** The info currently being displayed. */ var info: T, ) } } object TemporaryDisplayRemovalReason { object TemporaryDisplayRemovalReason { Loading packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayControllerTest.kt +1 −2 Original line number Original line Diff line number Diff line Loading @@ -261,11 +261,10 @@ class TemporaryViewDisplayControllerTest : SysuiTestCase() { override val windowLayoutParams = commonWindowLayoutParams override val windowLayoutParams = commonWindowLayoutParams override fun updateView(newInfo: ViewInfo, currentView: ViewGroup) { override fun updateView(newInfo: ViewInfo, currentView: ViewGroup) { super.updateView(newInfo, currentView) mostRecentViewInfo = newInfo mostRecentViewInfo = newInfo } } override fun shouldIgnoreViewRemoval(removalReason: String): Boolean { override fun shouldIgnoreViewRemoval(info: ViewInfo, removalReason: String): Boolean { return shouldIgnoreViewRemoval return shouldIgnoreViewRemoval } } Loading Loading
packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt +0 −2 Original line number Original line Diff line number Diff line Loading @@ -142,8 +142,6 @@ class MediaTttChipControllerReceiver @Inject constructor( } } override fun updateView(newInfo: ChipReceiverInfo, currentView: ViewGroup) { override fun updateView(newInfo: ChipReceiverInfo, currentView: ViewGroup) { super.updateView(newInfo, currentView) val iconInfo = MediaTttUtils.getIconInfoFromPackageName( val iconInfo = MediaTttUtils.getIconInfoFromPackageName( context, newInfo.routeInfo.clientPackageName, logger context, newInfo.routeInfo.clientPackageName, logger ) ) Loading
packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttChipControllerSender.kt +2 −4 Original line number Original line Diff line number Diff line Loading @@ -132,8 +132,6 @@ open class MediaTttChipControllerSender @Inject constructor( newInfo: ChipSenderInfo, newInfo: ChipSenderInfo, currentView: ViewGroup currentView: ViewGroup ) { ) { super.updateView(newInfo, currentView) val chipState = newInfo.state val chipState = newInfo.state // Detect falsing touches on the chip. // Detect falsing touches on the chip. Loading Loading @@ -210,10 +208,10 @@ open class MediaTttChipControllerSender @Inject constructor( // animateChipOut matches the animateChipIn. // animateChipOut matches the animateChipIn. } } override fun shouldIgnoreViewRemoval(removalReason: String): Boolean { override fun shouldIgnoreViewRemoval(info: ChipSenderInfo, removalReason: String): Boolean { // Don't remove the chip if we're in progress or succeeded, since the user should still be // Don't remove the chip if we're in progress or succeeded, since the user should still be // able to see the status of the transfer. (But do remove it if it's finally timed out.) // able to see the status of the transfer. (But do remove it if it's finally timed out.) val transferStatus = info?.state?.transferStatus val transferStatus = info.state.transferStatus if ( if ( (transferStatus == TransferStatus.IN_PROGRESS || (transferStatus == TransferStatus.IN_PROGRESS || transferStatus == TransferStatus.SUCCEEDED) && transferStatus == TransferStatus.SUCCEEDED) && Loading
packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt +30 −34 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,6 @@ import android.view.accessibility.AccessibilityManager import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_TEXT import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_TEXT import androidx.annotation.CallSuper import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.DelayableExecutor Loading Loading @@ -87,17 +86,8 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora */ */ internal abstract val windowLayoutParams: WindowManager.LayoutParams internal abstract val windowLayoutParams: WindowManager.LayoutParams /** The view currently being displayed. Null if the view is not being displayed. */ /** A container for all the display-related objects. Null if the view is not being displayed. */ private var view: ViewGroup? = null private var displayInfo: DisplayInfo? = null /** The view controller for [view]. Null if the view is not being displayed. */ private var viewController: TouchableRegionViewController? = null /** The info currently being displayed. Null if the view is not being displayed. */ internal var info: T? = null // TODO(b/245610654): We should probably group [view], [viewController], and [info] together // into one object since they're either all null or all non-null. /** A [Runnable] that, when run, will cancel the pending timeout of the view. */ /** A [Runnable] that, when run, will cancel the pending timeout of the view. */ private var cancelViewTimeout: Runnable? = null private var cancelViewTimeout: Runnable? = null Loading @@ -109,10 +99,11 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora * display the correct information in the view. * display the correct information in the view. */ */ fun displayView(newInfo: T) { fun displayView(newInfo: T) { val currentView = view val currentDisplayInfo = displayInfo if (currentView != null) { if (currentDisplayInfo != null) { updateView(newInfo, currentView) currentDisplayInfo.info = newInfo updateView(currentDisplayInfo.info, currentDisplayInfo.view) } else { } else { // The view is new, so set up all our callbacks and inflate the view // The view is new, so set up all our callbacks and inflate the view configurationController.addCallback(displayScaleListener) configurationController.addCallback(displayScaleListener) Loading Loading @@ -149,24 +140,24 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora val newView = LayoutInflater val newView = LayoutInflater .from(context) .from(context) .inflate(viewLayoutRes, null) as ViewGroup .inflate(viewLayoutRes, null) as ViewGroup view = newView val newViewController = TouchableRegionViewController(newView, this::getTouchableRegion) val newViewController = TouchableRegionViewController(newView, this::getTouchableRegion) newViewController.init() newViewController.init() viewController = newViewController updateView(newInfo, newView) // We don't need to hold on to the view controller since we never set anything additional // on it -- it will be automatically cleaned up when the view is detached. val newDisplayInfo = DisplayInfo(newView, newInfo) displayInfo = newDisplayInfo updateView(newDisplayInfo.info, newDisplayInfo.view) windowManager.addView(newView, windowLayoutParams) windowManager.addView(newView, windowLayoutParams) animateViewIn(newView) animateViewIn(newView) } } /** Removes then re-inflates the view. */ /** Removes then re-inflates the view. */ private fun reinflateView() { private fun reinflateView() { val currentInfo = info val currentViewInfo = displayInfo ?: return if (view == null || currentInfo == null) { return } windowManager.removeView(view) windowManager.removeView(currentViewInfo.view) inflateAndUpdateView(currentInfo) inflateAndUpdateView(currentViewInfo.info) } } private val displayScaleListener = object : ConfigurationController.ConfigurationListener { private val displayScaleListener = object : ConfigurationController.ConfigurationListener { Loading @@ -182,21 +173,20 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora * change, etc.) * change, etc.) */ */ fun removeView(removalReason: String) { fun removeView(removalReason: String) { if (shouldIgnoreViewRemoval(removalReason)) { val currentDisplayInfo = displayInfo ?: return if (shouldIgnoreViewRemoval(currentDisplayInfo.info, removalReason)) { return return } } val currentView = view ?: return val currentView = currentDisplayInfo.view animateViewOut(currentView) { windowManager.removeView(currentView) } animateViewOut(currentView) { windowManager.removeView(currentView) } logger.logChipRemoval(removalReason) logger.logChipRemoval(removalReason) configurationController.removeCallback(displayScaleListener) configurationController.removeCallback(displayScaleListener) // Re-set the view to null immediately (instead as part of the animation end runnable) so // Re-set to null immediately (instead as part of the animation end runnable) so // that if a new view event comes in while this view is animating out, we still display the // that if a new view event comes in while this view is animating out, we still display the // new view appropriately. // new view appropriately. view = null displayInfo = null viewController = null info = null // No need to time the view out since it's already gone // No need to time the view out since it's already gone cancelViewTimeout?.run() cancelViewTimeout?.run() } } Loading @@ -206,15 +196,12 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora * * * Allows subclasses to keep the view visible for longer in certain circumstances. * Allows subclasses to keep the view visible for longer in certain circumstances. */ */ open fun shouldIgnoreViewRemoval(removalReason: String): Boolean = false open fun shouldIgnoreViewRemoval(info: T, removalReason: String): Boolean = false /** /** * A method implemented by subclasses to update [currentView] based on [newInfo]. * A method implemented by subclasses to update [currentView] based on [newInfo]. */ */ @CallSuper abstract fun updateView(newInfo: T, currentView: ViewGroup) open fun updateView(newInfo: T, currentView: ViewGroup) { info = newInfo } /** /** * Fills [outRect] with the touchable region of this view. This will be used by WindowManager * Fills [outRect] with the touchable region of this view. This will be used by WindowManager Loading @@ -237,6 +224,15 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora internal open fun animateViewOut(view: ViewGroup, onAnimationEnd: Runnable) { internal open fun animateViewOut(view: ViewGroup, onAnimationEnd: Runnable) { onAnimationEnd.run() onAnimationEnd.run() } } /** A container for all the display-related state objects. */ private inner class DisplayInfo( /** The view currently being displayed. */ val view: ViewGroup, /** The info currently being displayed. */ var info: T, ) } } object TemporaryDisplayRemovalReason { object TemporaryDisplayRemovalReason { Loading
packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayControllerTest.kt +1 −2 Original line number Original line Diff line number Diff line Loading @@ -261,11 +261,10 @@ class TemporaryViewDisplayControllerTest : SysuiTestCase() { override val windowLayoutParams = commonWindowLayoutParams override val windowLayoutParams = commonWindowLayoutParams override fun updateView(newInfo: ViewInfo, currentView: ViewGroup) { override fun updateView(newInfo: ViewInfo, currentView: ViewGroup) { super.updateView(newInfo, currentView) mostRecentViewInfo = newInfo mostRecentViewInfo = newInfo } } override fun shouldIgnoreViewRemoval(removalReason: String): Boolean { override fun shouldIgnoreViewRemoval(info: ViewInfo, removalReason: String): Boolean { return shouldIgnoreViewRemoval return shouldIgnoreViewRemoval } } Loading