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
b404ba00
Unverified
Commit
b404ba00
authored
Aug 14, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Aug 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1582 from RocketChat/new/permission-list
[NEW] Permission list
parents
e329ca22
4cdc71dd
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
16 deletions
+52
-16
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+3
-0
PermissionsRepository.kt
...hat/rocket/android/server/domain/PermissionsRepository.kt
+3
-3
RefreshPermissionsInteractor.kt
...ket/android/server/domain/RefreshPermissionsInteractor.kt
+38
-0
RefreshSettingsInteractor.kt
...rocket/android/server/domain/RefreshSettingsInteractor.kt
+3
-0
SaveSettingsInteractor.kt
...at/rocket/android/server/domain/SaveSettingsInteractor.kt
+0
-9
SharedPreferencesPermissionsRepository.kt
...infraestructure/SharedPreferencesPermissionsRepository.kt
+4
-3
build.gradle
build.gradle
+1
-1
No files found.
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
b404ba00
...
...
@@ -11,6 +11,7 @@ import chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.RefreshSettingsInteractor
import
chat.rocket.android.server.domain.RefreshPermissionsInteractor
import
chat.rocket.android.server.domain.RemoveAccountInteractor
import
chat.rocket.android.server.domain.SaveAccountInteractor
import
chat.rocket.android.server.domain.TokenRepository
...
...
@@ -46,6 +47,7 @@ class MainPresenter @Inject constructor(
private
val
tokenRepository
:
TokenRepository
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
refreshSettingsInteractor
:
RefreshSettingsInteractor
,
private
val
refreshPermissionsInteractor
:
RefreshPermissionsInteractor
,
private
val
localRepository
:
LocalRepository
,
private
val
navHeaderMapper
:
NavHeaderUiModelMapper
,
private
val
saveAccountInteractor
:
SaveAccountInteractor
,
...
...
@@ -157,6 +159,7 @@ class MainPresenter @Inject constructor(
fun
connect
()
{
refreshSettingsInteractor
.
refreshAsync
(
currentServer
)
refreshPermissionsInteractor
.
refreshAsync
(
currentServer
)
manager
.
connect
()
}
...
...
app/src/main/java/chat/rocket/android/server/domain/PermissionsRepository.kt
View file @
b404ba00
...
...
@@ -5,12 +5,12 @@ import chat.rocket.core.model.Permission
interface
PermissionsRepository
{
/**
* Stores
[p
ermission] locally.
* Stores
a list of [P
ermission] locally.
*
* @param url The server url to store the permission.
* @param permission
The permission
to store.
* @param permission
List The permission list
to store.
*/
fun
save
(
url
:
String
,
permission
:
Permission
)
fun
save
(
url
:
String
,
permission
List
:
List
<
Permission
>
)
/**
* Gets permission given by the [permissionId] and for the server [url].
...
...
app/src/main/java/chat/rocket/android/server/domain/RefreshPermissionsInteractor.kt
0 → 100644
View file @
b404ba00
package
chat.rocket.android.server.domain
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.retryIO
import
chat.rocket.core.internal.rest.permissions
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
javax.inject.Inject
/**
* This class reloads the current logged server permission whenever its used.
*/
class
RefreshPermissionsInteractor
@Inject
constructor
(
private
val
factory
:
RocketChatClientFactory
,
private
val
repository
:
PermissionsRepository
)
{
fun
refreshAsync
(
server
:
String
)
{
launch
(
CommonPool
)
{
try
{
factory
.
create
(
server
).
let
{
client
->
val
permissions
=
retryIO
(
description
=
"permissions"
,
times
=
5
,
maxDelay
=
5000
,
initialDelay
=
300
)
{
client
.
permissions
()
}
repository
.
save
(
server
,
permissions
)
}
}
catch
(
ex
:
Exception
)
{
Timber
.
e
(
ex
,
"Error refreshing permissions for: $server"
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/domain/RefreshSettingsInteractor.kt
View file @
b404ba00
...
...
@@ -9,6 +9,9 @@ import kotlinx.coroutines.experimental.withContext
import
timber.log.Timber
import
javax.inject.Inject
/**
* This class reloads the current logged server settings whenever needed.
*/
class
RefreshSettingsInteractor
@Inject
constructor
(
private
val
factory
:
RocketChatClientFactory
,
private
val
repository
:
SettingsRepository
...
...
app/src/main/java/chat/rocket/android/server/domain/SaveSettingsInteractor.kt
deleted
100644 → 0
View file @
e329ca22
package
chat.rocket.android.server.domain
import
chat.rocket.core.model.Value
import
javax.inject.Inject
class
SaveSettingsInteractor
@Inject
constructor
(
private
val
repository
:
SettingsRepository
)
{
fun
save
(
url
:
String
,
settings
:
Map
<
String
,
Value
<
Any
>>)
=
repository
.
save
(
url
,
settings
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/infraestructure/SharedPreferencesPermissionsRepository.kt
View file @
b404ba00
...
...
@@ -9,12 +9,13 @@ class SharedPreferencesPermissionsRepository(
private
val
localRepository
:
LocalRepository
,
moshi
:
Moshi
)
:
PermissionsRepository
{
private
val
adapter
=
moshi
.
adapter
(
Permission
::
class
.
java
)
override
fun
save
(
url
:
String
,
permission
:
Permission
)
{
override
fun
save
(
url
:
String
,
permissionList
:
List
<
Permission
>)
{
for
(
permission
in
permissionList
)
{
localRepository
.
save
(
getPermissionKey
(
url
,
permission
.
id
),
adapter
.
toJson
(
permission
))
}
}
override
fun
get
(
url
:
String
,
permissionId
:
String
):
Permission
?
{
return
localRepository
.
get
(
getPermissionKey
(
url
,
permissionId
))
?.
let
{
...
...
build.gradle
View file @
b404ba00
...
...
@@ -10,7 +10,7 @@ buildscript {
}
dependencies
{
classpath
'com.android.tools.build:gradle:3.3.0-alpha0
3
'
classpath
'com.android.tools.build:gradle:3.3.0-alpha0
5
'
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath
"org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}"
classpath
'com.google.gms:google-services:4.0.2'
...
...
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