forked from PeterCxy/OpenEUICC
Compare commits
3 commits
24076e8fb4
...
b88345057c
Author | SHA1 | Date | |
---|---|---|---|
b88345057c | |||
9596b8632c | |||
087c760010 |
4 changed files with 40 additions and 24 deletions
|
@ -1,6 +1,7 @@
|
|||
package im.angry.openeuicc.ui
|
||||
|
||||
import android.icu.text.SimpleDateFormat
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
@ -32,9 +33,19 @@ class LogsActivity : AppCompatActivity() {
|
|||
SimpleDateFormat.getDateTimeInstance().format(Date())
|
||||
)
|
||||
},
|
||||
getLogText = { logStr }
|
||||
getLogText = ::buildLogText
|
||||
)
|
||||
|
||||
private fun buildLogText() = buildString {
|
||||
appendLine("Manufacturer: ${Build.MANUFACTURER}")
|
||||
appendLine("Brand: ${Build.BRAND}")
|
||||
appendLine("Model: ${Build.MODEL}")
|
||||
appendLine("SDK Version: ${Build.VERSION.SDK_INT}")
|
||||
appendLine("App Version: $selfAppVersion")
|
||||
appendLine("-".repeat(10))
|
||||
appendLine(logStr)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
|
@ -29,7 +29,7 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
|||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.pref_settings, rootKey)
|
||||
|
||||
developerPref = findPreference("pref_developer")!!
|
||||
developerPref = requirePreference("pref_developer")
|
||||
|
||||
// Show / hide developer preference based on whether it is enabled
|
||||
lifecycleScope.launch {
|
||||
|
@ -38,14 +38,14 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
|||
.collect()
|
||||
}
|
||||
|
||||
findPreference<Preference>("pref_info_app_version")?.apply {
|
||||
requirePreference<Preference>("pref_info_app_version").apply {
|
||||
summary = requireContext().selfAppVersion
|
||||
|
||||
// Enable developer options when this is clicked for 7 times
|
||||
setOnPreferenceClickListener(::onAppVersionClicked)
|
||||
}
|
||||
|
||||
findPreference<Preference>("pref_advanced_language")?.apply {
|
||||
requirePreference<Preference>("pref_advanced_language").apply {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return@apply
|
||||
isVisible = true
|
||||
intent = Intent(Settings.ACTION_APP_LOCALE_SETTINGS).apply {
|
||||
|
@ -53,32 +53,35 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
|||
}
|
||||
}
|
||||
|
||||
findPreference<Preference>("pref_advanced_logs")?.apply {
|
||||
requirePreference<Preference>("pref_advanced_logs").apply {
|
||||
intent = Intent(requireContext(), LogsActivity::class.java)
|
||||
}
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_notifications_download")
|
||||
?.bindBooleanFlow(preferenceRepository.notificationDownloadFlow)
|
||||
requirePreference<CheckBoxPreference>("pref_notifications_download")
|
||||
.bindBooleanFlow(preferenceRepository.notificationDownloadFlow)
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_notifications_delete")
|
||||
?.bindBooleanFlow(preferenceRepository.notificationDeleteFlow)
|
||||
requirePreference<CheckBoxPreference>("pref_notifications_delete")
|
||||
.bindBooleanFlow(preferenceRepository.notificationDeleteFlow)
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_notifications_switch")
|
||||
?.bindBooleanFlow(preferenceRepository.notificationSwitchFlow)
|
||||
requirePreference<CheckBoxPreference>("pref_notifications_switch")
|
||||
.bindBooleanFlow(preferenceRepository.notificationSwitchFlow)
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_advanced_disable_safeguard_removable_esim")
|
||||
?.bindBooleanFlow(preferenceRepository.disableSafeguardFlow)
|
||||
requirePreference<CheckBoxPreference>("pref_advanced_disable_safeguard_removable_esim")
|
||||
.bindBooleanFlow(preferenceRepository.disableSafeguardFlow)
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_advanced_verbose_logging")
|
||||
?.bindBooleanFlow(preferenceRepository.verboseLoggingFlow)
|
||||
requirePreference<CheckBoxPreference>("pref_advanced_verbose_logging")
|
||||
.bindBooleanFlow(preferenceRepository.verboseLoggingFlow)
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_developer_unfiltered_profile_list")
|
||||
?.bindBooleanFlow(preferenceRepository.unfilteredProfileListFlow)
|
||||
requirePreference<CheckBoxPreference>("pref_developer_unfiltered_profile_list")
|
||||
.bindBooleanFlow(preferenceRepository.unfilteredProfileListFlow)
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_ignore_tls_certificate")
|
||||
?.bindBooleanFlow(preferenceRepository.ignoreTLSCertificateFlow)
|
||||
requirePreference<CheckBoxPreference>("pref_developer_ignore_tls_certificate")
|
||||
.bindBooleanFlow(preferenceRepository.ignoreTLSCertificateFlow)
|
||||
}
|
||||
|
||||
protected fun <T : Preference> requirePreference(key: CharSequence) =
|
||||
findPreference<T>(key)!!
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
setupRootViewInsets(requireView().requireViewById(R.id.recycler_view))
|
||||
|
@ -133,8 +136,8 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
protected fun mergePreferenceOverlay(overlayKey: String, targetKey: String) {
|
||||
val overlayCat = findPreference<PreferenceCategory>(overlayKey)!!
|
||||
val targetCat = findPreference<PreferenceCategory>(targetKey)!!
|
||||
val overlayCat = requirePreference<PreferenceCategory>(overlayKey)
|
||||
val targetCat = requirePreference<PreferenceCategory>(targetKey)
|
||||
|
||||
val prefs = buildList {
|
||||
for (i in 0..<overlayCat.preferenceCount) {
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
android:id="@+id/profile_download_code"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/profile_download_code">
|
||||
android:hint="@string/profile_download_code"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:maxLines="1"
|
||||
|
@ -57,7 +58,8 @@
|
|||
android:id="@+id/profile_download_confirmation_code"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/profile_download_confirmation_code">
|
||||
android:hint="@string/profile_download_confirmation_code"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:maxLines="1"
|
||||
|
|
|
@ -31,7 +31,7 @@ class UnprivilegedSettingsFragment : SettingsFragment() {
|
|||
addPreferencesFromResource(R.xml.pref_unprivileged_settings)
|
||||
mergePreferenceOverlay("pref_info_overlay", "pref_info")
|
||||
|
||||
findPreference<Preference>("pref_info_ara_m")?.apply {
|
||||
requirePreference<Preference>("pref_info_ara_m").apply {
|
||||
summary = firstSigner.encodeHex()
|
||||
setOnPreferenceClickListener {
|
||||
requireContext().getSystemService(ClipboardManager::class.java)!!
|
||||
|
|
Loading…
Add table
Reference in a new issue