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

Commit b370556a authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Grey out start button on RecordIssueDialog when IssueType isn't

selected, in addition to disabling it.

Bug: 305049544
Flag: ACONFIG record_issue_qs_tile DEVELOPMENT
Test: Manually tested that everything works on device.
Change-Id: I99445be4a6b817a5793ba809de70f05c76b10c2d
parent 7328ecc1
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.recordissue

import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
@@ -74,7 +75,6 @@ constructor(

    @SuppressLint("UseSwitchCompatOrMaterialCode") private lateinit var screenRecordSwitch: Switch
    private lateinit var issueTypeButton: Button
    private var hasSelectedIssueType: Boolean = false

    @MainThread
    override fun beforeCreate(dialog: SystemUIDialog, savedInstanceState: Bundle?) {
@@ -86,7 +86,6 @@ constructor(
            setPositiveButton(
                R.string.qs_record_issue_start,
                { _, _ ->
                    if (hasSelectedIssueType) {
                    onStarted.accept(
                        IssueRecordingConfig(
                            screenRecordSwitch.isChecked,
@@ -94,7 +93,6 @@ constructor(
                        )
                    )
                    dismiss()
                    }
                },
                false
            )
@@ -115,8 +113,12 @@ constructor(
                    bgExecutor.execute { onScreenRecordSwitchClicked() }
                }
            }
            val startButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE)
            issueTypeButton = requireViewById(R.id.issue_type_button)
            issueTypeButton.setOnClickListener { onIssueTypeClicked(context) }
            issueTypeButton.setOnClickListener {
                onIssueTypeClicked(context) { startButton.isEnabled = true }
            }
            startButton.isEnabled = false
        }
    }

@@ -159,7 +161,7 @@ constructor(
    }

    @MainThread
    private fun onIssueTypeClicked(context: Context) {
    private fun onIssueTypeClicked(context: Context, onIssueTypeSelected: Runnable) {
        val selectedCategory = issueTypeButton.text.toString()
        val popupMenu = PopupMenu(context, issueTypeButton)

@@ -174,11 +176,11 @@ constructor(
        popupMenu.apply {
            setOnMenuItemClickListener {
                issueTypeButton.text = it.title
                onIssueTypeSelected.run()
                true
            }
            setForceShowIcon(true)
            show()
        }
        hasSelectedIssueType = true
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -222,4 +222,9 @@ class RecordIssueDialogDelegateTest : SysuiTestCase() {
            )
        verify(factory, never()).create(any<ScreenCapturePermissionDialogDelegate>())
    }

    @Test
    fun startButton_isDisabled_beforeIssueTypeIsSelected() {
        assertThat(dialog.getButton(Dialog.BUTTON_POSITIVE).isEnabled).isFalse()
    }
}