mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-23 05:39:18 +01:00
Make languages setting use IntegerListPreference
This commit is contained in:
parent
c1a3ddcd1c
commit
221039084e
@ -173,7 +173,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
val preferenceFd = ParcelFileDescriptor.open(File("${applicationInfo.dataDir}/shared_prefs/${applicationInfo.packageName}_preferences.xml"), ParcelFileDescriptor.MODE_READ_WRITE)
|
||||
|
||||
emulationThread = Thread {
|
||||
executeApplication(rom.toString(), romType, romFd.detachFd(), preferenceFd.detachFd(), Integer.parseInt(settings.systemLanguage), applicationContext.filesDir.canonicalPath + "/", assets)
|
||||
executeApplication(rom.toString(), romType, romFd.detachFd(), preferenceFd.detachFd(), settings.systemLanguage, applicationContext.filesDir.canonicalPath + "/", assets)
|
||||
if (shouldFinish)
|
||||
runOnUiThread {
|
||||
emulationThread.join()
|
||||
|
@ -292,7 +292,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun loadRoms(loadFromFile : Boolean) {
|
||||
viewModel.loadRoms(loadFromFile, Uri.parse(settings.searchLocation), Integer.parseInt(settings.systemLanguage))
|
||||
viewModel.loadRoms(loadFromFile, Uri.parse(settings.searchLocation), settings.systemLanguage)
|
||||
settings.refreshRequired = false
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
package emu.skyline.preference
|
||||
|
||||
import java.lang.Exception
|
||||
import android.os.Bundle
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
@ -22,6 +21,7 @@ import androidx.core.content.res.TypedArrayUtils
|
||||
import androidx.preference.R
|
||||
import androidx.preference.DialogPreference
|
||||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import emu.skyline.R as sR
|
||||
|
||||
/**
|
||||
* A Preference that displays a list of entries as a dialog.
|
||||
@ -68,31 +68,30 @@ class IntegerListPreference @JvmOverloads constructor(
|
||||
|
||||
init {
|
||||
val res : Resources = context.resources
|
||||
val entryValuesId = attrs!!.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "entryValues", 0)
|
||||
|
||||
var a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes
|
||||
val a = context.obtainStyledAttributes(
|
||||
attrs, sR.styleable.IntegerListPreference, defStyleAttr, defStyleRes
|
||||
)
|
||||
|
||||
entries = TypedArrayUtils.getTextArray(
|
||||
a, R.styleable.ListPreference_entries,
|
||||
R.styleable.ListPreference_android_entries
|
||||
a, sR.styleable.IntegerListPreference_entries,
|
||||
sR.styleable.IntegerListPreference_android_entries
|
||||
)
|
||||
entryValues = try { res.getIntArray(entryValuesId) } catch (e : Exception) { null }
|
||||
|
||||
val entryValuesId = TypedArrayUtils.getResourceId(
|
||||
a, sR.styleable.IntegerListPreference_android_entryValues,
|
||||
sR.styleable.IntegerListPreference_android_entryValues, 0
|
||||
)
|
||||
entryValues = if (entryValuesId != 0) res.getIntArray(entryValuesId) else null
|
||||
|
||||
if (TypedArrayUtils.getBoolean(
|
||||
a, R.styleable.ListPreference_useSimpleSummaryProvider,
|
||||
R.styleable.ListPreference_useSimpleSummaryProvider, false
|
||||
a, sR.styleable.IntegerListPreference_useSimpleSummaryProvider,
|
||||
sR.styleable.IntegerListPreference_useSimpleSummaryProvider, false
|
||||
)
|
||||
) {
|
||||
summaryProvider = SimpleSummaryProvider.instance
|
||||
}
|
||||
a.recycle()
|
||||
|
||||
//Retrieve the Preference summary attribute since it's private in the Preference class.
|
||||
a = context.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.Preference, defStyleAttr, defStyleRes
|
||||
)
|
||||
a.recycle()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,5 +38,5 @@ class Settings @Inject constructor(@ApplicationContext private val context : Con
|
||||
|
||||
var maxRefreshRate by sharedPreferences(context, false)
|
||||
|
||||
var systemLanguage by sharedPreferences(context, "1")
|
||||
var systemLanguage by sharedPreferences(context, 1)
|
||||
}
|
||||
|
@ -54,24 +54,4 @@
|
||||
<item>Traditional Chinese (正體中文)</item>
|
||||
<item>Brazilian Portuguese (português do Brasil)</item>
|
||||
</string-array>
|
||||
<string-array name="system_lang_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
<item>11</item>
|
||||
<item>12</item>
|
||||
<item>13</item>
|
||||
<item>14</item>
|
||||
<item>15</item>
|
||||
<item>16</item>
|
||||
<item>17</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -4,4 +4,18 @@
|
||||
<attr name="limit" format="integer" />
|
||||
</declare-styleable>
|
||||
<attr name="chipChoiceStyle" format="reference" />
|
||||
<declare-styleable name="IntegerListPreference">
|
||||
<!-- The human-readable array to present as a list. Each entry must have a corresponding
|
||||
index in entryValues. -->
|
||||
<attr format="reference" name="entries"/>
|
||||
<attr name="android:entries"/>
|
||||
<!-- The array to find the value to save for a preference when an entry from
|
||||
entries is selected. If a user clicks on the second item in entries, the
|
||||
second item in this array will be saved to the preference. -->
|
||||
<attr format="reference" name="entryValues"/>
|
||||
<attr name="android:entryValues"/>
|
||||
<!-- Whether the preference should automatically set its summary to the value saved for the
|
||||
preference, and update the summary when the value is changed. Defaults to false. -->
|
||||
<attr format="boolean" name="useSimpleSummaryProvider"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
@ -75,7 +75,6 @@
|
||||
<emu.skyline.preference.IntegerListPreference
|
||||
android:defaultValue="1"
|
||||
android:entries="@array/system_languages"
|
||||
android:entryValues="@array/system_lang_values"
|
||||
app:key="system_language"
|
||||
app:title="@string/system_language"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
Loading…
Reference in New Issue
Block a user