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
f55f9761
Commit
f55f9761
authored
Feb 22, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Codacy feedback
parent
398a1fa9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
31 deletions
+31
-31
RocketChatMessageUrlsLayout.java
...t/android/widget/message/RocketChatMessageUrlsLayout.java
+31
-31
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/RocketChatMessageUrlsLayout.java
View file @
f55f9761
...
...
@@ -5,17 +5,12 @@ import android.content.Context;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.support.graphics.drawable.VectorDrawableCompat
;
import
android.text.TextUtils
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
com.facebook.drawee.backends.pipeline.Fresco
;
import
com.facebook.drawee.drawable.ProgressBarDrawable
;
import
com.facebook.drawee.generic.GenericDraweeHierarchy
;
import
com.facebook.drawee.interfaces.DraweeController
;
import
com.facebook.drawee.view.SimpleDraweeView
;
import
java.util.List
;
...
...
@@ -76,19 +71,8 @@ public class RocketChatMessageUrlsLayout extends LinearLayout {
private
void
appendUrlView
(
WebContent
webContent
,
boolean
autoloadImages
)
{
final
String
url
=
webContent
.
getUrl
();
final
WebContentHeaders
webContentHeaders
=
webContent
.
getHeaders
();
String
contentType
=
webContentHeaders
!=
null
?
webContentHeaders
.
getContentType
()
:
""
;
if
(
contentType
!=
null
&&
contentType
.
startsWith
(
"image/"
)
&&
ImageFormat
.
SUPPORTED_LIST
.
contains
(
contentType
))
{
final
View
inlineImageView
=
inflater
.
inflate
(
R
.
layout
.
message_inline_image
,
this
,
false
);
final
SimpleDraweeView
inlineImage
=
(
SimpleDraweeView
)
inlineImageView
.
findViewById
(
R
.
id
.
message_inline_image
);
final
View
loadView
=
inlineImageView
.
findViewById
(
R
.
id
.
message_inline_image_load
);
loadImage
(
url
,
inlineImage
,
loadView
,
autoloadImages
);
addView
(
inlineImageView
);
}
addMessageInlineImage
(
webContent
,
autoloadImages
,
url
);
// see Rocket.Chat:packages/rocketchat-oembed/client/oembedUrlWidget.coffee
final
Map
<
WebContentMeta
.
Type
,
WebContentMeta
>
webContentMetaMap
=
webContent
.
getMetaMap
();
...
...
@@ -96,18 +80,6 @@ public class RocketChatMessageUrlsLayout extends LinearLayout {
return
;
}
String
title
=
webContent
.
getMetaTitle
();
String
description
=
webContent
.
getMetaDescription
();
if
(
description
!=
null
)
{
if
(
description
.
startsWith
(
"\""
))
{
description
=
description
.
substring
(
1
);
}
if
(
description
.
endsWith
(
"\""
))
{
description
=
description
.
substring
(
0
,
description
.
length
()
-
1
);
}
}
final
String
imageURL
=
webContent
.
getMetaImage
();
WebContentParsedUrl
parsedUrl
=
webContent
.
getParsedUrl
();
...
...
@@ -116,8 +88,8 @@ public class RocketChatMessageUrlsLayout extends LinearLayout {
View
embedUrl
=
inflater
.
inflate
(
R
.
layout
.
message_inline_embed_url
,
this
,
false
);
((
TextView
)
embedUrl
.
findViewById
(
R
.
id
.
hostname
)).
setText
(
host
);
((
TextView
)
embedUrl
.
findViewById
(
R
.
id
.
title
)).
setText
(
title
);
((
TextView
)
embedUrl
.
findViewById
(
R
.
id
.
description
)).
setText
(
description
);
((
TextView
)
embedUrl
.
findViewById
(
R
.
id
.
title
)).
setText
(
webContent
.
getMetaTitle
()
);
((
TextView
)
embedUrl
.
findViewById
(
R
.
id
.
description
)).
setText
(
removeQuote
(
webContent
.
getMetaDescription
())
);
final
SimpleDraweeView
image
=
(
SimpleDraweeView
)
embedUrl
.
findViewById
(
R
.
id
.
image
);
if
(
TextUtils
.
isEmpty
(
imageURL
))
{
...
...
@@ -139,6 +111,34 @@ public class RocketChatMessageUrlsLayout extends LinearLayout {
addView
(
embedUrl
);
}
private
String
removeQuote
(
String
description
)
{
if
(
description
!=
null
)
{
if
(
description
.
startsWith
(
"\""
))
{
description
=
description
.
substring
(
1
);
}
if
(
description
.
endsWith
(
"\""
))
{
description
=
description
.
substring
(
0
,
description
.
length
()
-
1
);
}
}
return
description
;
}
private
void
addMessageInlineImage
(
WebContent
webContent
,
boolean
autoloadImages
,
String
url
)
{
final
WebContentHeaders
webContentHeaders
=
webContent
.
getHeaders
();
String
contentType
=
webContentHeaders
!=
null
?
webContentHeaders
.
getContentType
()
:
""
;
if
(
contentType
!=
null
&&
contentType
.
startsWith
(
"image/"
)
&&
ImageFormat
.
SUPPORTED_LIST
.
contains
(
contentType
))
{
final
View
inlineImageView
=
inflater
.
inflate
(
R
.
layout
.
message_inline_image
,
this
,
false
);
final
SimpleDraweeView
inlineImage
=
(
SimpleDraweeView
)
inlineImageView
.
findViewById
(
R
.
id
.
message_inline_image
);
final
View
loadView
=
inlineImageView
.
findViewById
(
R
.
id
.
message_inline_image_load
);
loadImage
(
url
,
inlineImage
,
loadView
,
autoloadImages
);
addView
(
inlineImageView
);
}
}
private
void
loadImage
(
final
String
url
,
final
SimpleDraweeView
drawee
,
final
View
load
,
boolean
autoloadImage
)
{
if
(
autoloadImage
)
{
...
...
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