hanggrian/socialview

Mention brokes when dot and underscore used together?

Closed this issue · 2 comments

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?

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.

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