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

Commit 247f35ac authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Screen Chips] Show 3-2-1 countdown for screen record chip.

This updates the OngoingActivityChipModel.Shown to have two variants:
 - Timer: For chips that show a timer counting up
 - Countdown: For the 3-2-1 countdown
The model now allows for a null icon and a null click listener, since
the countdown chip has neither.

This also adds a new TextView to the chip view, used for the countdown.

This also updates the click listener for the call chip to be null if
there's no intent, now that we support a null click listener.

Bug: 332662551
Flag: com.android.systemui.status_bar_screen_sharing_chips

Test: Verify old ongoing call chip with the flag off still has the right
spacing
Test: Start screen recording -> verify chip shows the 3-2-1 countdown,
then switches to the timer chip counting up
Test: Verify all new chips still work with icons and timers
Test: Increase font size so that there's not enough room for the timer
on the chip -> verify only the icon shows and the icon is centered

Change-Id: I358233473dd098ad23034a6b41876a7bfa67a8a0
parent 4c722885
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@
            android:tint="?android:attr/colorPrimary"
        />

        <!-- Only one of [ongoing_activity_chip_time, ongoing_activity_chip_text] will ever
             be shown at one time. -->
        <com.android.systemui.statusbar.chips.ui.view.ChipChronometer
            android:id="@+id/ongoing_activity_chip_time"
            android:layout_width="wrap_content"
@@ -58,5 +60,19 @@
            android:textColor="?android:attr/colorPrimary"
        />

        <!-- Used to show generic text in the chip instead of a timer. -->
        <TextView
            android:id="@+id/ongoing_activity_chip_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:gravity="center|start"
            android:paddingStart="@dimen/ongoing_activity_chip_icon_text_padding"
            android:textAppearance="@android:style/TextAppearance.Material.Small"
            android:fontFamily="@*android:string/config_headlineFontFamily"
            android:textColor="?android:attr/colorPrimary"
            android:visibility="gone"
            />

    </com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer>
</FrameLayout>
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.common.ui.binder

import android.view.View
import android.widget.ImageView
import com.android.systemui.common.shared.model.Icon

@@ -30,4 +31,13 @@ object IconViewBinder {
            is Icon.Resource -> view.setImageResource(icon.res)
        }
    }

    fun bindNullable(icon: Icon?, view: ImageView) {
        if (icon != null) {
            view.visibility = View.VISIBLE
            bind(icon, view)
        } else {
            view.visibility = View.GONE
        }
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.res.R;
import com.android.systemui.screenrecord.RecordingController;
import com.android.systemui.screenrecord.data.model.ScreenRecordModel;
import com.android.systemui.settings.UserContextProvider;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -146,8 +147,9 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
        if (isRecording) {
            state.secondaryLabel = mContext.getString(R.string.quick_settings_screen_record_stop);
        } else if (isStarting) {
            // round, since the timer isn't exact
            int countdown = (int) Math.floorDiv(mMillisUntilFinished + 500, 1000);
            int countdown =
                    (int) ScreenRecordModel.Starting.Companion.toCountdownSeconds(
                            mMillisUntilFinished);
            state.secondaryLabel = String.format("%d...", countdown);
        } else {
            state.secondaryLabel = mContext.getString(R.string.quick_settings_screen_record_start);
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ constructor(
                            contentDescription = null
                        )
                    icon = { loadedIcon }
                    val countDown = Math.floorDiv(data.millisUntilStarted + 500, 1000)
                    val countDown = data.countdownSeconds
                    sideViewIcon = QSTileState.SideViewIcon.None
                    secondaryLabel = String.format("%d...", countDown)
                }
+11 −1
Original line number Diff line number Diff line
@@ -22,7 +22,17 @@ sealed interface ScreenRecordModel {
    data object Recording : ScreenRecordModel

    /** A screen recording will begin in [millisUntilStarted] ms. */
    data class Starting(val millisUntilStarted: Long) : ScreenRecordModel
    data class Starting(val millisUntilStarted: Long) : ScreenRecordModel {
        val countdownSeconds = millisUntilStarted.toCountdownSeconds()

        companion object {
            /**
             * Returns the number of seconds until screen recording will start, used to show a 3-2-1
             * countdown.
             */
            fun Long.toCountdownSeconds() = Math.floorDiv(this + 500, 1000)
        }
    }

    /** There's nothing related to screen recording happening. */
    data object DoingNothing : ScreenRecordModel
Loading