mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-05 16:22:31 -08:00
fix: Merge dialog #2283
This commit is contained in:
4 files changed
+27
-19
No files matched your search
@@ -561,11 +561,11 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
mMainCredentialViewModel.uiState.collect { uiState ->
|
||||
when (uiState) {
|
||||
mMainCredentialViewModel.uiState.collect { credentialState ->
|
||||
when (credentialState) {
|
||||
is MainCredentialViewModel.UIState.Loading -> {}
|
||||
is MainCredentialViewModel.UIState.OnMainCredentialEntered -> {
|
||||
mergeDatabaseFrom(uiState.databaseUri, uiState.mainCredential)
|
||||
mergeDatabaseFrom(credentialState.databaseUri, credentialState.mainCredential)
|
||||
mMainCredentialViewModel.onActionReceived()
|
||||
}
|
||||
is MainCredentialViewModel.UIState.OnMainCredentialCanceled -> {
|
||||
@@ -724,7 +724,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Search not used
|
||||
},
|
||||
selectionAction = { intentSenderMode, typeMode, searchInfo ->
|
||||
selectionAction = { _, typeMode, _ ->
|
||||
var entry: Entry? = null
|
||||
try {
|
||||
entry = result.data?.getNewEntry(database)
|
||||
@@ -744,7 +744,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
}
|
||||
}
|
||||
},
|
||||
registrationAction = { intentSenderMode, typeMode, searchInfo ->
|
||||
registrationAction = { _, _, _ ->
|
||||
// Save not used
|
||||
}
|
||||
)
|
||||
@@ -901,7 +901,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Nothing here, a search is simply performed
|
||||
},
|
||||
selectionAction = { intentSenderMode, typeMode, searchInfo ->
|
||||
selectionAction = { _, typeMode, searchInfo ->
|
||||
when (typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD -> {
|
||||
@@ -1686,13 +1686,13 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
context = activity,
|
||||
database = database,
|
||||
searchInfo = searchInfo,
|
||||
onItemsFound = { openedDatabase, items ->
|
||||
onItemsFound = { _, items ->
|
||||
when (typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD -> {
|
||||
MagikeyboardService.performSelection(
|
||||
items = items,
|
||||
actionPopulateKeyboard = { entryInfo ->
|
||||
actionPopulateKeyboard = { _ ->
|
||||
activity.buildSpecialModeResponseAndSetResult(items)
|
||||
onValidateSpecialMode()
|
||||
},
|
||||
|
||||
+13
-6
@@ -28,6 +28,7 @@ import androidx.fragment.app.activityViewModels
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.helpers.ExternalFileHelper
|
||||
import com.kunzisoft.keepass.database.MainCredential
|
||||
import com.kunzisoft.keepass.database.exception.FileNotFoundDatabaseException
|
||||
import com.kunzisoft.keepass.utils.UriUtil.getDocumentFile
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.view.MainCredentialView
|
||||
@@ -71,15 +72,21 @@ class MainCredentialDialogFragment : DatabaseDialogFragment() {
|
||||
databaseUri = databaseUri
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
mExternalFileHelper = ExternalFileHelper(this)
|
||||
mExternalFileHelper?.buildOpenDocument { uri ->
|
||||
if (uri != null) {
|
||||
mainCredentialView?.populateKeyFileView(uri)
|
||||
mExternalFileHelper = ExternalFileHelper(this)
|
||||
mExternalFileHelper?.buildOpenDocument { uri ->
|
||||
if (uri != null) {
|
||||
mainCredentialView?.populateKeyFileView(uri)
|
||||
}
|
||||
}
|
||||
mainCredentialView?.setOpenKeyfileClickListener(mExternalFileHelper)
|
||||
} ?: run {
|
||||
mMainCredentialViewModel.cancelMainCredential(
|
||||
databaseUri = null,
|
||||
error = FileNotFoundDatabaseException()
|
||||
)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
mainCredentialView?.setOpenKeyfileClickListener(mExternalFileHelper)
|
||||
|
||||
return builder.create()
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ class MainCredentialViewModel: ViewModel() {
|
||||
}
|
||||
|
||||
fun cancelMainCredential(
|
||||
databaseUri: Uri
|
||||
databaseUri: Uri?,
|
||||
error: Throwable? = null
|
||||
) {
|
||||
mUiState.value = UIState.OnMainCredentialCanceled(databaseUri, MainCredential())
|
||||
mUiState.value = UIState.OnMainCredentialCanceled(databaseUri, error)
|
||||
}
|
||||
|
||||
fun onActionReceived() {
|
||||
@@ -39,8 +40,8 @@ class MainCredentialViewModel: ViewModel() {
|
||||
val mainCredential: MainCredential
|
||||
): UIState()
|
||||
data class OnMainCredentialCanceled(
|
||||
val databaseUri: Uri,
|
||||
val mainCredential: MainCredential
|
||||
val databaseUri: Uri?,
|
||||
val error: Throwable?
|
||||
): UIState()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user