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
1c2e9e44
Commit
1c2e9e44
authored
Oct 06, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement new UX to messages reply
parent
2ecf4674
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
205 additions
and
70 deletions
+205
-70
RoomContract.java
...a/chat/rocket/android/fragment/chatroom/RoomContract.java
+1
-1
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+4
-4
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+4
-4
MessageFormManager.kt
...ocket/android/layouthelper/chatroom/MessageFormManager.kt
+15
-1
MessagePopup.java
...at/rocket/android/layouthelper/chatroom/MessagePopup.java
+2
-2
MessageFormLayout.java
...chat/rocket/android/widget/message/MessageFormLayout.java
+50
-4
ic_close.xml
...t-chat-android-widgets/src/main/res/drawable/ic_close.xml
+8
-0
message_composer.xml
...-android-widgets/src/main/res/layout/message_composer.xml
+121
-54
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomContract.java
View file @
1c2e9e44
...
...
@@ -37,7 +37,7 @@ public interface RoomContract {
void
manualLoadImages
();
void
onReply
(
String
message
);
void
onReply
(
String
m
arkdown
,
Message
m
essage
);
void
onCopy
(
String
message
);
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
1c2e9e44
...
...
@@ -649,8 +649,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
@Override
public
void
onReply
(
String
message
)
{
messageFormManager
.
set
EditMessage
(
message
);
public
void
onReply
(
String
m
arkdown
,
Message
m
essage
)
{
messageFormManager
.
set
Reply
(
markdown
,
message
);
}
@Override
...
...
@@ -665,11 +665,11 @@ public class RoomFragment extends AbstractChatRoomFragment implements
public
void
showMessageActions
(
Message
message
)
{
Activity
context
=
getActivity
();
if
(
context
!=
null
&&
context
instanceof
MainActivity
)
{
MessagePopup
.
with
(
message
)
MessagePopup
.
take
(
message
)
.
setReplyAction
(
presenter:
:
replyMessage
)
.
setEditAction
(
this
::
onEditMessage
)
.
setCopyAction
(
msg
->
onCopy
(
message
.
getMessage
()))
.
show
(
context
);
.
show
With
(
context
);
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
1c2e9e44
...
...
@@ -127,13 +127,13 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
public
void
replyMessage
(
Message
message
)
{
this
.
absoluteUrlHelper
.
getRocketChatAbsoluteUrl
()
.
cache
()
.
observeOn
(
Schedulers
.
io
(
))
.
subscrib
eOn
(
AndroidSchedulers
.
mainThread
())
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()
))
.
observ
eOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
serverUrl
->
{
if
(
serverUrl
.
isPresent
())
{
String
baseUrl
=
serverUrl
.
get
().
getBaseUrl
();
view
.
onReply
(
buildReplyM
essage
(
baseUrl
,
message
)
);
view
.
onReply
(
buildReplyM
arkDown
(
baseUrl
,
message
),
message
);
}
},
Logger:
:
report
...
...
@@ -145,7 +145,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
view
.
onCopy
(
message
.
getMessage
());
}
private
String
buildReplyM
essage
(
String
baseUrl
,
Message
message
)
{
private
String
buildReplyM
arkDown
(
String
baseUrl
,
Message
message
)
{
if
(
currentRoom
==
null
||
message
.
getUser
()
==
null
)
{
return
""
;
}
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageFormManager.kt
View file @
1c2e9e44
package
chat.rocket.android.layouthelper.chatroom
import
android.view.View
import
chat.rocket.android.widget.message.MessageFormLayout
import
chat.rocket.core.models.Message
class
MessageFormManager
(
private
val
messageFormLayout
:
MessageFormLayout
,
val
callback
:
MessageFormLayout
.
ExtraActionSelectionClickListener
)
{
private
var
sendMessageCallback
:
SendMessageCallback
?
=
null
private
var
replyMarkDown
:
String
=
""
init
{
messageFormLayout
.
setExtraActionSelectionClickListener
(
callback
)
...
...
@@ -31,8 +34,19 @@ class MessageFormManager(private val messageFormLayout: MessageFormLayout, val c
messageFormLayout
.
isEnabled
=
enable
}
fun
setReply
(
replyMarkDown
:
String
,
message
:
Message
)
{
this
.
replyMarkDown
=
replyMarkDown
messageFormLayout
.
setReplyContent
(
message
)
messageFormLayout
.
setReplyCancelListener
({
this
.
replyMarkDown
=
""
messageFormLayout
.
clearReplyContent
()
})
}
private
fun
sendMessage
(
message
:
String
)
{
sendMessageCallback
?.
onSubmitText
(
message
)
val
finalMessage
=
if
(
replyMarkDown
.
isNotEmpty
())
"$replyMarkDown $message"
else
message
replyMarkDown
=
""
sendMessageCallback
?.
onSubmitText
(
finalMessage
)
}
interface
SendMessageCallback
{
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessagePopup.java
View file @
1c2e9e44
...
...
@@ -112,7 +112,7 @@ public class MessagePopup {
singleton
.
defaultActions
.
add
(
COPY_ACTION_INFO
);
}
public
static
MessagePopup
with
(
Message
message
)
{
public
static
MessagePopup
take
(
Message
message
)
{
if
(
singleton
==
null
)
{
synchronized
(
MessagePopup
.
class
)
{
if
(
singleton
==
null
)
{
...
...
@@ -163,7 +163,7 @@ public class MessagePopup {
return
singleton
;
}
public
void
show
(
Context
context
)
{
public
void
show
With
(
Context
context
)
{
showAvailableActionsOnly
(
context
);
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/MessageFormLayout.java
View file @
1c2e9e44
...
...
@@ -4,6 +4,7 @@ import android.annotation.TargetApi;
import
android.content.Context
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.v13.view.inputmethod.InputContentInfoCompat
;
import
android.text.Editable
;
import
android.text.TextUtils
;
...
...
@@ -15,10 +16,14 @@ import android.view.ViewGroup;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.EditText
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
chat.rocket.android.widget.R
;
import
chat.rocket.android.widget.helper.DebouncingOnClickListener
;
import
chat.rocket.core.models.Message
;
public
class
MessageFormLayout
extends
LinearLayout
{
...
...
@@ -27,6 +32,11 @@ public class MessageFormLayout extends LinearLayout {
private
ImageButton
attachButton
;
private
ImageButton
sendButton
;
private
RelativeLayout
replyBar
;
private
ImageView
replyCancelButton
;
private
TextView
replyMessageText
;
private
TextView
replyUsernameText
;
private
ExtraActionSelectionClickListener
extraActionSelectionClickListener
;
private
SubmitTextListener
submitTextListener
;
private
ImageKeyboardEditText
.
OnCommitContentListener
listener
;
...
...
@@ -65,6 +75,11 @@ public class MessageFormLayout extends LinearLayout {
}
});
replyCancelButton
=
composer
.
findViewById
(
R
.
id
.
reply_cancel
);
replyMessageText
=
composer
.
findViewById
(
R
.
id
.
reply_message
);
replyUsernameText
=
composer
.
findViewById
(
R
.
id
.
reply_username
);
replyBar
=
composer
.
findViewById
(
R
.
id
.
reply_bar
);
sendButton
=
composer
.
findViewById
(
R
.
id
.
button_send
);
sendButton
.
setOnClickListener
(
new
DebouncingOnClickListener
()
{
...
...
@@ -73,6 +88,7 @@ public class MessageFormLayout extends LinearLayout {
String
messageText
=
getText
();
if
(
messageText
.
length
()
>
0
&&
submitTextListener
!=
null
)
{
submitTextListener
.
onSubmitText
(
messageText
);
clearReplyContent
();
}
}
});
...
...
@@ -118,6 +134,16 @@ public class MessageFormLayout extends LinearLayout {
addView
(
composer
);
}
public
void
clearReplyContent
()
{
replyBar
.
setVisibility
(
View
.
GONE
);
replyMessageText
.
setText
(
""
);
replyUsernameText
.
setText
(
""
);
}
public
void
setReplyCancelListener
(
OnClickListener
onClickListener
)
{
replyCancelButton
.
setOnClickListener
(
onClickListener
);
}
public
EditText
getEditText
()
{
return
(
EditText
)
composer
.
findViewById
(
R
.
id
.
editor
);
}
...
...
@@ -154,10 +180,7 @@ public class MessageFormLayout extends LinearLayout {
if
(
text
.
length
()
>
0
)
{
editor
.
setSelection
(
text
.
length
());
InputMethodManager
inputMethodManager
=
(
InputMethodManager
)
editor
.
getContext
()
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
editor
.
requestFocus
();
inputMethodManager
.
showSoftInput
(
editor
,
0
);
requestFocusAndShowKeyboard
();
}
}
});
...
...
@@ -173,6 +196,29 @@ public class MessageFormLayout extends LinearLayout {
this
.
listener
=
listener
;
}
public
void
setReplyContent
(
@NonNull
Message
message
)
{
String
text
=
message
.
getMessage
();
if
(!
TextUtils
.
isEmpty
(
text
))
{
replyMessageText
.
setText
(
text
);
replyUsernameText
.
setText
(
message
.
getUser
().
getUsername
());
replyBar
.
setVisibility
(
View
.
VISIBLE
);
requestFocusAndShowKeyboard
();
}
}
private
void
requestFocusAndShowKeyboard
()
{
final
EditText
editor
=
getEditor
();
editor
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
InputMethodManager
inputMethodManager
=
(
InputMethodManager
)
editor
.
getContext
()
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
editor
.
requestFocus
();
inputMethodManager
.
showSoftInput
(
editor
,
0
);
}
});
}
private
void
animateHide
(
final
View
view
)
{
view
.
animate
().
scaleX
(
0
).
scaleY
(
0
).
setDuration
(
150
).
withEndAction
(
new
Runnable
()
{
@Override
...
...
rocket-chat-android-widgets/src/main/res/drawable/ic_close.xml
0 → 100644
View file @
1c2e9e44
<!-- drawable/close.xml -->
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:height=
"24dp"
android:width=
"24dp"
android:viewportWidth=
"24"
android:viewportHeight=
"24"
>
<path
android:fillColor=
"#000"
android:pathData=
"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"
/>
</vector>
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/layout/message_composer.xml
View file @
1c2e9e44
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"48dp"
android:background=
"@drawable/top_shadow"
tools:context=
"chat.rocket.android.widget.message.MessageFormLayout"
>
<chat.rocket.android.widget.message.ImageKeyboardEditText
android:id=
"@+id/editor"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginStart=
"16dp"
android:inputType=
"textCapSentences|textMultiLine"
android:hint=
"@string/message_composer_message_hint"
android:textSize=
"14sp"
android:minLines=
"1"
android:maxLines=
"4"
android:background=
"@null"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toLeftOf=
"@+id/container"
app:layout_constraintBottom_toBottomOf=
"parent"
/>
<FrameLayout
android:id=
"@+id/container"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginStart=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginEnd=
"16dp"
app:layout_constraintTop_toTopOf=
"@+id/editor"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintLeft_toRightOf=
"@+id/editor"
app:layout_constraintBottom_toBottomOf=
"@+id/editor"
>
<ImageButton
android:id=
"@+id/button_attach"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:tint=
"@color/color_icon_composer"
app:srcCompat=
"@drawable/ic_attach_file_black_24dp"
android:background=
"?attr/selectableItemBackgroundBorderless"
/>
<ImageButton
android:id=
"@+id/button_send"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:tint=
"@color/color_accent"
app:srcCompat=
"@drawable/ic_send_black_24dp"
android:background=
"?attr/selectableItemBackgroundBorderless"
/>
</FrameLayout>
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/top_shadow"
android:minHeight=
"48dp"
tools:context=
"chat.rocket.android.widget.message.MessageFormLayout"
>
<RelativeLayout
android:id=
"@+id/reply_bar"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"8dp"
android:visibility=
"gone"
app:layout_constraintBottom_toTopOf=
"@+id/keyboard_container"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:layout_editor_absoluteX=
"8dp"
tools:layout_editor_absoluteY=
"8dp"
tools:visibility=
"visible"
>
<android.support.v7.widget.AppCompatImageView
android:id=
"@+id/reply_cancel"
android:layout_width=
"24dp"
android:layout_height=
"24dp"
android:layout_centerVertical=
"true"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:adjustViewBounds=
"true"
app:srcCompat=
"@drawable/ic_close"
app:tint=
"@color/color_icon_composer"
/>
<TextView
android:id=
"@+id/reply_username"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_alignBaseline=
"@id/reply_username"
android:layout_toLeftOf=
"@+id/reply_cancel"
android:layout_toStartOf=
"@id/reply_cancel"
android:ellipsize=
"end"
android:maxLines=
"1"
android:textColor=
"@color/color_accent"
android:textStyle=
"bold"
tools:text=
"jane.doe"
/>
<TextView
android:id=
"@+id/reply_message"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/reply_username"
android:layout_toLeftOf=
"@+id/reply_cancel"
android:layout_toStartOf=
"@id/reply_cancel"
android:ellipsize=
"end"
android:maxLines=
"1"
tools:text=
"Mensagemaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddsdsdsdsdsdsdsdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadadadadddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
/>
</RelativeLayout>
<android.support.constraint.ConstraintLayout
android:id=
"@+id/keyboard_container"
android:layout_width=
"0dp"
android:layout_height=
"48dp"
android:background=
"@drawable/top_shadow"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/reply_bar"
>
<chat.rocket.android.widget.message.ImageKeyboardEditText
android:id=
"@+id/editor"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginStart=
"16dp"
android:background=
"@null"
android:hint=
"@string/message_composer_message_hint"
android:inputType=
"textCapSentences|textMultiLine"
android:maxLines=
"4"
android:minLines=
"1"
android:textSize=
"14sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toLeftOf=
"@+id/container"
app:layout_constraintTop_toTopOf=
"parent"
/>
<FrameLayout
android:id=
"@+id/container"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginStart=
"16dp"
app:layout_constraintBottom_toBottomOf=
"@+id/editor"
app:layout_constraintLeft_toRightOf=
"@+id/editor"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/editor"
>
<ImageButton
android:id=
"@+id/button_attach"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:tint=
"@color/color_icon_composer"
app:srcCompat=
"@drawable/ic_attach_file_black_24dp"
/>
<ImageButton
android:id=
"@+id/button_send"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:tint=
"@color/color_accent"
app:srcCompat=
"@drawable/ic_send_black_24dp"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
\ 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