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

Commit ea3174a6 authored by Caitlin Cassidy's avatar Caitlin Cassidy
Browse files

[Media TTT] Add content description to app icon.

Fixes: 211661947
Test: manual with talkback
Test: media.taptotransfer test suite
Change-Id: I453ce134b94a4016e630adee88329b4d2bf869f4
parent 05898447
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -71,20 +71,32 @@ class MediaTttCommandLineHelper @Inject constructor(
            when (args[1]) {
                MOVE_CLOSER_TO_TRANSFER_COMMAND_NAME -> {
                    mediaTttChipControllerSender.displayChip(
                        MoveCloserToTransfer(appIconDrawable, otherDeviceName)
                        MoveCloserToTransfer(
                            appIconDrawable, APP_ICON_CONTENT_DESCRIPTION, otherDeviceName
                        )
                    )
                }
                TRANSFER_INITIATED_COMMAND_NAME -> {
                    val futureTask = FutureTask { fakeUndoRunnable }
                    mediaTttChipControllerSender.displayChip(
                        TransferInitiated(appIconDrawable, otherDeviceName, futureTask)
                        TransferInitiated(
                            appIconDrawable,
                            APP_ICON_CONTENT_DESCRIPTION,
                            otherDeviceName,
                            futureTask
                        )
                    )
                    mainExecutor.executeDelayed({ futureTask.run() }, FUTURE_WAIT_TIME)

                }
                TRANSFER_SUCCEEDED_COMMAND_NAME -> {
                    mediaTttChipControllerSender.displayChip(
                        TransferSucceeded(appIconDrawable, otherDeviceName, fakeUndoRunnable)
                        TransferSucceeded(
                            appIconDrawable,
                            APP_ICON_CONTENT_DESCRIPTION,
                            otherDeviceName,
                            fakeUndoRunnable
                        )
                    )
                }
                else -> {
@@ -118,7 +130,9 @@ class MediaTttCommandLineHelper @Inject constructor(
    /** A command to DISPLAY the media ttt chip on the RECEIVER device. */
    inner class AddChipCommandReceiver : Command {
        override fun execute(pw: PrintWriter, args: List<String>) {
            mediaTttChipControllerReceiver.displayChip(ChipStateReceiver(appIconDrawable))
            mediaTttChipControllerReceiver.displayChip(
                ChipStateReceiver(appIconDrawable, APP_ICON_CONTENT_DESCRIPTION)
            )
        }
        override fun help(pw: PrintWriter) {
            pw.println("Usage: adb shell cmd statusbar $ADD_CHIP_COMMAND_RECEIVER_TAG")
@@ -156,4 +170,5 @@ val TRANSFER_INITIATED_COMMAND_NAME = TransferInitiated::class.simpleName!!
val TRANSFER_SUCCEEDED_COMMAND_NAME = TransferSucceeded::class.simpleName!!

private const val FUTURE_WAIT_TIME = 2000L
private const val APP_ICON_CONTENT_DESCRIPTION = "Fake media app icon"
private const val TAG = "MediaTapToTransferCli"
+1 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ abstract class MediaTttChipControllerCommon<T : MediaTttChipState>(
    internal fun setIcon(chipState: T, currentChipView: ViewGroup) {
        currentChipView.findViewById<CachingIconView>(R.id.app_icon).apply {
            this.setImageDrawable(chipState.appIconDrawable)
            this.contentDescription = chipState.appIconContentDescription
        }
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import android.graphics.drawable.Drawable
 * A superclass chip state that will be subclassed by the sender chip and receiver chip.
 *
 * @property appIconDrawable a drawable representing the icon of the app playing the media.
 * @property appIconContentDescription a string to use as the content description for the icon.
 */
open class MediaTttChipState(
    internal val appIconDrawable: Drawable
    internal val appIconDrawable: Drawable,
    internal val appIconContentDescription: String
)
+3 −2
Original line number Diff line number Diff line
@@ -24,5 +24,6 @@ import com.android.systemui.media.taptotransfer.common.MediaTttChipState
 * the receiver device.
 */
class ChipStateReceiver(
    appIconDrawable: Drawable
) : MediaTttChipState(appIconDrawable)
    appIconDrawable: Drawable,
    appIconContentDescription: String
) : MediaTttChipState(appIconDrawable, appIconContentDescription)
+22 −4
Original line number Diff line number Diff line
@@ -34,9 +34,10 @@ import java.util.concurrent.Future
 */
sealed class ChipStateSender(
    appIconDrawable: Drawable,
    appIconContentDescription: String,
    @StringRes internal val chipText: Int,
    internal val otherDeviceName: String,
) : MediaTttChipState(appIconDrawable)
) : MediaTttChipState(appIconDrawable, appIconContentDescription)

/**
 * A state representing that the two devices are close but not close enough to initiate a transfer.
@@ -44,8 +45,14 @@ sealed class ChipStateSender(
 */
class MoveCloserToTransfer(
    appIconDrawable: Drawable,
    appIconContentDescription: String,
    otherDeviceName: String,
) : ChipStateSender(appIconDrawable, R.string.media_move_closer_to_transfer, otherDeviceName)
) : ChipStateSender(
    appIconDrawable,
    appIconContentDescription,
    R.string.media_move_closer_to_transfer,
    otherDeviceName
)

/**
 * A state representing that a transfer has been initiated (but not completed).
@@ -57,9 +64,15 @@ class MoveCloserToTransfer(
 */
class TransferInitiated(
    appIconDrawable: Drawable,
    appIconContentDescription: String,
    otherDeviceName: String,
    val future: Future<Runnable?>
) : ChipStateSender(appIconDrawable, R.string.media_transfer_playing, otherDeviceName)
) : ChipStateSender(
    appIconDrawable,
    appIconContentDescription,
    R.string.media_transfer_playing,
    otherDeviceName
)

/**
 * A state representing that a transfer has been successfully completed.
@@ -69,6 +82,11 @@ class TransferInitiated(
 */
class TransferSucceeded(
    appIconDrawable: Drawable,
    appIconContentDescription: String,
    otherDeviceName: String,
    val undoRunnable: Runnable? = null
) : ChipStateSender(appIconDrawable, R.string.media_transfer_playing, otherDeviceName)
) : ChipStateSender(appIconDrawable,
    appIconContentDescription,
    R.string.media_transfer_playing,
    otherDeviceName
)
Loading