mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-26 20:06:37 -08:00
feat: Build title from webDomain
This commit is contained in:
1 parent
b32bb609de
commit
3fdcd3c43d
1 file changed
+24
-10
@@ -182,26 +182,40 @@ class EntryInfo : NodeInfo {
|
||||
}
|
||||
modification = true
|
||||
}
|
||||
} ?: run {
|
||||
} ?: searchInfo.applicationId?.let { applicationId ->
|
||||
// Save application id in custom field
|
||||
if (database?.allowEntryCustomFields() == true) {
|
||||
searchInfo.applicationId?.let { applicationId ->
|
||||
if (!containsDomainOrApplicationId(applicationId)) {
|
||||
addUniqueField(
|
||||
Field(
|
||||
APPLICATION_ID_FIELD_NAME,
|
||||
ProtectedString(false, applicationId)
|
||||
)
|
||||
if (!containsDomainOrApplicationId(applicationId)) {
|
||||
addUniqueField(
|
||||
Field(
|
||||
APPLICATION_ID_FIELD_NAME,
|
||||
ProtectedString(false, applicationId)
|
||||
)
|
||||
modification = true
|
||||
}
|
||||
)
|
||||
modification = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if (title.isEmpty()) {
|
||||
title = searchInfoToTitle(searchInfo)
|
||||
}
|
||||
return modification
|
||||
}
|
||||
|
||||
/**
|
||||
* Capitalize and remove suffix of web domain to create a title
|
||||
*/
|
||||
private fun searchInfoToTitle(searchInfo: SearchInfo): String {
|
||||
val webDomain = searchInfo.webDomain
|
||||
return webDomain?.substring(0, webDomain.lastIndexOf('.'))?.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
|
||||
} ?: searchInfo.toString()
|
||||
}
|
||||
|
||||
fun saveRegisterInfo(database: Database?, registerInfo: RegisterInfo) {
|
||||
registerInfo.searchInfo.let {
|
||||
title = searchInfoToTitle(it)
|
||||
}
|
||||
registerInfo.username?.let {
|
||||
username = it
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user