Fix autolink #720

This commit is contained in:
J-Jamet
2020-09-25 20:41:24 +02:00
parent 2c669deae5
commit daf239c93c
5 changed files with 25 additions and 9 deletions

View File

@@ -5,6 +5,7 @@ KeePassDX(2.8.6)
* Fix dialog background #717
* Better domain recognition for autofill #702
* Write custom data #651
* Fix autolink #720
KeePassDX(2.8.5)
* Fix Base 64 #708

View File

@@ -96,11 +96,11 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
urlFieldView = findViewById(R.id.entry_url_field)
urlFieldView.setLabel(R.string.entry_url)
urlFieldView.setValueAutoLink(true)
urlFieldView.setLinkAll()
notesFieldView = findViewById(R.id.entry_notes_field)
notesFieldView.setLabel(R.string.entry_notes)
notesFieldView.setValueAutoLink(true)
notesFieldView.setAutoLink()
extraFieldsContainerView = findViewById(R.id.extra_fields_container)
extraFieldsListView = findViewById(R.id.extra_fields_list)
@@ -304,7 +304,7 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
entryCustomField?.apply {
setLabel(title)
setValue(value.toString(), value.isProtected)
setValueAutoLink(true)
setAutoLink()
activateCopyButton(allowCopy)
assignCopyButtonClickListener(onCopyButtonClickListener)
applyFontVisibility(fontInVisibility)

View File

@@ -30,6 +30,7 @@ import android.widget.TextView
import androidx.annotation.StringRes
import androidx.core.text.util.LinkifyCompat
import com.kunzisoft.keepass.R
import java.util.regex.Pattern
class EntryField @JvmOverloads constructor(context: Context,
attrs: AttributeSet? = null,
@@ -100,19 +101,27 @@ class EntryField @JvmOverloads constructor(context: Context,
setTextIsSelectable(true)
}
applyHiddenStyle(isProtected && !showButtonView.isSelected)
if (valueView.autoLinkMask == Linkify.ALL) {
try {
LinkifyCompat.addLinks(this, Linkify.ALL)
} catch (e: Exception) {}
if (valueView.autoLinkMask == LINKIFY_MASKS) {
linkify()
}
}
}
fun setValueAutoLink(autoLink: Boolean) {
valueView.autoLinkMask = if (autoLink && !isProtected) Linkify.ALL else 0
fun setAutoLink() {
if (!isProtected) linkify()
changeProtectedValueParameters()
}
private fun linkify() {
valueView.autoLinkMask = LINKIFY_MASKS
LinkifyCompat.addLinks(valueView, LINKIFY_MASKS)
}
fun setLinkAll() {
valueView.autoLinkMask = LINKIFY_ALL
LinkifyCompat.addLinks(valueView, LINKIFY_ALL)
}
fun activateCopyButton(enable: Boolean) {
// Reverse because isActivated show custom color and allow click
copyButtonView.isActivated = !enable
@@ -122,4 +131,8 @@ class EntryField @JvmOverloads constructor(context: Context,
copyButtonView.setOnClickListener(onClickActionListener)
copyButtonView.visibility = if (onClickActionListener == null) GONE else VISIBLE
}
companion object {
private const val LINKIFY_MASKS = Linkify.WEB_URLS or Linkify.EMAIL_ADDRESSES
private const val LINKIFY_ALL = Linkify.ALL
}
}

View File

@@ -4,3 +4,4 @@
* Fix dialog background #717
* Better domain recognition for autofill #702
* Write custom data #651
* Fix autolink #720

View File

@@ -4,3 +4,4 @@
* Correction du fond des dialogues #717
* Meilleure reconnaissance du domaine pour l'autofill #702
* Ecriture des données customisées #651
* Correction de l'autolink #720