chore: move to developer options

This commit is contained in:
septs 2025-03-05 10:16:04 +08:00
parent 11c07a05a7
commit e8b5c5c99c
Signed by: septs
SSH key fingerprint: SHA256:ElK0p6DNkbsqYUdJ3I9QHDVf21SQD0c2r+hd7s/r5Co
4 changed files with 11 additions and 18 deletions

View file

@ -44,11 +44,11 @@ class PreferenceRepository(private val context: Context) {
val notificationSwitchFlow = bindFlow(PreferenceKeys.NOTIFICATION_SWITCH, false)
// ---- Advanced ----
val refreshAfterSwitchFlow = bindFlow(PreferenceKeys.REFRESH_AFTER_SWITCH, true)
val disableSafeguardFlow = bindFlow(PreferenceKeys.DISABLE_SAFEGUARD_REMOVABLE_ESIM, false)
val verboseLoggingFlow = bindFlow(PreferenceKeys.VERBOSE_LOGGING, false)
// ---- Developer Options ----
val refreshAfterSwitchFlow = bindFlow(PreferenceKeys.REFRESH_AFTER_SWITCH, true)
val developerOptionsEnabledFlow = bindFlow(PreferenceKeys.DEVELOPER_OPTIONS_ENABLED, false)
val unfilteredProfileListFlow = bindFlow(PreferenceKeys.UNFILTERED_PROFILE_LIST, false)
val ignoreTLSCertificateFlow = bindFlow(PreferenceKeys.IGNORE_TLS_CERTIFICATE, false)
@ -61,17 +61,11 @@ class PreferenceFlowWrapper<T> private constructor(
private val context: Context,
private val key: Preferences.Key<T>,
inner: Flow<T>,
private val setter: suspend (T) -> T = { it }
) : Flow<T> by inner {
internal constructor(context: Context, key: Preferences.Key<T>, defaultValue: T) :
this(context, key, context.dataStore.data.map { it[key] ?: defaultValue })
suspend fun updatePreference(value: T) {
context.dataStore.edit { it[key] = setter(value) }
context.dataStore.edit { it[key] = value }
}
internal fun with(flow: Flow<T> = this, setter: suspend (T) -> T) =
PreferenceFlowWrapper(context, key, flow, setter)
}
fun PreferenceFlowWrapper<Boolean>.negative() = with(map { !it }) { !it }

View file

@ -162,8 +162,8 @@
<string name="pref_notifications_switch">Switching</string>
<string name="pref_notifications_switch_desc">Send notifications for <i>switching</i> profiles\nNote that this type of notification is unreliable.</string>
<string name="pref_advanced">Advanced</string>
<string name="pref_advanced_disable_refresh_after_switch">Disable refresh status after switching</string>
<string name="pref_advanced_disable_refresh_after_switch_desc">Avoid OMAPI crash after switch</string>
<string name="pref_advanced_refresh_after_switch">Refresh status after switching</string>
<string name="pref_advanced_refresh_after_switch_desc">If crash after switch, Please trying disable the function</string>
<string name="pref_advanced_disable_safeguard_removable_esim">Allow Disabling / Deleting Active Profile</string>
<string name="pref_advanced_disable_safeguard_removable_esim_desc">By default, this app prevents you from disabling the active profile on a removable eSIM inserted in the device, because doing so may <i>sometimes</i> render it inaccessible.\nCheck this box to <i>remove</i> this safeguard.</string>
<string name="pref_advanced_verbose_logging">Verbose Logging</string>

View file

@ -10,7 +10,6 @@ import androidx.preference.CheckBoxPreference
import androidx.preference.Preference
import im.angry.easyeuicc.R
import im.angry.openeuicc.util.encodeHex
import im.angry.openeuicc.util.negative
import im.angry.openeuicc.util.preferenceRepository
import java.security.MessageDigest
@ -32,11 +31,11 @@ class UnprivilegedSettingsFragment : SettingsFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
super.onCreatePreferences(savedInstanceState, rootKey)
addPreferencesFromResource(R.xml.pref_unprivileged_settings)
mergePreferenceOverlay("pref_advanced_overlay", "pref_advanced")
mergePreferenceOverlay("pref_developer_overlay", "pref_developer")
mergePreferenceOverlay("pref_info_overlay", "pref_info")
requirePreference<CheckBoxPreference>("pref_advanced_disable_refreshed_after_switch")
.bindBooleanFlow(preferenceRepository.refreshAfterSwitchFlow.negative())
requirePreference<CheckBoxPreference>("pref_developer_refreshed_after_switch")
.bindBooleanFlow(preferenceRepository.refreshAfterSwitchFlow)
requirePreference<Preference>("pref_info_ara_m").apply {
summary = firstSigner.encodeHex()

View file

@ -2,13 +2,13 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:isPreferenceVisible="false"
app:key="pref_advanced_overlay">
app:key="pref_developer_overlay">
<CheckBoxPreference
app:iconSpaceReserved="false"
app:key="pref_advanced_disable_refreshed_after_switch"
app:key="pref_developer_refreshed_after_switch"
app:order="1"
app:summary="@string/pref_advanced_disable_refresh_after_switch_desc"
app:title="@string/pref_advanced_disable_refresh_after_switch" />
app:summary="@string/pref_advanced_refresh_after_switch_desc"
app:title="@string/pref_advanced_refresh_after_switch" />
</PreferenceCategory>
<PreferenceCategory
app:isPreferenceVisible="false"