Main activity is now refreshing when the group checkbox is changed

This commit is contained in:
hacobot.dev 2023-01-10 17:23:49 -07:00 committed by Billy Laws
parent b67bfe3848
commit 7cd13916a3
2 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,23 @@
/*
* SPDX-License-Identifier: MPL-2.0
* Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
*/
package emu.skyline.preference
import android.content.Context
import android.util.AttributeSet
import androidx.preference.CheckBoxPreference
import androidx.preference.R
import emu.skyline.di.getSettings
/**
* This preference is used with checkboxes that need to refresh the main activity when changed
*/
class ChkBoxPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.checkBoxPreferenceStyle) : CheckBoxPreference(context, attrs, defStyleAttr) {
override fun onClick() {
context?.getSettings()?.refreshRequired = true
super.onClick()
}
}

View File

@ -22,7 +22,7 @@
app:key="layout_type"
app:title="@string/layout_type"
app:useSimpleSummaryProvider="true" />
<CheckBoxPreference
<emu.skyline.preference.ChkBoxPreference
android:defaultValue="true"
android:summaryOff="@string/group_by_format_desc_off"
android:summaryOn="@string/group_by_format_desc_on"