Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
9bcb5346
Commit
9bcb5346
authored
Feb 05, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix username regex
parent
c3307c64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
MessageParser.kt
...src/main/java/chat/rocket/android/helper/MessageParser.kt
+4
-4
No files found.
app/src/main/java/chat/rocket/android/helper/MessageParser.kt
View file @
9bcb5346
...
...
@@ -28,7 +28,7 @@ import javax.inject.Inject
class
MessageParser
@Inject
constructor
(
val
context
:
Application
,
private
val
configuration
:
SpannableConfiguration
)
{
private
val
parser
=
Markwon
.
createParser
()
private
val
user
Pattern
=
Pattern
.
compile
(
"
(@[\\w.]+)"
,
private
val
user
nameRegex
=
Pattern
.
compile
(
"([^\\S]|^)+
(@[\\w.]+)"
,
Pattern
.
MULTILINE
or
Pattern
.
CASE_INSENSITIVE
)
/**
...
...
@@ -65,11 +65,11 @@ class MessageParser @Inject constructor(val context: Application, private val co
}
private
fun
applySpans
(
text
:
CharSequence
)
{
val
matcher
=
user
Pattern
.
matcher
(
text
)
val
matcher
=
user
nameRegex
.
matcher
(
text
)
val
result
=
text
as
Spannable
while
(
matcher
.
find
())
{
val
user
=
matcher
.
group
(
1
)
val
start
=
matcher
.
start
()
val
user
=
matcher
.
group
(
2
)
val
start
=
matcher
.
start
(
2
)
//TODO: should check if username actually exists prior to applying.
result
.
setSpan
(
UsernameClickableSpan
(),
start
,
start
+
user
.
length
,
0
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment