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
f0b85b9f
Commit
f0b85b9f
authored
May 02, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save permissions when loading chatrooms
parent
385c30bd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
20 deletions
+32
-20
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+2
-1
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+3
-0
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+19
-17
PermissionsInteractor.kt
...hat/rocket/android/server/domain/PermissionsInteractor.kt
+7
-1
PermissionsRepository.kt
...hat/rocket/android/server/domain/PermissionsRepository.kt
+1
-1
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
f0b85b9f
...
...
@@ -48,7 +48,7 @@ class ChatRoomPresenter @Inject constructor(
getSettingsInteractor
:
GetSettingsInteractor
,
serverInteractor
:
GetCurrentServerInteractor
,
private
val
getChatRoomsInteractor
:
GetChatRoomsInteractor
,
private
val
permissions
:
Get
PermissionsInteractor
,
private
val
permissions
:
PermissionsInteractor
,
private
val
uriInteractor
:
UriInteractor
,
private
val
messagesRepository
:
MessagesRepository
,
private
val
usersRepository
:
UsersRepository
,
...
...
@@ -73,6 +73,7 @@ class ChatRoomPresenter @Inject constructor(
fun
loadMessages
(
chatRoomId
:
String
,
chatRoomType
:
String
,
offset
:
Long
=
0
)
{
this
.
chatRoomId
=
chatRoomId
this
.
chatRoomType
=
chatRoomType
println
(
permissions
.
canPostToReadOnlyChannels
())
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
f0b85b9f
...
...
@@ -23,6 +23,7 @@ import chat.rocket.core.internal.model.Subscription
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.internal.realtime.socket.model.StreamMessage
import
chat.rocket.core.internal.realtime.socket.model.Type
import
chat.rocket.core.internal.rest.permissions
import
chat.rocket.core.internal.rest.spotlight
import
chat.rocket.core.model.ChatRoom
import
chat.rocket.core.model.Room
...
...
@@ -45,6 +46,7 @@ class ChatRoomsPresenter @Inject constructor(
private
val
refreshSettingsInteractor
:
RefreshSettingsInteractor
,
private
val
viewModelMapper
:
ViewModelMapper
,
private
val
jobSchedulerInteractor
:
JobSchedulerInteractor
,
private
val
permissionsInteractor
:
PermissionsInteractor
,
settingsRepository
:
SettingsRepository
,
factory
:
ConnectionManagerFactory
)
{
...
...
@@ -64,6 +66,7 @@ class ChatRoomsPresenter @Inject constructor(
view
.
showLoading
()
subscribeStatusChange
()
try
{
permissionsInteractor
.
saveAll
(
client
.
permissions
())
// If we still don't have 'Store_Last_Message' setting, refresh the settings
if
(!
settings
.
hasShowLastMessage
())
{
refreshSettingsInteractor
.
refresh
(
currentServer
)
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
f0b85b9f
...
...
@@ -23,7 +23,6 @@ import chat.rocket.android.helper.SharedPreferenceHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.showLastMessage
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.widget.DividerItemDecoration
import
chat.rocket.common.model.RoomType
...
...
@@ -37,10 +36,14 @@ import timber.log.Timber
import
javax.inject.Inject
class
ChatRoomsFragment
:
Fragment
(),
ChatRoomsView
{
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
@Inject
lateinit
var
serverInteractor
:
GetCurrentServerInteractor
@Inject
lateinit
var
settingsRepository
:
SettingsRepository
@Inject
lateinit
var
localRepository
:
LocalRepository
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
@Inject
lateinit
var
serverInteractor
:
GetCurrentServerInteractor
@Inject
lateinit
var
settingsRepository
:
SettingsRepository
@Inject
lateinit
var
localRepository
:
LocalRepository
private
lateinit
var
preferences
:
SharedPreferences
private
var
searchView
:
SearchView
?
=
null
private
val
handler
=
Handler
()
...
...
@@ -136,9 +139,9 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
})
val
dialogSort
=
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
dialog_sort_title
)
.
setView
(
dialogLayout
)
.
setPositiveButton
(
"Done"
,
{
dialog
,
_
->
dialog
.
dismiss
()
})
.
setTitle
(
R
.
string
.
dialog_sort_title
)
.
setView
(
dialogLayout
)
.
setPositiveButton
(
"Done"
,
{
dialog
,
_
->
dialog
.
dismiss
()
})
dialogSort
.
show
()
}
...
...
@@ -146,9 +149,9 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
return
super
.
onOptionsItemSelected
(
item
)
}
private
fun
invalidateQueryOnSearch
(){
private
fun
invalidateQueryOnSearch
()
{
searchView
?.
let
{
if
(!
searchView
!!
.
isIconified
){
if
(!
searchView
!!
.
isIconified
)
{
queryChatRoomsByName
(
searchView
!!
.
query
.
toString
())
}
}
...
...
@@ -179,7 +182,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
ui
{
text_no_data_to_display
.
setVisible
(
true
)
}
}
override
fun
showLoading
(){
override
fun
showLoading
()
{
ui
{
view_loading
.
setVisible
(
true
)
}
}
...
...
@@ -236,19 +239,18 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
ui
{
recycler_view
.
layoutManager
=
LinearLayoutManager
(
it
,
LinearLayoutManager
.
VERTICAL
,
false
)
recycler_view
.
addItemDecoration
(
DividerItemDecoration
(
it
,
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_start
),
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_end
)))
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_start
),
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_end
)))
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
// TODO - use a ViewModel Mapper instead of using settings on the adapter
println
(
serverInteractor
.
get
()
+
" -> ${settingsRepository.get(serverInteractor.get()!!).showLastMessage()}"
)
val
baseAdapter
=
ChatRoomsAdapter
(
it
,
settingsRepository
.
get
(
serverInteractor
.
get
()
!!
),
localRepository
)
{
chatRoom
->
presenter
.
loadChatRoom
(
chatRoom
)
settingsRepository
.
get
(
serverInteractor
.
get
()
!!
),
localRepository
)
{
chatRoom
->
presenter
.
loadChatRoom
(
chatRoom
)
}
sectionedAdapter
=
SimpleSectionedRecyclerViewAdapter
(
it
,
R
.
layout
.
item_chatroom_header
,
R
.
id
.
text_chatroom_header
,
baseAdapter
)
R
.
layout
.
item_chatroom_header
,
R
.
id
.
text_chatroom_header
,
baseAdapter
)
recycler_view
.
adapter
=
sectionedAdapter
}
}
...
...
app/src/main/java/chat/rocket/android/server/domain/
Get
PermissionsInteractor.kt
→
app/src/main/java/chat/rocket/android/server/domain/PermissionsInteractor.kt
View file @
f0b85b9f
package
chat.rocket.android.server.domain
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.core.model.Permission
import
javax.inject.Inject
// Creating rooms
...
...
@@ -15,7 +16,7 @@ const val EDIT_MESSAGE = "edit-message"
const
val
PIN_MESSAGE
=
"pin-message"
const
val
POST_READONLY
=
"post-readonly"
class
Get
PermissionsInteractor
@Inject
constructor
(
class
PermissionsInteractor
@Inject
constructor
(
private
val
settingsRepository
:
SettingsRepository
,
private
val
permissionsRepository
:
PermissionsRepository
,
private
val
localRepository
:
LocalRepository
,
...
...
@@ -24,6 +25,11 @@ class GetPermissionsInteractor @Inject constructor(
private
fun
publicSettings
():
PublicSettings
?
=
settingsRepository
.
get
(
getCurrentServerUrl
()
!!
)
fun
saveAll
(
permissions
:
List
<
Permission
>)
{
val
url
=
getCurrentServerUrl
()
!!
permissions
.
forEach
{
permissionsRepository
.
save
(
url
,
it
)
}
}
/**
* Check whether user is allowed to delete a message.
*/
...
...
app/src/main/java/chat/rocket/android/server/domain/PermissionsRepository.kt
View file @
f0b85b9f
...
...
@@ -18,7 +18,7 @@ interface PermissionsRepository {
* @param url The server url from where we're interested on getting the permissions.
* @param permissionId the id of the permission to get.
*
* @return The interested
permission
or null if not found.
* @return The interested
[Permission]
or null if not found.
*/
fun
get
(
url
:
String
,
permissionId
:
String
):
Permission
?
}
\ 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