diff --git a/app/src/main/java/emu/skyline/MainActivity.kt b/app/src/main/java/emu/skyline/MainActivity.kt index bb3f758c..572927e7 100644 --- a/app/src/main/java/emu/skyline/MainActivity.kt +++ b/app/src/main/java/emu/skyline/MainActivity.kt @@ -54,7 +54,7 @@ class MainActivity : AppCompatActivity() { private val adapter = GenericAdapter() - private val layoutType get() = LayoutType.values()[settings.layoutType.toInt()] + private val layoutType get() = LayoutType.values()[settings.layoutType] private val missingIcon by lazy { ContextCompat.getDrawable(this, R.drawable.default_icon)!!.toBitmap(256, 256) } @@ -92,7 +92,7 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState : Bundle?) { // Need to create new instance of settings, dependency injection happens AppCompatDelegate.setDefaultNightMode( - when ((Settings(this).appTheme.toInt())) { + when ((Settings(this).appTheme)) { 0 -> AppCompatDelegate.MODE_NIGHT_NO 1 -> AppCompatDelegate.MODE_NIGHT_YES 2 -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM @@ -106,8 +106,8 @@ class MainActivity : AppCompatActivity() { PreferenceManager.setDefaultValues(this, R.xml.preferences, false) adapter.apply { - setHeaderItems(listOf(HeaderRomFilterItem(formatOrder, if (settings.filter == 0) null else formatOrder[settings.filter - 1]) { romFormat -> - settings.filter = romFormat?.let { formatOrder.indexOf(romFormat) + 1 } ?: 0 + setHeaderItems(listOf(HeaderRomFilterItem(formatOrder, if (settings.romFormatFilter == 0) null else formatOrder[settings.romFormatFilter - 1]) { romFormat -> + settings.romFormatFilter = romFormat?.let { formatOrder.indexOf(romFormat) + 1 } ?: 0 formatFilter = romFormat populateAdapter() })) diff --git a/app/src/main/java/emu/skyline/SkylineApplication.kt b/app/src/main/java/emu/skyline/SkylineApplication.kt index 6b49427c..33876eb8 100644 --- a/app/src/main/java/emu/skyline/SkylineApplication.kt +++ b/app/src/main/java/emu/skyline/SkylineApplication.kt @@ -36,6 +36,6 @@ class SkylineApplication : Application() { val appFilesPath = applicationContext.getPublicFilesDir().canonicalPath File("$appFilesPath/logs/").mkdirs() - initializeLog("$appFilesPath/", getSettings().logLevel.toInt()) + initializeLog("$appFilesPath/", getSettings().logLevel) } } diff --git a/app/src/main/java/emu/skyline/preference/IntegerListPreference.kt b/app/src/main/java/emu/skyline/preference/IntegerListPreference.kt index dd28223d..2dbfd549 100644 --- a/app/src/main/java/emu/skyline/preference/IntegerListPreference.kt +++ b/app/src/main/java/emu/skyline/preference/IntegerListPreference.kt @@ -28,7 +28,7 @@ import emu.skyline.R as sR * @see androidx.preference.ListPreference */ @SuppressLint("RestrictedApi") -class IntegerListPreference @JvmOverloads constructor( +open class IntegerListPreference @JvmOverloads constructor( context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = TypedArrayUtils.getAttr( diff --git a/app/src/main/java/emu/skyline/preference/ThemePreference.kt b/app/src/main/java/emu/skyline/preference/ThemePreference.kt index e56cb0ad..42db3b79 100644 --- a/app/src/main/java/emu/skyline/preference/ThemePreference.kt +++ b/app/src/main/java/emu/skyline/preference/ThemePreference.kt @@ -14,12 +14,12 @@ import androidx.preference.R /** * This preference is used to set the theme to Light/Dark mode */ -class ThemePreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.dialogPreferenceStyle) : ListPreference(context, attrs, defStyleAttr) { +class ThemePreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.dialogPreferenceStyle) : IntegerListPreference(context, attrs, defStyleAttr) { /** * This changes [AppCompatDelegate.sDefaultNightMode] based on what the user's selection is */ override fun callChangeListener(newValue : Any?) : Boolean { - AppCompatDelegate.setDefaultNightMode(when ((newValue as String).toInt()) { + AppCompatDelegate.setDefaultNightMode(when (newValue as Int) { 0 -> AppCompatDelegate.MODE_NIGHT_NO 1 -> AppCompatDelegate.MODE_NIGHT_YES 2 -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM diff --git a/app/src/main/java/emu/skyline/utils/Settings.kt b/app/src/main/java/emu/skyline/utils/Settings.kt index fe6c6cb0..c2652a75 100644 --- a/app/src/main/java/emu/skyline/utils/Settings.kt +++ b/app/src/main/java/emu/skyline/utils/Settings.kt @@ -10,40 +10,37 @@ import android.content.pm.ActivityInfo import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject import javax.inject.Singleton +import emu.skyline.R @Singleton class Settings @Inject constructor(@ApplicationContext private val context : Context) { - var layoutType by sharedPreferences(context, "1") - + // Emulator var searchLocation by sharedPreferences(context, "") - - var refreshRequired by sharedPreferences(context, false) - - var appTheme by sharedPreferences(context, "2") - + var appTheme by sharedPreferences(context, 2) + var layoutType by sharedPreferences(context, 1) var selectAction by sharedPreferences(context, false) - var perfStats by sharedPreferences(context, false) - - var operationMode by sharedPreferences(context, true) - - var onScreenControl by sharedPreferences(context, true) - - var onScreenControlRecenterSticks by sharedPreferences(context, true) - + var logLevel by sharedPreferences(context, 3) var logCompact by sharedPreferences(context, false) - var logLevel by sharedPreferences(context, "3") - - var filter by sharedPreferences(context, 0) - - var maxRefreshRate by sharedPreferences(context, false) - - var aspectRatio by sharedPreferences(context, 0) - + // System + var operationMode by sharedPreferences(context, true) + var usernameValue by sharedPreferences(context, context.getString(R.string.username_default)) var systemLanguage by sharedPreferences(context, 1) + // Display + var forceTripleBuffering by sharedPreferences(context, true) + var disableFrameThrottling by sharedPreferences(context, false) + var maxRefreshRate by sharedPreferences(context, false) + var aspectRatio by sharedPreferences(context, 0) var orientation by sharedPreferences(context, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) - var respectDisplayCutout by sharedPreferences(context, false) + + // Input + var onScreenControl by sharedPreferences(context, true) + var onScreenControlRecenterSticks by sharedPreferences(context, true) + + // Other + var romFormatFilter by sharedPreferences(context, 0) + var refreshRequired by sharedPreferences(context, false) } diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index 10f3fbf3..66cc0aa7 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -7,33 +7,16 @@ Debug Verbose - - 0 - 1 - 2 - 3 - 4 - List Grid Grid Compact - - 0 - 1 - 2 - Light Dark Use System Default - - 0 - 1 - 2 - American English British English diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 9134e5a6..c2d27a7b 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -13,14 +13,12 @@ - @@ -36,10 +34,9 @@ android:summaryOn="@string/perf_stats_desc_on" app:key="perf_stats" app:title="@string/perf_stats" /> -