mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-30 05:43:00 -08:00
Fix autolink #720
This commit is contained in:
1 parent
2c669deae5
commit
daf239c93c
5 files changed
+25
-9
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user