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

Commit 80aa9cbb authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Don't let users start Recording Issue until they have selected an Issue

Type.

Also, some minor refactoring.

Bug: 305049544
Flag: ACONFIG record_issue_qs_tile DEVELOPMENT
Test: Tested this locally on a device.
Change-Id: I1c3e0d5cc6240aa4fad2d9cb5d5b0c6ddbff4e29
parent 0f59265d
Loading
Loading
Loading
Loading
+50 −44
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ import android.view.WindowManager
import android.widget.Button
import android.widget.PopupMenu
import android.widget.Switch
import androidx.annotation.AnyThread
import androidx.annotation.MainThread
import androidx.annotation.WorkerThread
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlagsClassic
@@ -74,6 +74,7 @@ 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?) {
@@ -82,7 +83,10 @@ constructor(
            setTitle(context.getString(R.string.qs_record_issue_label))
            setIcon(R.drawable.qs_record_issue_icon_off)
            setNegativeButton(R.string.cancel) { _, _ -> dismiss() }
            setPositiveButton(R.string.qs_record_issue_start) { _, _ ->
            setPositiveButton(
                R.string.qs_record_issue_start,
                { _, _ ->
                    if (hasSelectedIssueType) {
                        onStarted.accept(
                            IssueRecordingConfig(
                                screenRecordSwitch.isChecked,
@@ -91,6 +95,9 @@ constructor(
                        )
                        dismiss()
                    }
                },
                false
            )
        }
    }

@@ -104,18 +111,17 @@ constructor(

            screenRecordSwitch = requireViewById(R.id.screenrecord_switch)
            screenRecordSwitch.setOnCheckedChangeListener { _, isEnabled ->
                onScreenRecordSwitchClicked(context, isEnabled)
                if (isEnabled) {
                    bgExecutor.execute { onScreenRecordSwitchClicked() }
                }
            }
            issueTypeButton = requireViewById(R.id.issue_type_button)
            issueTypeButton.setOnClickListener { onIssueTypeClicked(context) }
        }
    }

    @AnyThread
    private fun onScreenRecordSwitchClicked(context: Context, isEnabled: Boolean) {
        if (!isEnabled) return

        bgExecutor.execute {
    @WorkerThread
    private fun onScreenRecordSwitchClicked() {
        if (
            flags.isEnabled(WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES) &&
                devicePolicyResolver
@@ -126,7 +132,7 @@ constructor(
                screenCaptureDisabledDialogDelegate.createDialog().show()
                screenRecordSwitch.isChecked = false
            }
                return@execute
            return
        }

        mediaProjectionMetricsLogger.notifyProjectionInitiated(
@@ -151,7 +157,6 @@ constructor(
            }
        }
    }
    }

    @MainThread
    private fun onIssueTypeClicked(context: Context) {
@@ -174,5 +179,6 @@ constructor(
            setForceShowIcon(true)
            show()
        }
        hasSelectedIssueType = true
    }
}