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