Repository: skyline-emu/skyline
File: app/src/main/java/emu/skyline/input/onscreen/OnScreenEditActivity.kt (Kotlin)

Code before:
        val checkArray = buttonProps.map { it.second }.toBooleanArray()

        MaterialAlertDialogBuilder(this)
                .setMultiChoiceItems(buttonProps.map {
                    val longText = getString(it.first.long!!)
                    if (it.first.short == longText) longText else "$longText: ${it.first.short}"
                }.toTypedArray(), checkArray) { _, which, isChecked ->
                    checkArray[which] = isChecked
                }.setPositiveButton(R.string.confirm) { _, _ ->
                    buttonProps.forEachIndexed { index, pair ->
                        if (checkArray[index] != pair.second)
                            binding.onScreenControllerView.setButtonEnabled(pair.first, checkArray[index])
                    }
                }.setNegativeButton(R.string.cancel, null)
                .setOnDismissListener { fullScreen() }
                .show()
    }

    private val actions : List<Pair<Int, () -> Unit>> = listOf(
            Pair(R.drawable.ic_restore, { binding.onScreenControllerView.resetControls() }),
            Pair(R.drawable.ic_toggle, toggleAction),
            Pair(R.drawable.ic_edit, editAction),
            Pair(R.drawable.ic_zoom_out, { binding.onScreenControllerView.decreaseScale() }),
            Pair(R.drawable.ic_zoom_in, { binding.onScreenControllerView.increaseScale() }),
            Pair(R.drawable.ic_close, closeAction)
    )

    private val fabMapping = mutableMapOf<Int, FloatingActionButton>()

    override fun onCreate(savedInstanceState : Bundle?) {
        super.onCreate(savedInstanceState)
        window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
        setContentView(binding.root)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            // Android might not allow child views to overlap the system bars
            // Override this behavior and force content to extend into the cutout area
            window.setDecorFitsSystemWindows(false)

            window.insetsController?.let {
                it.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
                it.hide(WindowInsets.Type.systemBars())
            }
        }

        binding.onScreenControllerView.recenterSticks = preferenceSettings.onScreenControlRecenterSticks

        actions.forEach { pair ->
            binding.fabParent.addView(LayoutInflater.from(this).inflate(R.layout.on_screen_edit_mini_fab, binding.fabParent, false).apply {
                (this as FloatingActionButton).setImageDrawable(ContextCompat.getDrawable(context, pair.first))
                setOnClickListener { pair.second.invoke() }

Review comment (suggestion):
```suggestion
            Pair(R.drawable.ic_opacity_minus) { binding.onScreenControllerView.changeOpacity(OPACITY_DELTA_STEP) },
            Pair(R.drawable.ic_opacity_plus) { binding.onScreenControllerView.changeOpacity(-OPACITY_DELTA_STEP) },
```

Create a `OPACITY_DELTA_STEP` constant at the top of this class with value 10.


Code after:
    }

    private val toggleAction : () -> Unit = {
        val buttonProps = binding.onScreenControllerView.getButtonProps()
        val checkArray = buttonProps.map { it.second }.toBooleanArray()

        MaterialAlertDialogBuilder(this)
                .setMultiChoiceItems(buttonProps.map {
                    val longText = getString(it.first.long!!)
                    if (it.first.short == longText) longText else "$longText: ${it.first.short}"
                }.toTypedArray(), checkArray) { _, which, isChecked ->
                    checkArray[which] = isChecked
                }.setPositiveButton(R.string.confirm) { _, _ ->
                    buttonProps.forEachIndexed { index, pair ->
                        if (checkArray[index] != pair.second)
                            binding.onScreenControllerView.setButtonEnabled(pair.first, checkArray[index])
                    }
                }.setNegativeButton(R.string.cancel, null)
                .setOnDismissListener { fullScreen() }
                .show()
    }

    private val actions : List<Pair<Int, () -> Unit>> = listOf(
            Pair(R.drawable.ic_restore, { binding.onScreenControllerView.resetControls() }),
            Pair(R.drawable.ic_toggle, toggleAction),
            Pair(R.drawable.ic_edit, editAction),
            Pair(R.drawable.ic_zoom_out, { binding.onScreenControllerView.decreaseScale() }),
            Pair(R.drawable.ic_zoom_in, { binding.onScreenControllerView.increaseScale() }),
            Pair(R.drawable.ic_opacity_minus) { binding.onScreenControllerView.changeOpacity(-OPACITY_DELTA_STEP) },
            Pair(R.drawable.ic_opacity_plus) { binding.onScreenControllerView.changeOpacity(OPACITY_DELTA_STEP) },
            Pair(R.drawable.ic_close, closeAction)
    )

    private val fabMapping = mutableMapOf<Int, FloatingActionButton>()

    override fun onCreate(savedInstanceState : Bundle?) {
        super.onCreate(savedInstanceState)
        window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
        setContentView(binding.root)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            // Android might not allow child views to overlap the system bars
            // Override this behavior and force content to extend into the cutout area
            window.setDecorFitsSystemWindows(false)

            window.insetsController?.let {
                it.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
                it.hide(WindowInsets.Type.systemBars())
            }
        }