Compare commits
1 commit
e8a0a994ad
...
d8ef0415b2
Author | SHA1 | Date | |
---|---|---|---|
d8ef0415b2 |
4 changed files with 37 additions and 3 deletions
|
@ -8,6 +8,7 @@ import android.provider.Settings
|
|||
import android.widget.Toast
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
|
@ -16,7 +17,6 @@ import im.angry.openeuicc.util.*
|
|||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
open class SettingsFragment: PreferenceFragmentCompat() {
|
||||
private lateinit var developerPref: PreferenceCategory
|
||||
|
@ -84,6 +84,9 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
|||
requirePreference<CheckBoxPreference>("pref_developer_euicc_memory_reset")
|
||||
.bindBooleanFlow(preferenceRepository.euiccMemoryResetFlow)
|
||||
|
||||
requirePreference<ListPreference>("pref_developer_es10x_mss")
|
||||
.bindIntFlow(preferenceRepository.es10xMssFlow, 63)
|
||||
|
||||
requirePreference<Preference>("pref_developer_isdr_aid_list").apply {
|
||||
intent = Intent(requireContext(), IsdrAidListActivity::class.java)
|
||||
}
|
||||
|
@ -138,13 +141,26 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
runBlocking {
|
||||
lifecycleScope.launch {
|
||||
flow.updatePreference(newValue as Boolean)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun ListPreference.bindIntFlow(flow: PreferenceFlowWrapper<Int>, defaultValue: Int) {
|
||||
lifecycleScope.launch {
|
||||
flow.collect { value = it.toString() }
|
||||
}
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
lifecycleScope.launch {
|
||||
flow.updatePreference((newValue as String).toIntOrNull() ?: defaultValue)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
protected fun mergePreferenceOverlay(overlayKey: String, targetKey: String) {
|
||||
val overlayCat = requirePreference<PreferenceCategory>(overlayKey)
|
||||
val targetCat = requirePreference<PreferenceCategory>(targetKey)
|
||||
|
|
|
@ -88,7 +88,7 @@ open class PreferenceRepository(private val context: Context) {
|
|||
PreferenceConstants.DEFAULT_AID_LIST,
|
||||
{ Base64.getEncoder().encodeToString(it.encodeToByteArray()) },
|
||||
{ Base64.getDecoder().decode(it).decodeToString() })
|
||||
val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 60)
|
||||
val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 63)
|
||||
|
||||
protected fun <T> bindFlow(
|
||||
key: Preferences.Key<T>,
|
||||
|
|
|
@ -200,6 +200,16 @@
|
|||
<string name="pref_developer_ignore_tls_certificate_desc">Accept any TLS certificate used by the RSP server</string>
|
||||
<string name="pref_developer_euicc_memory_reset">Allow erasing eUICC</string>
|
||||
<string name="pref_developer_euicc_memory_reset_desc">This is a dangerous operation and hidden by default. As an alternative, you can delete all profiles manually.</string>
|
||||
<string name="pref_developer_es10x_mss">ES10x MSS</string>
|
||||
<string name="pref_developer_es10x_mss_desc">Global ES10x MSS</string>
|
||||
<string-array name="pref_developer_es10x_entry_keys">
|
||||
<item>High Speed</item>
|
||||
<item>Compatibility Mode</item>
|
||||
</string-array>
|
||||
<string-array name="pref_developer_es10x_entry_values" translatable="false">
|
||||
<item>255</item>
|
||||
<item>63</item>
|
||||
</string-array>
|
||||
<string name="pref_developer_isdr_aid_list">Customize ISD-R AID list</string>
|
||||
<string name="pref_developer_isdr_aid_list_desc">Some brands of removable eUICCs may use their own non-standard ISD-R AID, rendering them inaccessible to third-party apps. We can attempt to use non-standard AIDs added in this list, but there is no guarantee that they will work.</string>
|
||||
<string name="pref_info">Info</string>
|
||||
|
|
|
@ -81,6 +81,14 @@
|
|||
app:summary="@string/pref_developer_euicc_memory_reset_desc"
|
||||
app:title="@string/pref_developer_euicc_memory_reset" />
|
||||
|
||||
<ListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="pref_developer_es10x_mss"
|
||||
app:summary="@string/pref_developer_es10x_mss_desc"
|
||||
app:title="@string/pref_developer_es10x_mss"
|
||||
app:entries="@array/pref_developer_es10x_entry_keys"
|
||||
app:entryValues="@array/pref_developer_es10x_entry_values" />
|
||||
|
||||
<Preference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="pref_developer_isdr_aid_list"
|
||||
|
|
Loading…
Add table
Reference in a new issue