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

Commit 8a40863a authored by Matt Casey's avatar Matt Casey
Browse files

Provide content description for preview tap action

It can change at runtime so it needs to be updateable.

Bug: 345367380
Test: atest com.android.systemui.screenshot com.google.android.systemui.screenshot
Flag: EXEMPT bugfix
Change-Id: Iae423d39fdc2dc48a0dee3ba2469249639ff911c
parent e59390f1
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@
            android:layout_marginBottom="@dimen/overlay_border_width"
            android:layout_gravity="center"
            android:elevation="4dp"
            android:contentDescription="@string/screenshot_edit_description"
            android:scaleType="fitEnd"
            android:background="@drawable/overlay_preview_background"
            android:adjustViewBounds="true"
@@ -67,7 +66,6 @@
            android:layout_marginBottom="@dimen/overlay_border_width"
            android:layout_gravity="center"
            android:elevation="4dp"
            android:contentDescription="@string/screenshot_edit_description"
            android:scaleType="fitEnd"
            android:background="@drawable/overlay_preview_background"
            android:adjustViewBounds="true"
+3 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.screenshot

import android.app.assist.AssistContent
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonAppearance
import com.android.systemui.screenshot.ui.viewmodel.PreviewAction
import com.android.systemui.screenshot.ui.viewmodel.ScreenshotViewModel
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
@@ -84,9 +85,9 @@ constructor(
    }

    inner class ActionsCallback(private val screenshotId: UUID) {
        fun providePreviewAction(onClick: () -> Unit) {
        fun providePreviewAction(previewAction: PreviewAction) {
            if (screenshotId == currentScreenshotId) {
                viewModel.setPreviewAction(onClick)
                viewModel.setPreviewAction(previewAction)
            }
        }

+15 −10
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.screenshot.ScreenshotEvent.SCREENSHOT_EDIT_TAPPED
import com.android.systemui.screenshot.ScreenshotEvent.SCREENSHOT_PREVIEW_TAPPED
import com.android.systemui.screenshot.ScreenshotEvent.SCREENSHOT_SHARE_TAPPED
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonAppearance
import com.android.systemui.screenshot.ui.viewmodel.PreviewAction
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@@ -40,7 +41,9 @@ import java.util.UUID
 */
interface ScreenshotActionsProvider {
    fun onScrollChipReady(onClick: Runnable)

    fun onScrollChipInvalidated()

    fun setCompletedScreenshot(result: ScreenshotSavedResult)

    /**
@@ -75,7 +78,8 @@ constructor(
    private var result: ScreenshotSavedResult? = null

    init {
        actionsCallback.providePreviewAction {
        actionsCallback.providePreviewAction(
            PreviewAction(context.resources.getString(R.string.screenshot_edit_description)) {
                debugLog(LogConfig.DEBUG_ACTIONS) { "Preview tapped" }
                uiEventLogger.log(SCREENSHOT_PREVIEW_TAPPED, 0, request.packageNameString)
                onDeferrableActionTapped { result ->
@@ -86,6 +90,7 @@ constructor(
                    )
                }
            }
        )

        actionsCallback.provideActionButton(
            ActionButtonAppearance(
+3 −2
Original line number Diff line number Diff line
@@ -128,8 +128,9 @@ constructor(private val buttonViewBinder: ActionButtonViewBinder) {
                        }
                    }
                    launch {
                        viewModel.previewAction.collect { onClick ->
                            previewView.setOnClickListener { onClick?.invoke() }
                        viewModel.previewAction.collect { action ->
                            previewView.setOnClickListener { action?.onClick?.invoke() }
                            previewView.contentDescription = action?.contentDescription
                        }
                    }
                    launch {
+9 −4
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@ class ScreenshotViewModel(private val accessibilityManager: AccessibilityManager
    val scrollingScrim: StateFlow<Bitmap?> = _scrollingScrim
    private val _badge = MutableStateFlow<Drawable?>(null)
    val badge: StateFlow<Drawable?> = _badge
    private val _previewAction = MutableStateFlow<(() -> Unit)?>(null)
    val previewAction: StateFlow<(() -> Unit)?> = _previewAction
    private val _previewAction = MutableStateFlow<PreviewAction?>(null)
    val previewAction: StateFlow<PreviewAction?> = _previewAction
    private val _actions = MutableStateFlow(emptyList<ActionButtonViewModel>())
    val actions: StateFlow<List<ActionButtonViewModel>> = _actions
    private val _animationState = MutableStateFlow(AnimationState.NOT_STARTED)
@@ -57,8 +57,8 @@ class ScreenshotViewModel(private val accessibilityManager: AccessibilityManager
        _badge.value = badge
    }

    fun setPreviewAction(onClick: () -> Unit) {
        _previewAction.value = onClick
    fun setPreviewAction(previewAction: PreviewAction) {
        _previewAction.value = previewAction
    }

    fun addAction(
@@ -149,6 +149,11 @@ class ScreenshotViewModel(private val accessibilityManager: AccessibilityManager
    }
}

data class PreviewAction(
    val contentDescription: CharSequence,
    val onClick: () -> Unit,
)

enum class AnimationState {
    NOT_STARTED,
    ENTRANCE_STARTED, // The first 200ms of the entrance animation
Loading