diff --git a/app/src/main/java/emu/skyline/preference/ChkBoxPreference.kt b/app/src/main/java/emu/skyline/preference/ChkBoxPreference.kt new file mode 100644 index 00000000..58c8fce3 --- /dev/null +++ b/app/src/main/java/emu/skyline/preference/ChkBoxPreference.kt @@ -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() + } +} diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 7793cb06..cea9e6ce 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -22,7 +22,7 @@ app:key="layout_type" app:title="@string/layout_type" app:useSimpleSummaryProvider="true" /> -