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
b3382b08
Commit
b3382b08
authored
Jan 19, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PR based improvements
parent
0a926198
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
51 deletions
+55
-51
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+20
-11
UsersOfRoomDialogFragment.java
...d/fragment/chatroom/dialog/UsersOfRoomDialogFragment.java
+1
-1
MessageFormManager.java
...ket/android/layouthelper/chatroom/MessageFormManager.java
+4
-4
MessageRenderer.java
...in/java/chat/rocket/android/renderer/MessageRenderer.java
+6
-6
UserRenderer.java
.../main/java/chat/rocket/android/renderer/UserRenderer.java
+3
-3
ExtraActionPickerDialogFragment.java
...roid/widget/internal/ExtraActionPickerDialogFragment.java
+5
-9
MessageFormLayout.java
...chat/rocket/android/widget/message/MessageFormLayout.java
+16
-17
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
b3382b08
...
@@ -7,6 +7,7 @@ import android.os.Bundle;
...
@@ -7,6 +7,7 @@ import android.os.Bundle;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.Snackbar
;
import
android.support.v4.app.DialogFragment
;
import
android.support.v4.view.GravityCompat
;
import
android.support.v4.view.GravityCompat
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.support.v4.widget.SlidingPaneLayout
;
...
@@ -66,7 +67,10 @@ import permissions.dispatcher.RuntimePermissions;
...
@@ -66,7 +67,10 @@ import permissions.dispatcher.RuntimePermissions;
*/
*/
@RuntimePermissions
@RuntimePermissions
public
class
RoomFragment
extends
AbstractChatRoomFragment
public
class
RoomFragment
extends
AbstractChatRoomFragment
implements
OnBackPressListener
,
RealmModelListAdapter
.
OnItemClickListener
<
PairedMessage
>
{
implements
OnBackPressListener
,
ExtraActionPickerDialogFragment
.
Callback
,
RealmModelListAdapter
.
OnItemClickListener
<
PairedMessage
>
{
private
static
final
int
DIALOG_ID
=
1
;
private
String
serverConfigId
;
private
String
serverConfigId
;
private
RealmHelper
realmHelper
;
private
RealmHelper
realmHelper
;
...
@@ -199,6 +203,14 @@ public class RoomFragment extends AbstractChatRoomFragment
...
@@ -199,6 +203,14 @@ public class RoomFragment extends AbstractChatRoomFragment
setupSideMenu
();
setupSideMenu
();
setupMessageComposer
();
setupMessageComposer
();
setupMessageActions
();
}
private
void
setupMessageActions
()
{
extraActionItems
=
new
ArrayList
<>(
3
);
// fixed number as of now
extraActionItems
.
add
(
new
ImageUploadActionItem
());
extraActionItems
.
add
(
new
AudioUploadActionItem
());
extraActionItems
.
add
(
new
VideoUploadActionItem
());
}
}
private
void
scrollToLatestMessage
()
{
private
void
scrollToLatestMessage
()
{
...
@@ -301,11 +313,6 @@ public class RoomFragment extends AbstractChatRoomFragment
...
@@ -301,11 +313,6 @@ public class RoomFragment extends AbstractChatRoomFragment
}
}
private
void
setupMessageComposer
()
{
private
void
setupMessageComposer
()
{
extraActionItems
=
new
ArrayList
<>(
3
);
// fixed number as of now
extraActionItems
.
add
(
new
ImageUploadActionItem
());
extraActionItems
.
add
(
new
AudioUploadActionItem
());
extraActionItems
.
add
(
new
VideoUploadActionItem
());
final
MessageFormLayout
messageFormLayout
=
final
MessageFormLayout
messageFormLayout
=
(
MessageFormLayout
)
rootView
.
findViewById
(
R
.
id
.
message_composer
);
(
MessageFormLayout
)
rootView
.
findViewById
(
R
.
id
.
message_composer
);
messageFormManager
=
messageFormManager
=
...
@@ -343,7 +350,7 @@ public class RoomFragment extends AbstractChatRoomFragment
...
@@ -343,7 +350,7 @@ public class RoomFragment extends AbstractChatRoomFragment
FileUploadProgressDialogFragment
.
create
(
serverConfigId
,
roomId
,
uplId
)
FileUploadProgressDialogFragment
.
create
(
serverConfigId
,
roomId
,
uplId
)
.
show
(
getFragmentManager
(),
FileUploadProgressDialogFragment
.
class
.
getSimpleName
());
.
show
(
getFragmentManager
(),
FileUploadProgressDialogFragment
.
class
.
getSimpleName
());
}
else
{
}
else
{
//
show
error.
//
onClick
error.
}
}
}
}
...
@@ -450,12 +457,14 @@ public class RoomFragment extends AbstractChatRoomFragment
...
@@ -450,12 +457,14 @@ public class RoomFragment extends AbstractChatRoomFragment
}
}
private
void
showExtraActionSelectionDialog
()
{
private
void
showExtraActionSelectionDialog
()
{
ExtraActionPickerDialogFragment
final
DialogFragment
fragment
=
ExtraActionPickerDialogFragment
.
create
(
new
ArrayList
<>(
extraActionItems
),
this
::
onExtraItemSelected
)
.
create
(
new
ArrayList
<>(
extraActionItems
));
.
show
(
getFragmentManager
(),
"ExtraActionPickerDialogFragment"
);
fragment
.
setTargetFragment
(
this
,
DIALOG_ID
);
fragment
.
show
(
getFragmentManager
(),
"ExtraActionPickerDialogFragment"
);
}
}
private
void
onExtraItemSelected
(
int
itemId
)
{
@Override
public
void
onItemSelected
(
int
itemId
)
{
for
(
AbstractExtraActionItem
extraActionItem
:
extraActionItems
)
{
for
(
AbstractExtraActionItem
extraActionItem
:
extraActionItems
)
{
if
(
extraActionItem
.
getItemId
()
==
itemId
)
{
if
(
extraActionItem
.
getItemId
()
==
itemId
)
{
RoomFragmentPermissionsDispatcher
RoomFragmentPermissionsDispatcher
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/dialog/UsersOfRoomDialogFragment.java
View file @
b3382b08
...
@@ -23,7 +23,7 @@ import chat.rocket.android.realm_helper.RealmObjectObserver;
...
@@ -23,7 +23,7 @@ import chat.rocket.android.realm_helper.RealmObjectObserver;
import
chat.rocket.android.service.RocketChatService
;
import
chat.rocket.android.service.RocketChatService
;
/**
/**
* Dialog to
show
members in a room.
* Dialog to
onClick
members in a room.
*/
*/
public
class
UsersOfRoomDialogFragment
extends
AbstractChatRoomDialogFragment
{
public
class
UsersOfRoomDialogFragment
extends
AbstractChatRoomDialogFragment
{
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageFormManager.java
View file @
b3382b08
...
@@ -11,14 +11,14 @@ public class MessageFormManager {
...
@@ -11,14 +11,14 @@ public class MessageFormManager {
private
SendMessageCallback
sendMessageCallback
;
private
SendMessageCallback
sendMessageCallback
;
public
MessageFormManager
(
MessageFormLayout
messageFormLayout
,
public
MessageFormManager
(
MessageFormLayout
messageFormLayout
,
MessageFormLayout
.
ShowExtraActionSelectionCallback
callback
)
{
MessageFormLayout
.
ExtraActionSelectionClickListener
callback
)
{
this
.
messageFormLayout
=
messageFormLayout
;
this
.
messageFormLayout
=
messageFormLayout
;
init
(
callback
);
init
(
callback
);
}
}
private
void
init
(
MessageFormLayout
.
ShowExtraActionSelectionCallback
callback
)
{
private
void
init
(
MessageFormLayout
.
ExtraActionSelectionClickListener
listener
)
{
messageFormLayout
.
set
ShowExtraActionSelectionCallback
(
callback
);
messageFormLayout
.
set
ExtraActionSelectionClickListener
(
listener
);
messageFormLayout
.
setTextListener
(
this
::
sendMessage
);
messageFormLayout
.
set
Submit
TextListener
(
this
::
sendMessage
);
}
}
public
void
setSendMessageCallback
(
SendMessageCallback
sendMessageCallback
)
{
public
void
setSendMessageCallback
(
SendMessageCallback
sendMessageCallback
)
{
...
...
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.java
View file @
b3382b08
...
@@ -27,7 +27,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
...
@@ -27,7 +27,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
}
/**
/**
*
show
Avatar image.
*
onClick
Avatar image.
*/
*/
public
MessageRenderer
avatarInto
(
ImageView
imageView
,
String
hostname
)
{
public
MessageRenderer
avatarInto
(
ImageView
imageView
,
String
hostname
)
{
switch
(
object
.
getSyncState
())
{
switch
(
object
.
getSyncState
())
{
...
@@ -42,7 +42,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
...
@@ -42,7 +42,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
}
/**
/**
*
show
Username in textView.
*
onClick
Username in textView.
*/
*/
public
MessageRenderer
usernameInto
(
TextView
textView
)
{
public
MessageRenderer
usernameInto
(
TextView
textView
)
{
userRenderer
.
usernameInto
(
textView
);
userRenderer
.
usernameInto
(
textView
);
...
@@ -50,7 +50,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
...
@@ -50,7 +50,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
}
/**
/**
*
show
timestamp in textView.
*
onClick
timestamp in textView.
*/
*/
public
MessageRenderer
timestampInto
(
TextView
textView
)
{
public
MessageRenderer
timestampInto
(
TextView
textView
)
{
if
(!
shouldHandle
(
textView
))
{
if
(!
shouldHandle
(
textView
))
{
...
@@ -71,7 +71,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
...
@@ -71,7 +71,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
}
/**
/**
*
show
body in RocketChatMessageLayout.
*
onClick
body in RocketChatMessageLayout.
*/
*/
public
MessageRenderer
bodyInto
(
RocketChatMessageLayout
rocketChatMessageLayout
)
{
public
MessageRenderer
bodyInto
(
RocketChatMessageLayout
rocketChatMessageLayout
)
{
if
(!
shouldHandle
(
rocketChatMessageLayout
))
{
if
(!
shouldHandle
(
rocketChatMessageLayout
))
{
...
@@ -84,7 +84,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
...
@@ -84,7 +84,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
}
/**
/**
*
show
urls in RocketChatMessageUrlsLayout.
*
onClick
urls in RocketChatMessageUrlsLayout.
*/
*/
public
MessageRenderer
urlsInto
(
RocketChatMessageUrlsLayout
urlsLayout
)
{
public
MessageRenderer
urlsInto
(
RocketChatMessageUrlsLayout
urlsLayout
)
{
if
(!
shouldHandle
(
urlsLayout
))
{
if
(!
shouldHandle
(
urlsLayout
))
{
...
@@ -103,7 +103,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
...
@@ -103,7 +103,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
}
/**
/**
*
show
urls in RocketChatMessageUrlsLayout.
*
onClick
urls in RocketChatMessageUrlsLayout.
*/
*/
public
MessageRenderer
attachmentsInto
(
RocketChatMessageAttachmentsLayout
attachmentsLayout
,
public
MessageRenderer
attachmentsInto
(
RocketChatMessageAttachmentsLayout
attachmentsLayout
,
String
hostname
,
String
userId
,
String
token
)
{
String
hostname
,
String
userId
,
String
token
)
{
...
...
app/src/main/java/chat/rocket/android/renderer/UserRenderer.java
View file @
b3382b08
...
@@ -19,7 +19,7 @@ public class UserRenderer extends AbstractRenderer<User> {
...
@@ -19,7 +19,7 @@ public class UserRenderer extends AbstractRenderer<User> {
}
}
/**
/**
*
show
Avatar image.
*
onClick
Avatar image.
*/
*/
public
UserRenderer
avatarInto
(
ImageView
imageView
,
String
hostname
)
{
public
UserRenderer
avatarInto
(
ImageView
imageView
,
String
hostname
)
{
if
(!
shouldHandle
(
imageView
))
{
if
(!
shouldHandle
(
imageView
))
{
...
@@ -33,7 +33,7 @@ public class UserRenderer extends AbstractRenderer<User> {
...
@@ -33,7 +33,7 @@ public class UserRenderer extends AbstractRenderer<User> {
}
}
/**
/**
*
show
Username in textView.
*
onClick
Username in textView.
*/
*/
public
UserRenderer
usernameInto
(
TextView
textView
)
{
public
UserRenderer
usernameInto
(
TextView
textView
)
{
if
(!
shouldHandle
(
textView
))
{
if
(!
shouldHandle
(
textView
))
{
...
@@ -45,7 +45,7 @@ public class UserRenderer extends AbstractRenderer<User> {
...
@@ -45,7 +45,7 @@ public class UserRenderer extends AbstractRenderer<User> {
}
}
/**
/**
*
show
user's status color into imageView.
*
onClick
user's status color into imageView.
*/
*/
public
UserRenderer
statusColorInto
(
ImageView
imageView
)
{
public
UserRenderer
statusColorInto
(
ImageView
imageView
)
{
if
(!
shouldHandle
(
imageView
))
{
if
(!
shouldHandle
(
imageView
))
{
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/internal/ExtraActionPickerDialogFragment.java
View file @
b3382b08
...
@@ -2,6 +2,7 @@ package chat.rocket.android.widget.internal;
...
@@ -2,6 +2,7 @@ package chat.rocket.android.widget.internal;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.support.design.widget.BottomSheetDialogFragment
;
import
android.support.design.widget.BottomSheetDialogFragment
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
java.util.List
;
import
java.util.List
;
...
@@ -12,13 +13,11 @@ import chat.rocket.android.widget.message.MessageExtraActionItemPresenter;
...
@@ -12,13 +13,11 @@ import chat.rocket.android.widget.message.MessageExtraActionItemPresenter;
public
class
ExtraActionPickerDialogFragment
extends
BottomSheetDialogFragment
{
public
class
ExtraActionPickerDialogFragment
extends
BottomSheetDialogFragment
{
private
List
<
MessageExtraActionItemPresenter
>
actionItems
;
private
List
<
MessageExtraActionItemPresenter
>
actionItems
;
private
Callback
callback
;
public
static
ExtraActionPickerDialogFragment
create
(
public
static
ExtraActionPickerDialogFragment
create
(
List
<
MessageExtraActionItemPresenter
>
actionItems
,
Callback
callback
)
{
List
<
MessageExtraActionItemPresenter
>
actionItems
)
{
ExtraActionPickerDialogFragment
fragment
=
new
ExtraActionPickerDialogFragment
();
ExtraActionPickerDialogFragment
fragment
=
new
ExtraActionPickerDialogFragment
();
fragment
.
setActionItems
(
actionItems
);
fragment
.
setActionItems
(
actionItems
);
fragment
.
setCallback
(
callback
);
return
fragment
;
return
fragment
;
}
}
...
@@ -27,10 +26,6 @@ public class ExtraActionPickerDialogFragment extends BottomSheetDialogFragment {
...
@@ -27,10 +26,6 @@ public class ExtraActionPickerDialogFragment extends BottomSheetDialogFragment {
this
.
actionItems
=
actionItems
;
this
.
actionItems
=
actionItems
;
}
}
public
void
setCallback
(
Callback
callback
)
{
this
.
callback
=
callback
;
}
@Override
@Override
public
final
void
setupDialog
(
Dialog
dialog
,
int
style
)
{
public
final
void
setupDialog
(
Dialog
dialog
,
int
style
)
{
super
.
setupDialog
(
dialog
,
style
);
super
.
setupDialog
(
dialog
,
style
);
...
@@ -51,8 +46,9 @@ public class ExtraActionPickerDialogFragment extends BottomSheetDialogFragment {
...
@@ -51,8 +46,9 @@ public class ExtraActionPickerDialogFragment extends BottomSheetDialogFragment {
}
}
private
void
callbackOnItemSelected
(
int
itemId
)
{
private
void
callbackOnItemSelected
(
int
itemId
)
{
if
(
callback
!=
null
)
{
final
Fragment
fragment
=
getTargetFragment
();
callback
.
onItemSelected
(
itemId
);
if
(
fragment
instanceof
Callback
)
{
((
Callback
)
fragment
).
onItemSelected
(
itemId
);
}
}
}
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/MessageFormLayout.java
View file @
b3382b08
...
@@ -14,7 +14,6 @@ import android.widget.EditText;
...
@@ -14,7 +14,6 @@ import android.widget.EditText;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
java.util.ArrayList
;
import
chat.rocket.android.widget.R
;
import
chat.rocket.android.widget.R
;
public
class
MessageFormLayout
extends
LinearLayout
{
public
class
MessageFormLayout
extends
LinearLayout
{
...
@@ -24,8 +23,8 @@ public class MessageFormLayout extends LinearLayout {
...
@@ -24,8 +23,8 @@ public class MessageFormLayout extends LinearLayout {
private
View
btnExtra
;
private
View
btnExtra
;
private
View
btnSubmit
;
private
View
btnSubmit
;
private
ShowExtraActionSelectionCallback
showExtraActionSelectionCallback
;
private
ExtraActionSelectionClickListener
extraActionSelectionClickListener
;
private
TextListener
t
extListener
;
private
SubmitTextListener
submitT
extListener
;
public
MessageFormLayout
(
Context
context
)
{
public
MessageFormLayout
(
Context
context
)
{
super
(
context
);
super
(
context
);
...
@@ -57,7 +56,7 @@ public class MessageFormLayout extends LinearLayout {
...
@@ -57,7 +56,7 @@ public class MessageFormLayout extends LinearLayout {
btnExtra
.
setOnClickListener
(
new
OnClickListener
()
{
btnExtra
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
showExtraActionSelectionDialog
();
onExtraActionSelectionClick
();
}
}
});
});
...
@@ -67,8 +66,8 @@ public class MessageFormLayout extends LinearLayout {
...
@@ -67,8 +66,8 @@ public class MessageFormLayout extends LinearLayout {
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
String
messageText
=
getText
();
String
messageText
=
getText
();
if
(
messageText
.
length
()
>
0
&&
t
extListener
!=
null
)
{
if
(
messageText
.
length
()
>
0
&&
submitT
extListener
!=
null
)
{
t
extListener
.
onSubmitText
(
messageText
);
submitT
extListener
.
onSubmitText
(
messageText
);
}
}
}
}
});
});
...
@@ -101,18 +100,18 @@ public class MessageFormLayout extends LinearLayout {
...
@@ -101,18 +100,18 @@ public class MessageFormLayout extends LinearLayout {
addView
(
composer
);
addView
(
composer
);
}
}
public
void
set
ShowExtraActionSelectionCallback
(
public
void
set
ExtraActionSelectionClickListener
(
ShowExtraActionSelectionCallback
showExtraActionSelectionCallback
)
{
ExtraActionSelectionClickListener
extraActionSelectionClickListener
)
{
this
.
showExtraActionSelectionCallback
=
showExtraActionSelectionCallback
;
this
.
extraActionSelectionClickListener
=
extraActionSelectionClickListener
;
}
}
public
void
set
TextListener
(
TextListener
t
extListener
)
{
public
void
set
SubmitTextListener
(
SubmitTextListener
submitT
extListener
)
{
this
.
textListener
=
t
extListener
;
this
.
submitTextListener
=
submitT
extListener
;
}
}
private
void
showExtraActionSelectionDialog
()
{
private
void
onExtraActionSelectionClick
()
{
if
(
showExtraActionSelectionCallback
!=
null
)
{
if
(
extraActionSelectionClickListener
!=
null
)
{
showExtraActionSelectionCallback
.
show
();
extraActionSelectionClickListener
.
onClick
();
}
}
}
}
...
@@ -151,11 +150,11 @@ public class MessageFormLayout extends LinearLayout {
...
@@ -151,11 +150,11 @@ public class MessageFormLayout extends LinearLayout {
});
});
}
}
public
interface
ShowExtraActionSelectionCallback
{
public
interface
ExtraActionSelectionClickListener
{
void
show
();
void
onClick
();
}
}
public
interface
TextListener
{
public
interface
Submit
TextListener
{
void
onSubmitText
(
String
message
);
void
onSubmitText
(
String
message
);
}
}
}
}
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