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
af5d6e32
Unverified
Commit
af5d6e32
authored
May 02, 2018
by
Rafael Kellermann Streit
Committed by
GitHub
May 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1239 from RocketChat/fix/fix-url-preview-click
[FIX] Fix url preview on messages
parents
5122f1fd
f9585e44
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
10 deletions
+29
-10
UrlPreviewViewHolder.kt
...t/rocket/android/chatroom/adapter/UrlPreviewViewHolder.kt
+11
-3
MessageParser.kt
...src/main/java/chat/rocket/android/helper/MessageParser.kt
+2
-7
View.kt
...src/main/java/chat/rocket/android/util/extensions/View.kt
+16
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/UrlPreviewViewHolder.kt
View file @
af5d6e32
...
...
@@ -5,6 +5,7 @@ import android.net.Uri
import
android.view.View
import
chat.rocket.android.chatroom.viewmodel.UrlPreviewViewModel
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.util.extensions.openTabbedUrl
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
kotlinx.android.synthetic.main.message_url_preview.view.*
...
...
@@ -32,10 +33,17 @@ class UrlPreviewViewHolder(itemView: View,
text_title
.
content
=
data
.
title
text_description
.
content
=
data
.
description
?:
""
url_preview_layout
.
setOnClickListener
{
view
->
view
.
context
.
startActivity
(
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
data
.
rawData
.
url
)))
}
url_preview_layout
.
setOnClickListener
(
onClickListener
)
text_host
.
setOnClickListener
(
onClickListener
)
text_title
.
setOnClickListener
(
onClickListener
)
image_preview
.
setOnClickListener
(
onClickListener
)
text_description
.
setOnClickListener
(
onClickListener
)
}
}
private
val
onClickListener
=
{
view
:
View
->
if
(
data
!=
null
)
{
view
.
openTabbedUrl
(
Uri
.
parse
(
data
!!
.
rawData
.
url
))
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/helper/MessageParser.kt
View file @
af5d6e32
...
...
@@ -6,7 +6,6 @@ import android.graphics.Canvas
import
android.graphics.Paint
import
android.graphics.RectF
import
android.net.Uri
import
android.support.customtabs.CustomTabsIntent
import
android.support.v4.content.res.ResourcesCompat
import
android.text.Spanned
import
android.text.style.ClickableSpan
...
...
@@ -16,6 +15,7 @@ import android.view.View
import
chat.rocket.android.R
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.util.extensions.openTabbedUrl
import
chat.rocket.android.widget.emoji.EmojiParser
import
chat.rocket.android.widget.emoji.EmojiRepository
import
chat.rocket.android.widget.emoji.EmojiTypefaceSpan
...
...
@@ -151,12 +151,7 @@ class MessageParser @Inject constructor(
if
(!
link
.
startsWith
(
"@"
)
&&
link
!
in
consumed
)
{
builder
.
setSpan
(
object
:
ClickableSpan
()
{
override
fun
onClick
(
view
:
View
)
{
with
(
view
)
{
val
tabsbuilder
=
CustomTabsIntent
.
Builder
()
tabsbuilder
.
setToolbarColor
(
ResourcesCompat
.
getColor
(
context
.
resources
,
R
.
color
.
colorPrimary
,
context
.
theme
))
val
customTabsIntent
=
tabsbuilder
.
build
()
customTabsIntent
.
launchUrl
(
context
,
getUri
(
link
))
}
view
.
openTabbedUrl
(
getUri
(
link
))
}
},
matcher
.
start
(
0
),
matcher
.
end
(
0
))
consumed
.
add
(
link
)
...
...
app/src/main/java/chat/rocket/android/util/extensions/View.kt
0 → 100644
View file @
af5d6e32
package
chat.rocket.android.util.extensions
import
android.net.Uri
import
android.support.customtabs.CustomTabsIntent
import
android.support.v4.content.res.ResourcesCompat
import
android.view.View
import
chat.rocket.android.R
fun
View
.
openTabbedUrl
(
url
:
Uri
)
{
with
(
this
)
{
val
tabsbuilder
=
CustomTabsIntent
.
Builder
()
tabsbuilder
.
setToolbarColor
(
ResourcesCompat
.
getColor
(
context
.
resources
,
R
.
color
.
colorPrimary
,
context
.
theme
))
val
customTabsIntent
=
tabsbuilder
.
build
()
customTabsIntent
.
launchUrl
(
context
,
url
)
}
}
\ 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