hanggrian / socialview

Android TextView and EditText with hashtag, mention, and hyperlink support
http://hanggrian.com/socialview/
Apache License 2.0
323 stars 81 forks source link

Mention brokes when dot and underscore used together? #65

Closed uzaysan closed 4 years ago

uzaysan commented 5 years ago

If I write a mention like this @name.surname_2123 mention stops at dot. but when I remove either dot or underscore it works. How to fix this?

strangel3t commented 4 years ago

Their regex only supports letters after the @. You can do this to change the regex.

private fun SocialEditText.setPattern(pattern: String) {
    val impl = SocialEditText::class.java.getDeclaredField("impl")
    impl.isAccessible = true
    val socialView = impl.get(this) as SocialView
    val PATTERN_MENTION = SocialView::class.java.getDeclaredField("PATTERN_MENTION")
    PATTERN_MENTION.isAccessible = true
    PATTERN_MENTION.set(socialView, Pattern.compile(pattern))
    impl.set(this, socialView)
}

Had the same problem. Resolved using reflection and kotlin extension functions.

hanggrian commented 4 years ago

In the upcoming version 0.3, you may write your own pattern for each of the feature.