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
42376fca
Commit
42376fca
authored
May 15, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some naming refactoring
parent
c765ed8e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
22 deletions
+27
-22
ChatRoomNavigator.kt
...rocket/android/chatroom/presentation/ChatRoomNavigator.kt
+2
-2
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+3
-1
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+1
-1
ChatRoomActivity.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
+7
-7
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+12
-9
MainNavigator.kt
...va/chat/rocket/android/main/presentation/MainNavigator.kt
+2
-2
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomNavigator.kt
View file @
42376fca
...
...
@@ -32,10 +32,10 @@ class ChatRoomNavigator(internal val activity: ChatRoomActivity) {
isChatRoomReadOnly
:
Boolean
,
chatRoomLastSeen
:
Long
,
isChatRoomSubscribed
:
Boolean
,
isChatRoom
Owne
r
:
Boolean
,
isChatRoom
Creato
r
:
Boolean
,
chatRoomMessage
:
String
)
{
activity
.
startActivity
(
activity
.
chatRoomIntent
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoomReadOnly
,
chatRoomLastSeen
,
isChatRoomSubscribed
,
isChatRoom
Owne
r
,
chatRoomMessage
))
isChatRoomReadOnly
,
chatRoomLastSeen
,
isChatRoomSubscribed
,
isChatRoom
Creato
r
,
chatRoomMessage
))
activity
.
overridePendingTransition
(
R
.
anim
.
open_enter
,
R
.
anim
.
open_exit
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
42376fca
...
...
@@ -116,7 +116,9 @@ class ChatRoomPresenter @Inject constructor(
chatRoles
=
if
(
roomTypeOf
(
roomType
)
!
is
RoomType
.
DirectMessage
)
{
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
roomType
),
roomName
=
roomName
)
}
else
emptyList
()
// User has at least an 'owner' or 'moderator' role.
val
userCanMod
=
isOwnerOrMod
()
// Can post anyway if has the 'post-readonly' permission on server.
val
userCanPost
=
userCanMod
||
permissions
.
canPostToReadOnlyChannels
()
chatIsBroadcast
=
chatRoomsInteractor
.
getById
(
currentServer
,
roomId
)
?.
run
{
broadcast
...
...
@@ -680,7 +682,7 @@ class ChatRoomPresenter @Inject constructor(
chatRoomType
=
it
.
type
.
toString
(),
chatRoomLastSeen
=
it
.
lastSeen
?:
-
1
,
chatRoomName
=
roomName
,
isChatRoom
Owne
r
=
false
,
isChatRoom
Creato
r
=
false
,
isChatRoomReadOnly
=
false
,
isChatRoomSubscribed
=
it
.
open
,
chatRoomMessage
=
message
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
42376fca
...
...
@@ -139,7 +139,7 @@ interface ChatRoomView : LoadingView, MessageView {
/**
* Communicate whether it's a broadcast channel and if current user can post to it.
*/
fun
onRoomUpdated
(
userCanPost
:
Boolean
,
channelIsBroadcast
:
Boolean
,
user
IsModerator
:
Boolean
)
fun
onRoomUpdated
(
userCanPost
:
Boolean
,
channelIsBroadcast
:
Boolean
,
user
CanMod
:
Boolean
)
/**
* Open a DM with the user in the given [chatRoom] and pass the [permalink] for the message
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
View file @
42376fca
...
...
@@ -28,7 +28,7 @@ fun Context.chatRoomIntent(
isChatRoomReadOnly
:
Boolean
,
chatRoomLastSeen
:
Long
,
isChatRoomSubscribed
:
Boolean
=
true
,
isChatRoom
Owne
r
:
Boolean
=
false
,
isChatRoom
Creato
r
:
Boolean
=
false
,
chatRoomMessage
:
String
?
=
null
):
Intent
{
return
Intent
(
this
,
ChatRoomActivity
::
class
.
java
).
apply
{
...
...
@@ -38,7 +38,7 @@ fun Context.chatRoomIntent(
putExtra
(
INTENT_CHAT_ROOM_IS_READ_ONLY
,
isChatRoomReadOnly
)
putExtra
(
INTENT_CHAT_ROOM_LAST_SEEN
,
chatRoomLastSeen
)
putExtra
(
INTENT_CHAT_IS_SUBSCRIBED
,
isChatRoomSubscribed
)
putExtra
(
INTENT_CHAT_ROOM_IS_
OWNER
,
isChatRoomOwne
r
)
putExtra
(
INTENT_CHAT_ROOM_IS_
CREATOR
,
isChatRoomCreato
r
)
putExtra
(
INTENT_CHAT_ROOM_MESSAGE
,
chatRoomMessage
)
}
}
...
...
@@ -47,7 +47,7 @@ private const val INTENT_CHAT_ROOM_ID = "chat_room_id"
private
const
val
INTENT_CHAT_ROOM_NAME
=
"chat_room_name"
private
const
val
INTENT_CHAT_ROOM_TYPE
=
"chat_room_type"
private
const
val
INTENT_CHAT_ROOM_IS_READ_ONLY
=
"chat_room_is_read_only"
private
const
val
INTENT_CHAT_ROOM_IS_
OWNER
=
"chat_room_is_owne
r"
private
const
val
INTENT_CHAT_ROOM_IS_
CREATOR
=
"chat_room_is_creato
r"
private
const
val
INTENT_CHAT_ROOM_LAST_SEEN
=
"chat_room_last_seen"
private
const
val
INTENT_CHAT_IS_SUBSCRIBED
=
"is_chat_room_subscribed"
private
const
val
INTENT_CHAT_ROOM_MESSAGE
=
"chat_room_message"
...
...
@@ -65,7 +65,7 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector {
private
lateinit
var
chatRoomType
:
String
private
var
isChatRoomReadOnly
:
Boolean
=
false
private
var
isChatRoomSubscribed
:
Boolean
=
true
private
var
isChatRoom
Owne
r
:
Boolean
=
false
private
var
isChatRoom
Creato
r
:
Boolean
=
false
private
var
chatRoomLastSeen
:
Long
=
-
1L
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
...
...
@@ -94,8 +94,8 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector {
isChatRoomReadOnly
=
intent
.
getBooleanExtra
(
INTENT_CHAT_ROOM_IS_READ_ONLY
,
true
)
requireNotNull
(
isChatRoomReadOnly
)
{
"no chat_room_is_read_only provided in Intent extras"
}
isChatRoom
Owner
=
intent
.
getBooleanExtra
(
INTENT_CHAT_ROOM_IS_OWNE
R
,
false
)
requireNotNull
(
isChatRoom
Owner
)
{
"no chat_room_is_owne
r provided in Intent extras"
}
isChatRoom
Creator
=
intent
.
getBooleanExtra
(
INTENT_CHAT_ROOM_IS_CREATO
R
,
false
)
requireNotNull
(
isChatRoom
Creator
)
{
"no chat_room_is_creato
r provided in Intent extras"
}
val
chatRoomMessage
=
intent
.
getStringExtra
(
INTENT_CHAT_ROOM_MESSAGE
)
...
...
@@ -108,7 +108,7 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector {
if
(
supportFragmentManager
.
findFragmentByTag
(
TAG_CHAT_ROOM_FRAGMENT
)
==
null
)
{
addFragment
(
TAG_CHAT_ROOM_FRAGMENT
,
R
.
id
.
fragment_container
)
{
newInstance
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoomReadOnly
,
chatRoomLastSeen
,
isChatRoomSubscribed
,
isChatRoom
Owne
r
,
chatRoomMessage
)
isChatRoomSubscribed
,
isChatRoom
Creato
r
,
chatRoomMessage
)
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
42376fca
...
...
@@ -80,7 +80,7 @@ fun newInstance(
isChatRoomReadOnly
:
Boolean
,
chatRoomLastSeen
:
Long
,
isSubscribed
:
Boolean
=
true
,
isChatRoom
Owne
r
:
Boolean
=
false
,
isChatRoom
Creato
r
:
Boolean
=
false
,
chatRoomMessage
:
String
?
=
null
):
Fragment
{
return
ChatRoomFragment
().
apply
{
...
...
@@ -91,7 +91,7 @@ fun newInstance(
putBoolean
(
BUNDLE_IS_CHAT_ROOM_READ_ONLY
,
isChatRoomReadOnly
)
putLong
(
BUNDLE_CHAT_ROOM_LAST_SEEN
,
chatRoomLastSeen
)
putBoolean
(
BUNDLE_CHAT_ROOM_IS_SUBSCRIBED
,
isSubscribed
)
putBoolean
(
BUNDLE_CHAT_ROOM_IS_
OWNER
,
isChatRoomOwne
r
)
putBoolean
(
BUNDLE_CHAT_ROOM_IS_
CREATOR
,
isChatRoomCreato
r
)
putString
(
BUNDLE_CHAT_ROOM_MESSAGE
,
chatRoomMessage
)
}
}
...
...
@@ -104,7 +104,7 @@ private const val BUNDLE_IS_CHAT_ROOM_READ_ONLY = "is_chat_room_read_only"
private
const
val
REQUEST_CODE_FOR_PERFORM_SAF
=
42
private
const
val
BUNDLE_CHAT_ROOM_LAST_SEEN
=
"chat_room_last_seen"
private
const
val
BUNDLE_CHAT_ROOM_IS_SUBSCRIBED
=
"chat_room_is_subscribed"
private
const
val
BUNDLE_CHAT_ROOM_IS_
OWNER
=
"chat_room_is_owne
r"
private
const
val
BUNDLE_CHAT_ROOM_IS_
CREATOR
=
"chat_room_is_creato
r"
private
const
val
BUNDLE_CHAT_ROOM_MESSAGE
=
"chat_room_message"
class
ChatRoomFragment
:
Fragment
(),
ChatRoomView
,
EmojiKeyboardListener
,
EmojiReactionListener
{
...
...
@@ -120,7 +120,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private
var
chatRoomMessage
:
String
?
=
null
private
var
isSubscribed
:
Boolean
=
true
private
var
isChatRoomReadOnly
:
Boolean
=
false
private
var
isChatRoom
Owne
r
:
Boolean
=
false
private
var
isChatRoom
Creato
r
:
Boolean
=
false
private
var
isBroadcastChannel
:
Boolean
=
false
private
lateinit
var
emojiKeyboardPopup
:
EmojiKeyboardPopup
private
var
chatRoomLastSeen
:
Long
=
-
1
...
...
@@ -161,7 +161,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
isChatRoomReadOnly
=
bundle
.
getBoolean
(
BUNDLE_IS_CHAT_ROOM_READ_ONLY
)
isSubscribed
=
bundle
.
getBoolean
(
BUNDLE_CHAT_ROOM_IS_SUBSCRIBED
)
chatRoomLastSeen
=
bundle
.
getLong
(
BUNDLE_CHAT_ROOM_LAST_SEEN
)
isChatRoom
Owner
=
bundle
.
getBoolean
(
BUNDLE_CHAT_ROOM_IS_OWNE
R
)
isChatRoom
Creator
=
bundle
.
getBoolean
(
BUNDLE_CHAT_ROOM_IS_CREATO
R
)
chatRoomMessage
=
bundle
.
getString
(
BUNDLE_CHAT_ROOM_MESSAGE
)
}
else
{
requireNotNull
(
bundle
)
{
"no arguments supplied when the fragment was instantiated"
}
...
...
@@ -285,7 +285,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
override
fun
onRoomUpdated
(
userCanPost
:
Boolean
,
channelIsBroadcast
:
Boolean
,
userCanMod
:
Boolean
)
{
setupMessageComposer
(
isChatRoomOwner
||
userCanPost
)
// TODO: We should rely solely on the user being able to post, but we cannot guarantee
// that the "(channels|groups).roles" endpoint is supported by the server in use.
setupMessageComposer
(
userCanPost
||
isChatRoomCreator
)
isBroadcastChannel
=
channelIsBroadcast
if
(
isBroadcastChannel
&&
!
userCanMod
)
activity
?.
invalidateOptionsMenu
()
}
...
...
@@ -615,12 +617,12 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
onJoined
(
c
anPost
:
Boolean
)
{
override
fun
onJoined
(
userC
anPost
:
Boolean
)
{
ui
{
input_container
.
setVisible
(
true
)
button_join_chat
.
setVisible
(
false
)
isSubscribed
=
true
setupMessageComposer
(
isChatRoomOwne
r
)
setupMessageComposer
(
userCanPost
||
isChatRoomCreato
r
)
}
}
...
...
@@ -652,7 +654,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
private
fun
setupMessageComposer
(
canPost
:
Boolean
)
{
if
(!
canPost
&&
isChatRoomReadOnly
)
{
val
showComposer
=
if
(!
canPost
)
canPost
else
isChatRoomCreator
if
(!
showComposer
&&
isChatRoomReadOnly
)
{
text_room_is_read_only
.
setVisible
(
true
)
input_container
.
setVisible
(
false
)
}
else
if
(!
isSubscribed
)
{
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainNavigator.kt
View file @
42376fca
...
...
@@ -36,9 +36,9 @@ class MainNavigator(internal val activity: MainActivity) {
isChatRoomReadOnly
:
Boolean
,
chatRoomLastSeen
:
Long
,
isChatRoomSubscribed
:
Boolean
,
isChatRoom
Owne
r
:
Boolean
)
{
isChatRoom
Creato
r
:
Boolean
)
{
activity
.
startActivity
(
activity
.
chatRoomIntent
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoomReadOnly
,
chatRoomLastSeen
,
isChatRoomSubscribed
,
isChatRoom
Owne
r
))
isChatRoomReadOnly
,
chatRoomLastSeen
,
isChatRoomSubscribed
,
isChatRoom
Creato
r
))
activity
.
overridePendingTransition
(
R
.
anim
.
open_enter
,
R
.
anim
.
open_exit
)
}
...
...
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