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

Commit 03b4d28d authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Use Correct Saved Issue Type in Record Issue QS tile.

Bug: 360016989
Test: Verified the change works locally.
Flag: EXEMPT bug fix
Change-Id: I911a86b626f8400044bb1b1b48e0419c02cbe37c
parent 7dfc8e37
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -52,9 +52,20 @@ constructor(
        get() = prefs.getBoolean(HAS_APPROVED_SCREEN_RECORDING, false)
        private set(value) = prefs.edit().putBoolean(HAS_APPROVED_SCREEN_RECORDING, value).apply()

    // Store the index of the issue type because res ids are generated at compile time and change
    // in value from one build to another. The index will not change between package versions.
    private var issueTypeIndex: Int
        get() = prefs.getInt(KEY_ISSUE_TYPE_INDEX, ISSUE_TYPE_NOT_SET)
        set(value) = prefs.edit().putInt(KEY_ISSUE_TYPE_INDEX, value).apply()

    var issueTypeRes
        get() = prefs.getInt(KEY_ISSUE_TYPE_RES, ISSUE_TYPE_NOT_SET)
        set(value) = prefs.edit().putInt(KEY_ISSUE_TYPE_RES, value).apply()
        get() =
            // If the user has never used the record issue tile, we don't show a default issue type
            if (issueTypeIndex == ISSUE_TYPE_NOT_SET) ISSUE_TYPE_NOT_SET
            else ALL_ISSUE_TYPES.keys.toIntArray()[issueTypeIndex]
        set(value) {
            issueTypeIndex = ALL_ISSUE_TYPES.keys.toIntArray().indexOf(value)
        }

    val traceConfig: TraceConfig
        get() = ALL_ISSUE_TYPES[issueTypeRes] ?: customTraceState.traceConfig
@@ -89,17 +100,17 @@ constructor(
        private const val HAS_APPROVED_SCREEN_RECORDING = "HasApprovedScreenRecord"
        private const val KEY_RECORD_SCREEN = "key_recordScreen"
        private const val KEY_TAG_TITLES = "key_tagTitles"
        const val KEY_ISSUE_TYPE_RES = "key_issueTypeRes"
        const val KEY_ISSUE_TYPE_INDEX = "key_issueTypeIndex"
        const val ISSUE_TYPE_NOT_SET = -1
        const val TAG_TITLE_DELIMITER = ": "

        val ALL_ISSUE_TYPES: Map<Int, TraceConfig?> =
            hashMapOf(
        val ALL_ISSUE_TYPES: LinkedHashMap<Int, TraceConfig?> =
            linkedMapOf(
                Pair(R.string.performance, PresetTraceConfigs.getPerformanceConfig()),
                Pair(R.string.user_interface, PresetTraceConfigs.getUiConfig()),
                Pair(R.string.battery, PresetTraceConfigs.getBatteryConfig()),
                Pair(R.string.thermal, PresetTraceConfigs.getThermalConfig()),
                Pair(R.string.custom, null),
                Pair(R.string.custom, null), // Null means we are using a custom trace config
            )
    }
}
+4 −3
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePoli
import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDisabledDialogDelegate
import com.android.systemui.recordissue.IssueRecordingState.Companion.ALL_ISSUE_TYPES
import com.android.systemui.recordissue.IssueRecordingState.Companion.ISSUE_TYPE_NOT_SET
import com.android.systemui.recordissue.IssueRecordingState.Companion.KEY_ISSUE_TYPE_RES
import com.android.systemui.res.R
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.phone.SystemUIDialog
@@ -51,6 +50,8 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.util.concurrent.Executor

private const val EXTRA_ISSUE_TYPE_RES = "extra_issueTypeRes"

class RecordIssueDialogDelegate
@AssistedInject
constructor(
@@ -170,7 +171,7 @@ constructor(
            PopupMenu.OnMenuItemClickListener {
                issueTypeButton.text = it.title
                state.issueTypeRes =
                    it.intent?.getIntExtra(KEY_ISSUE_TYPE_RES, ISSUE_TYPE_NOT_SET)
                    it.intent?.getIntExtra(EXTRA_ISSUE_TYPE_RES, ISSUE_TYPE_NOT_SET)
                        ?: ISSUE_TYPE_NOT_SET
                onIssueTypeSelected.run()
                true
@@ -181,7 +182,7 @@ constructor(
                if (it != state.issueTypeRes) {
                    iconTintList = ColorStateList.valueOf(Color.TRANSPARENT)
                }
                intent = Intent().putExtra(KEY_ISSUE_TYPE_RES, it)
                intent = Intent().putExtra(EXTRA_ISSUE_TYPE_RES, it)

                if (it == R.string.custom) {
                    setOnMenuItemClickListener {