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
bebb5a92
Commit
bebb5a92
authored
Jan 12, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gets the read only attribute of a ChatRoom.
parent
6f85fabe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
20 deletions
+18
-20
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+0
-1
ChatRoomActivity.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
+7
-7
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+8
-8
ChatRoomsNavigator.kt
...cket/android/chatrooms/presentation/ChatRoomsNavigator.kt
+2
-2
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+1
-2
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
bebb5a92
...
...
@@ -6,7 +6,6 @@ import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.launchUI
import
chat.rocket.common.model.BaseRoom
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.messages
import
chat.rocket.core.internal.rest.sendMessage
import
javax.inject.Inject
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
View file @
bebb5a92
...
...
@@ -15,26 +15,26 @@ import dagger.android.support.HasSupportFragmentInjector
import
kotlinx.android.synthetic.main.app_bar_chat_room.*
import
javax.inject.Inject
fun
Context
.
chatRoomIntent
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoom
Open
:
Boolean
):
Intent
{
fun
Context
.
chatRoomIntent
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoom
ReadOnly
:
Boolean
):
Intent
{
return
Intent
(
this
,
ChatRoomActivity
::
class
.
java
).
apply
{
putExtra
(
INTENT_CHAT_ROOM_ID
,
chatRoomId
)
putExtra
(
INTENT_CHAT_ROOM_NAME
,
chatRoomName
)
putExtra
(
INTENT_CHAT_ROOM_TYPE
,
chatRoomType
)
putExtra
(
INTENT_IS_CHAT_ROOM_
OPEN
,
isChatRoomOpen
)
putExtra
(
INTENT_IS_CHAT_ROOM_
READ_ONLY
,
isChatRoomReadOnly
)
}
}
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_IS_CHAT_ROOM_
OPEN
=
"is_chat_room_open
"
private
const
val
INTENT_IS_CHAT_ROOM_
READ_ONLY
=
"is_chat_room_read_only
"
class
ChatRoomActivity
:
AppCompatActivity
(),
HasSupportFragmentInjector
{
@Inject
lateinit
var
fragmentDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Fragment
>
private
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomName
:
String
private
lateinit
var
chatRoomType
:
String
private
var
isChatRoom
Open
:
Boolean
=
tru
e
private
var
isChatRoom
ReadOnly
:
Boolean
=
fals
e
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
...
...
@@ -51,13 +51,13 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector {
chatRoomType
=
intent
.
getStringExtra
(
INTENT_CHAT_ROOM_TYPE
)
requireNotNull
(
chatRoomType
)
{
"no chat_room_type provided in Intent extras"
}
isChatRoom
Open
=
intent
.
getBooleanExtra
(
INTENT_IS_CHAT_ROOM_OPEN
,
true
)
requireNotNull
(
chatRoomType
)
{
"no is_chat_room_
open
provided in Intent extras"
}
isChatRoom
ReadOnly
=
intent
.
getBooleanExtra
(
INTENT_IS_CHAT_ROOM_READ_ONLY
,
true
)
requireNotNull
(
chatRoomType
)
{
"no is_chat_room_
read_only
provided in Intent extras"
}
setupToolbar
(
chatRoomName
)
addFragment
(
"ChatRoomFragment"
,
R
.
id
.
fragment_container
)
{
newInstance
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoom
Open
)
newInstance
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoom
ReadOnly
)
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
bebb5a92
...
...
@@ -21,13 +21,13 @@ import kotlinx.android.synthetic.main.fragment_chat_room.*
import
kotlinx.android.synthetic.main.message_composer.*
import
javax.inject.Inject
fun
newInstance
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoom
Open
:
Boolean
):
Fragment
{
fun
newInstance
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoom
ReadOnly
:
Boolean
):
Fragment
{
return
ChatRoomFragment
().
apply
{
arguments
=
Bundle
(
1
).
apply
{
putString
(
BUNDLE_CHAT_ROOM_ID
,
chatRoomId
)
putString
(
BUNDLE_CHAT_ROOM_NAME
,
chatRoomName
)
putString
(
BUNDLE_CHAT_ROOM_TYPE
,
chatRoomType
)
putBoolean
(
BUNDLE_IS_CHAT_ROOM_
OPEN
,
isChatRoomOpen
)
putBoolean
(
BUNDLE_IS_CHAT_ROOM_
READ_ONLY
,
isChatRoomReadOnly
)
}
}
}
...
...
@@ -35,14 +35,14 @@ fun newInstance(chatRoomId: String, chatRoomName: String, chatRoomType: String,
private
const
val
BUNDLE_CHAT_ROOM_ID
=
"chat_room_id"
private
const
val
BUNDLE_CHAT_ROOM_NAME
=
"chat_room_name"
private
const
val
BUNDLE_CHAT_ROOM_TYPE
=
"chat_room_type"
private
const
val
BUNDLE_IS_CHAT_ROOM_
OPEN
=
"is_chat_room_open
"
private
const
val
BUNDLE_IS_CHAT_ROOM_
READ_ONLY
=
"is_chat_room_read_only
"
class
ChatRoomFragment
:
Fragment
(),
ChatRoomView
{
@Inject
lateinit
var
presenter
:
ChatRoomPresenter
private
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomName
:
String
private
lateinit
var
chatRoomType
:
String
private
var
isChatRoom
Open
:
Boolean
=
tru
e
private
var
isChatRoom
ReadOnly
:
Boolean
=
fals
e
private
lateinit
var
adapter
:
ChatRoomAdapter
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
...
...
@@ -54,7 +54,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
chatRoomId
=
bundle
.
getString
(
BUNDLE_CHAT_ROOM_ID
)
chatRoomName
=
bundle
.
getString
(
BUNDLE_CHAT_ROOM_NAME
)
chatRoomType
=
bundle
.
getString
(
BUNDLE_CHAT_ROOM_TYPE
)
isChatRoom
Open
=
bundle
.
getBoolean
(
BUNDLE_IS_CHAT_ROOM_OPEN
)
isChatRoom
ReadOnly
=
bundle
.
getBoolean
(
BUNDLE_IS_CHAT_ROOM_READ_ONLY
)
}
else
{
requireNotNull
(
bundle
)
{
"no arguments supplied when the fragment was instantiated"
}
}
...
...
@@ -109,11 +109,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
private
fun
setupComposer
()
{
if
(
isChatRoomOpen
)
{
text_send
.
setOnClickListener
{
sendMessage
(
text_message
.
textContent
)
}
}
else
{
if
(
isChatRoomReadOnly
)
{
text_room_is_read_only
.
setVisibility
(
true
)
top_container
.
setVisibility
(
false
)
}
else
{
text_send
.
setOnClickListener
{
sendMessage
(
text_message
.
textContent
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsNavigator.kt
View file @
bebb5a92
...
...
@@ -7,8 +7,8 @@ import chat.rocket.android.chatrooms.ui.MainActivity
class
ChatRoomsNavigator
(
private
val
activity
:
MainActivity
,
private
val
context
:
Context
)
{
fun
toChatRoom
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoom
Open
:
Boolean
)
{
activity
.
startActivity
(
context
.
chatRoomIntent
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoom
Open
))
fun
toChatRoom
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoom
ReadOnly
:
Boolean
)
{
activity
.
startActivity
(
context
.
chatRoomIntent
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoom
ReadOnly
))
activity
.
overridePendingTransition
(
R
.
anim
.
open_enter
,
R
.
anim
.
open_exit
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
bebb5a92
...
...
@@ -4,7 +4,6 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.launchUI
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.chatRooms
import
chat.rocket.core.model.ChatRoom
import
javax.inject.Inject
...
...
@@ -33,7 +32,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
}
fun
loadChatRoom
(
chatRoom
:
ChatRoom
)
{
navigator
.
toChatRoom
(
chatRoom
.
id
,
chatRoom
.
name
,
chatRoom
.
type
.
name
,
chatRoom
.
open
)
navigator
.
toChatRoom
(
chatRoom
.
id
,
chatRoom
.
name
,
chatRoom
.
type
.
name
,
chatRoom
.
readonly
?:
false
)
}
private
fun
getOpenChatRooms
(
chatRooms
:
List
<
ChatRoom
>):
List
<
ChatRoom
>
{
...
...
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