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
64762358
Commit
64762358
authored
May 15, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract room name from permalink
parent
a2d07ad9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+2
-1
MessageHelper.kt
...src/main/java/chat/rocket/android/helper/MessageHelper.kt
+17
-5
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
64762358
...
...
@@ -123,7 +123,8 @@ class ChatRoomPresenter @Inject constructor(
view
.
onRoomUpdated
(
canPost
,
chatIsBroadcast
)
loadMessages
(
roomId
,
roomType
)
chatRoomMessage
?.
let
{
messageHelper
.
messageIdFromPermalink
(
it
)
}
?.
let
{
messageId
->
citeMessage
(
roomName
,
messageHelper
.
roomTypeFromPermalink
(
chatRoomMessage
)
!!
,
messageId
,
true
)
val
name
=
messageHelper
.
roomNameFromPermalink
(
chatRoomMessage
)
citeMessage
(
name
!!
,
messageHelper
.
roomTypeFromPermalink
(
chatRoomMessage
)
!!
,
messageId
,
true
)
}
}
}
...
...
app/src/main/java/chat/rocket/android/helper/MessageHelper.kt
View file @
64762358
...
...
@@ -30,8 +30,17 @@ class MessageHelper @Inject constructor(
fun
messageIdFromPermalink
(
permalink
:
String
):
String
?
{
PERMALINK_REGEX
.
find
(
permalink
.
trim
())
?.
let
{
if
(
it
.
groupValues
.
size
==
4
)
{
return
it
.
groupValues
[
3
]
if
(
it
.
groupValues
.
size
==
5
)
{
return
it
.
groupValues
[
MESSAGE_ID
]
}
}
return
null
}
fun
roomNameFromPermalink
(
permalink
:
String
):
String
?
{
PERMALINK_REGEX
.
find
(
permalink
.
trim
())
?.
let
{
if
(
it
.
groupValues
.
size
==
5
)
{
return
it
.
groupValues
[
ROOM_NAME
]
}
}
return
null
...
...
@@ -39,8 +48,8 @@ class MessageHelper @Inject constructor(
fun
roomTypeFromPermalink
(
permalink
:
String
):
String
?
{
PERMALINK_REGEX
.
find
(
permalink
.
trim
())
?.
let
{
if
(
it
.
groupValues
.
size
==
4
)
{
val
type
=
it
.
groupValues
[
2
]
if
(
it
.
groupValues
.
size
==
5
)
{
val
type
=
it
.
groupValues
[
ROOM_TYPE
]
return
when
(
type
)
{
"group"
->
"p"
"channel"
->
"c"
...
...
@@ -54,6 +63,9 @@ class MessageHelper @Inject constructor(
}
companion
object
{
val
PERMALINK_REGEX
=
"(?:__|[*#])|\\[(.+?)\\]\\(.+?//.+?/(.+)/.+\\?.*=(.*)\\)"
.
toRegex
()
private
const
val
ROOM_TYPE
=
2
private
const
val
ROOM_NAME
=
3
private
const
val
MESSAGE_ID
=
4
val
PERMALINK_REGEX
=
"(?:__|[*#])|\\[(.+?)\\]\\(.+?//.+?/(.+)/(.+)\\?.*=(.*)\\)"
.
toRegex
()
}
}
\ No newline at end of file
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