Fix keyboard selection

This commit is contained in:
J-Jamet
2020-10-19 14:24:12 +02:00
parent c8a952616f
commit 1fe3787186
3 changed files with 26 additions and 25 deletions

View File

@@ -576,14 +576,18 @@ class GroupActivity : LockingActivity(),
EntryActivity.launch(this@GroupActivity, entryVersioned, mReadOnly)
},
{ searchInfo ->
if (!mReadOnly && PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity)) {
if (!mReadOnly
&& searchInfo != null
&& PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity)) {
updateEntryWithSearchInfo(entryVersioned, searchInfo)
} else {
entrySelectedForKeyboardSelection(entryVersioned)
}
},
{ searchInfo, _ ->
if (!mReadOnly && PreferencesUtil.isAutofillSaveSearchInfoEnable(this@GroupActivity)) {
if (!mReadOnly
&& searchInfo != null
&& PreferencesUtil.isAutofillSaveSearchInfoEnable(this@GroupActivity)) {
updateEntryWithSearchInfo(entryVersioned, searchInfo)
} else {
entrySelectedForAutofillSelection(entryVersioned)
@@ -629,7 +633,7 @@ class GroupActivity : LockingActivity(),
onValidateSpecialMode()
}
private fun updateEntryWithSearchInfo(entry: Entry, searchInfo: SearchInfo?) {
private fun updateEntryWithSearchInfo(entry: Entry, searchInfo: SearchInfo) {
val newEntry = Entry(entry)
newEntry.setEntryInfo(mDatabase, newEntry.getEntryInfo(mDatabase).apply {
saveSearchInfo(mDatabase, searchInfo)

View File

@@ -184,7 +184,6 @@ class MagikIME : InputMethodService(), KeyboardView.OnKeyboardActionListener {
}
}
@Suppress("DEPRECATION")
private fun switchToPreviousKeyboard() {
var imeManager: InputMethodManager? = null
try {

View File

@@ -123,29 +123,27 @@ class EntryInfo : Parcelable {
(customFields as ArrayList<Field>).add(Field(field.name + suffix, field.protectedValue))
}
fun saveSearchInfo(database: Database?, searchInfo: SearchInfo?) {
searchInfo?.let { mSearchInfo ->
mSearchInfo.webDomain?.let { webDomain ->
// If unable to save web domain in custom field or URL not populated, save in URL
if (database?.allowEntryCustomFields() != true || url.isEmpty()) {
val retrievedScheme = mSearchInfo.webScheme
val scheme = if (retrievedScheme.isNullOrEmpty()) "http" else retrievedScheme
url = "$scheme://$webDomain"
} else {
// Save web domain in custom field
addUniqueField(Field(WEB_DOMAIN_FIELD_NAME,
ProtectedString(false, webDomain))
fun saveSearchInfo(database: Database?, searchInfo: SearchInfo) {
searchInfo.webDomain?.let { webDomain ->
// If unable to save web domain in custom field or URL not populated, save in URL
if (database?.allowEntryCustomFields() != true || url.isEmpty()) {
val retrievedScheme = searchInfo.webScheme
val scheme = if (retrievedScheme.isNullOrEmpty()) "http" else retrievedScheme
url = "$scheme://$webDomain"
} else {
// Save web domain in custom field
addUniqueField(Field(WEB_DOMAIN_FIELD_NAME,
ProtectedString(false, webDomain))
)
}
} ?: run {
// Save application id in custom field
if (database?.allowEntryCustomFields() == true) {
searchInfo.applicationId?.let { applicationId ->
addUniqueField(Field(APPLICATION_ID_FIELD_NAME,
ProtectedString(false, applicationId))
)
}
} ?: run {
// Save application id in custom field
if (database?.allowEntryCustomFields() == true) {
mSearchInfo.applicationId?.let { applicationId ->
addUniqueField(Field(APPLICATION_ID_FIELD_NAME,
ProtectedString(false, applicationId))
)
}
}
}
}
}