feat(UI): Mask WebDAV password while typing (#1564)
* Refactor * feat(UI): Mask WebDAV password while typing * fix: allow space as password * use coroutines for asynchronous setting
This commit is contained in:
parent
fd60bc7f13
commit
26d3be95e3
6 changed files with 42 additions and 25 deletions
|
|
@ -738,7 +738,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
subtitle = stringResource(SYMR.strings.data_saver_image_quality_summary),
|
||||
enabled = dataSaver != DataSaver.NONE,
|
||||
),
|
||||
kotlin.run {
|
||||
run {
|
||||
val dataSaverImageFormatJpeg by sourcePreferences.dataSaverImageFormatJpeg()
|
||||
.collectAsState()
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
|
|
@ -808,7 +808,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
title = stringResource(SYMR.strings.log_level),
|
||||
subtitle = stringResource(SYMR.strings.log_level_summary),
|
||||
),
|
||||
kotlin.run {
|
||||
run {
|
||||
var enableEncryptDatabase by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
if (enableEncryptDatabase) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ object SettingsBrowseScreen : SearchableSettings {
|
|||
enabled = sourcePreferences.relatedMangas().get(),
|
||||
),
|
||||
// KMK <--
|
||||
kotlin.run {
|
||||
run {
|
||||
val count by sourcePreferences.sourcesTabCategories().collectAsState()
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(MR.strings.action_edit_categories),
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import com.journeyapps.barcodescanner.ScanContract
|
|||
import com.journeyapps.barcodescanner.ScanOptions
|
||||
import eu.kanade.domain.sync.SyncPreferences
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.screen.SettingsSecurityScreen.PasswordDialog
|
||||
import eu.kanade.presentation.more.settings.screen.data.CreateBackupScreen
|
||||
import eu.kanade.presentation.more.settings.screen.data.RestoreBackupScreen
|
||||
import eu.kanade.presentation.more.settings.screen.data.StorageInfo
|
||||
|
|
@ -562,7 +563,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||
SyncManager.SyncService.SYNCYOMI.value to stringResource(SYMR.strings.syncyomi),
|
||||
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(SYMR.strings.google_drive),
|
||||
// KMK -->
|
||||
SyncManager.SyncService.WebDAV.value to stringResource(KMR.strings.web_dav),
|
||||
SyncManager.SyncService.WEB_DAV.value to stringResource(KMR.strings.web_dav),
|
||||
// KMK <--
|
||||
),
|
||||
title = stringResource(SYMR.strings.pref_sync_service),
|
||||
|
|
@ -606,7 +607,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||
SyncManager.SyncService.SYNCYOMI -> getSelfHostPreferences(syncPreferences)
|
||||
SyncManager.SyncService.GOOGLE_DRIVE -> getGoogleDrivePreferences()
|
||||
// KMK -->
|
||||
SyncManager.SyncService.WebDAV -> getWebDavPreferences(syncPreferences)
|
||||
SyncManager.SyncService.WEB_DAV -> getWebDavPreferences(syncPreferences)
|
||||
// KMK <--
|
||||
}
|
||||
|
||||
|
|
@ -759,7 +760,9 @@ object SettingsDataScreen : SearchableSettings {
|
|||
title = stringResource(SYMR.strings.pref_sync_api_key),
|
||||
subtitle = stringResource(SYMR.strings.pref_sync_api_key_summ),
|
||||
onConfirm = {
|
||||
syncPreferences.clientAPIKey().set(it)
|
||||
scope.launch {
|
||||
syncPreferences.clientAPIKey().set(it)
|
||||
}
|
||||
true
|
||||
},
|
||||
icon = null,
|
||||
|
|
@ -808,17 +811,28 @@ object SettingsDataScreen : SearchableSettings {
|
|||
true
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.EditTextPreference(
|
||||
preference = syncPreferences.webDavPassword(),
|
||||
title = stringResource(KMR.strings.pref_webdav_password),
|
||||
subtitle = stringResource(KMR.strings.pref_webdav_password_summ),
|
||||
onValueChanged = { newValue ->
|
||||
scope.launch {
|
||||
syncPreferences.webDavPassword().set(newValue)
|
||||
}
|
||||
true
|
||||
},
|
||||
),
|
||||
run {
|
||||
var dialogOpen by remember { mutableStateOf(false) }
|
||||
if (dialogOpen) {
|
||||
PasswordDialog(
|
||||
onDismissRequest = { dialogOpen = false },
|
||||
onReturnPassword = { password ->
|
||||
dialogOpen = false
|
||||
scope.launch {
|
||||
syncPreferences.webDavPassword().set(password.replace("\n", ""))
|
||||
}
|
||||
},
|
||||
title = KMR.strings.pref_webdav_password,
|
||||
)
|
||||
}
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(KMR.strings.pref_webdav_password),
|
||||
subtitle = stringResource(KMR.strings.pref_webdav_password_summ),
|
||||
onClick = {
|
||||
dialogOpen = true
|
||||
},
|
||||
)
|
||||
},
|
||||
Preference.PreferenceItem.EditTextPreference(
|
||||
preference = syncPreferences.webDavFolder(),
|
||||
title = stringResource(KMR.strings.pref_webdav_folder),
|
||||
|
|
@ -832,7 +846,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||
),
|
||||
)
|
||||
}
|
||||
// MK <--
|
||||
// KMK <--
|
||||
|
||||
@Composable
|
||||
private fun getSyncNowPref(): Preference.PreferenceGroup {
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||
enabled = passwordProtectDownloads,
|
||||
|
||||
),
|
||||
kotlin.run {
|
||||
run {
|
||||
var dialogOpen by remember { mutableStateOf(false) }
|
||||
if (dialogOpen) {
|
||||
PasswordDialog(
|
||||
|
|
@ -183,7 +183,7 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||
securityPreferences.cbzPassword().set("")
|
||||
},
|
||||
),
|
||||
kotlin.run {
|
||||
run {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val count by securityPreferences.authenticatorTimeRanges().collectAsState()
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
|
|
@ -199,7 +199,7 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||
},
|
||||
)
|
||||
},
|
||||
kotlin.run {
|
||||
run {
|
||||
val selection by securityPreferences.authenticatorDays().collectAsState()
|
||||
var dialogOpen by remember { mutableStateOf(false) }
|
||||
if (dialogOpen) {
|
||||
|
|
@ -332,13 +332,16 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||
fun PasswordDialog(
|
||||
onDismissRequest: () -> Unit,
|
||||
onReturnPassword: (String) -> Unit,
|
||||
// KMK -->
|
||||
title: StringResource = SYMR.strings.cbz_archive_password,
|
||||
// KMK <--
|
||||
) {
|
||||
var password by rememberSaveable { mutableStateOf("") }
|
||||
var passwordVisibility by remember { mutableStateOf(false) }
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
|
||||
title = { Text(text = stringResource(SYMR.strings.cbz_archive_password)) },
|
||||
title = { Text(text = stringResource(title)) },
|
||||
text = {
|
||||
TextField(
|
||||
value = password,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class SyncManager(
|
|||
SYNCYOMI(1),
|
||||
GOOGLE_DRIVE(2),
|
||||
// KMK -->
|
||||
WebDAV(3),
|
||||
WEB_DAV(3),
|
||||
// KMK <--
|
||||
;
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ class SyncManager(
|
|||
}
|
||||
|
||||
// KMK -->
|
||||
SyncService.WebDAV -> {
|
||||
SyncService.WEB_DAV -> {
|
||||
WebDavSyncService(context, json, syncPreferences, notifier)
|
||||
}
|
||||
// KMK <--
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class WebDavSyncService(
|
|||
private val url: String = syncPreferences.webDavUrl().get().trim()
|
||||
private val folder: String = syncPreferences.webDavFolder().get().trim('/')
|
||||
private val username: String = syncPreferences.webDavUsername().get().trim()
|
||||
private val password: String = syncPreferences.webDavPassword().get().trim()
|
||||
private val password: String = syncPreferences.webDavPassword().get()
|
||||
private val credentials: String = Credentials.basic(username, password)
|
||||
|
||||
private fun buildWebDavFileUrl(fileName: String = "backup.proto"): String {
|
||||
|
|
|
|||
Loading…
Reference in a new issue