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
541d705a
Commit
541d705a
authored
Dec 10, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #57 multi-line comment
parent
c671d9c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
1 deletion
+50
-1
RocketChatMessageLayout.java
...ocket/android/widget/message/RocketChatMessageLayout.java
+24
-1
highlight_background_with_border.xml
...rc/main/res/drawable/highlight_background_with_border.xml
+7
-0
message_body_highlight.xml
...id-widgets/src/main/res/layout/message_body_highlight.xml
+14
-0
message_styles.xml
...at-android-widgets/src/main/res/values/message_styles.xml
+5
-0
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/RocketChatMessageLayout.java
View file @
541d705a
...
...
@@ -3,6 +3,7 @@ package chat.rocket.android.widget.message;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.widget.LinearLayout
;
...
...
@@ -46,7 +47,29 @@ public class RocketChatMessageLayout extends LinearLayout {
public
void
setText
(
String
messageBody
)
{
removeAllViews
();
appendTextView
(
messageBody
);
if
(
messageBody
.
contains
(
"```"
))
{
boolean
highlight
=
false
;
for
(
final
String
chunk
:
TextUtils
.
split
(
messageBody
.
replace
(
"\r\n"
,
"\n"
),
"```"
))
{
final
String
trimmedChunk
=
chunk
.
replaceFirst
(
"^\n"
,
""
).
replaceFirst
(
"\n$"
,
""
);
if
(
highlight
)
{
appendHighlightTextView
(
trimmedChunk
);
}
else
if
(
trimmedChunk
.
length
()
>
0
)
{
appendTextView
(
trimmedChunk
);
}
highlight
=
!
highlight
;
}
}
else
{
appendTextView
(
messageBody
);
}
}
private
void
appendHighlightTextView
(
String
text
)
{
TextView
textView
=
(
TextView
)
inflater
.
inflate
(
R
.
layout
.
message_body_highlight
,
this
,
false
);
textView
.
setText
(
text
);
Linkify
.
markup
(
textView
);
addView
(
textView
);
}
private
void
appendTextView
(
String
text
)
{
...
...
rocket-chat-android-widgets/src/main/res/drawable/highlight_background_with_border.xml
0 → 100644
View file @
541d705a
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"@color/highlight_text_background_color"
/>
<stroke
android:width=
"1dp"
android:color=
"@color/highlight_text_border_color"
/>
<corners
android:radius=
"4dp"
/>
</shape>
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/layout/message_body_highlight.xml
0 → 100644
View file @
541d705a
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@android:id/text1"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textAppearance=
"@style/TextAppearance.RocketChat.MessageBody.Highlight"
android:background=
"@drawable/highlight_background_with_border"
android:padding=
"6dp"
android:layout_marginStart=
"0px"
android:layout_marginEnd=
"6dp"
android:layout_marginTop=
"3dp"
android:layout_marginBottom=
"3dp"
/>
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/values/message_styles.xml
View file @
541d705a
...
...
@@ -4,6 +4,11 @@
<style
name=
"TextAppearance.RocketChat.MessageBody"
parent=
"TextAppearance.AppCompat.Body1"
>
</style>
<style
name=
"TextAppearance.RocketChat.MessageBody.Highlight"
>
<item
name=
"android:textColor"
>
@color/highlight_text_color
</item>
<item
name=
"android:typeface"
>
monospace
</item>
<item
name=
"android:textStyle"
>
bold
</item>
</style>
<color
name=
"highlight_text_color"
>
#333
</color>
<color
name=
"highlight_text_background_color"
>
#f8f8f8
</color>
...
...
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