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

Commit 1cca4962 authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Android (Google) Code Review
Browse files

Merge "[Media TTT] Add the app icon to the view."

parents 8704be36 e087e129
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -26,6 +26,13 @@
    android:gravity="center_vertical"
    >

    <com.android.internal.widget.CachingIconView
        android:id="@+id/app_icon"
        android:layout_width="@dimen/media_ttt_icon_size"
        android:layout_height="@dimen/media_ttt_icon_size"
        android:layout_marginEnd="12dp"
        />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
@@ -37,8 +44,8 @@
    <ProgressBar
        android:id="@+id/loading"
        android:indeterminate="true"
        android:layout_width="@dimen/media_ttt_icon_size"
        android:layout_height="@dimen/media_ttt_icon_size"
        android:layout_width="@dimen/media_ttt_loading_size"
        android:layout_height="@dimen/media_ttt_loading_size"
        android:layout_marginStart="12dp"
        android:indeterminateTint="?androidprv:attr/colorAccentPrimaryVariant"
        style="?android:attr/progressBarStyleSmall"
+2 −1
Original line number Diff line number Diff line
@@ -980,7 +980,8 @@
    <!-- Media tap-to-transfer chip -->
    <dimen name="media_ttt_chip_outer_padding">16dp</dimen>
    <dimen name="media_ttt_text_size">16sp</dimen>
    <dimen name="media_ttt_icon_size">16dp</dimen>
    <dimen name="media_ttt_icon_size">24dp</dimen>
    <dimen name="media_ttt_loading_size">20dp</dimen>
    <dimen name="media_ttt_undo_button_vertical_padding">8dp</dimen>
    <dimen name="media_ttt_undo_button_vertical_negative_margin">-8dp</dimen>

+2 −1
Original line number Diff line number Diff line
@@ -99,12 +99,13 @@ public interface MediaModule {
    static Optional<MediaTttCommandLineHelper> providesMediaTttCommandLineHelper(
            MediaTttFlags mediaTttFlags,
            CommandRegistry commandRegistry,
            Context context,
            MediaTttChipController mediaTttChipController,
            @Main DelayableExecutor mainExecutor) {
        if (!mediaTttFlags.isMediaTttEnabled()) {
            return Optional.empty();
        }
        return Optional.of(new MediaTttCommandLineHelper(
                commandRegistry, mediaTttChipController, mainExecutor));
                commandRegistry, context, mediaTttChipController, mainExecutor));
    }
}
+11 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.View
import android.view.WindowManager
import android.widget.LinearLayout
import android.widget.TextView
import com.android.internal.widget.CachingIconView
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
@@ -74,6 +75,11 @@ class MediaTttChipController @Inject constructor(
        }
        val currentChipView = chipView!!

        // App icon
        currentChipView.findViewById<CachingIconView>(R.id.app_icon).apply {
            this.setImageDrawable(chipState.appIconDrawable)
        }

        // Text
        currentChipView.requireViewById<TextView>(R.id.text).apply {
            text = context.getString(chipState.chipText, chipState.otherDeviceName)
@@ -128,7 +134,11 @@ class MediaTttChipController @Inject constructor(
                val undoRunnable = chipState.future.get(TRANSFER_TIMEOUT_SECONDS, TimeUnit.SECONDS)
                // Make UI changes on the main thread
                mainExecutor.execute {
                    displayChip(TransferSucceeded(chipState.otherDeviceName, undoRunnable))
                    displayChip(
                        TransferSucceeded(
                            chipState.otherDeviceName, chipState.appIconDrawable, undoRunnable
                        )
                    )
                }
            } catch (ex: Exception) {
                // TODO(b/203800327): Maybe show a failure chip here if UX decides we need one.
+14 −7
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.media.taptotransfer

import android.graphics.drawable.Drawable
import androidx.annotation.StringRes
import com.android.systemui.R
import java.util.concurrent.Future
@@ -26,12 +27,15 @@ import java.util.concurrent.Future
 *
 * This is a sealed class where each subclass represents a specific chip state. Each subclass can
 * contain additional information that is necessary for only that state.
 *
 * @property chipText a string resource for the text that the chip should display.
 * @property otherDeviceName the name of the other device involved in the transfer.
 * @property appIconDrawable a drawable representing the icon of the app playing the media.
 */
sealed class MediaTttChipState(
    /** A string resource for the text that the chip should display. */
    @StringRes internal val chipText: Int,
    /** The name of the other device involved in the transfer. */
    internal val otherDeviceName: String
    internal val otherDeviceName: String,
    internal val appIconDrawable: Drawable,
)

/**
@@ -39,8 +43,9 @@ sealed class MediaTttChipState(
 * The chip will instruct the user to move closer in order to initiate the transfer.
 */
class MoveCloserToTransfer(
    otherDeviceName: String
) : MediaTttChipState(R.string.media_move_closer_to_transfer, otherDeviceName)
    otherDeviceName: String,
    appIconDrawable: Drawable
) : MediaTttChipState(R.string.media_move_closer_to_transfer, otherDeviceName, appIconDrawable)

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

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