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
107a4c86
Commit
107a4c86
authored
Feb 26, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use fullName for chatrooms if is Direct Message and settings.useRealName()
parent
c55f68fc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
29 deletions
+52
-29
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+16
-6
ChatRoomsAdapter.kt
...java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
+8
-1
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+7
-1
SettingsRepository.kt
...a/chat/rocket/android/server/domain/SettingsRepository.kt
+18
-18
SharedPreferencesSettingsRepository.kt
...er/infraestructure/SharedPreferencesSettingsRepository.kt
+3
-3
No files found.
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
107a4c86
package
chat.rocket.android.chatrooms.presentation
package
chat.rocket.android.chatrooms.presentation
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetChatRoomsInteractor
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.RefreshSettingsInteractor
import
chat.rocket.android.server.domain.SaveChatRoomsInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.RoomType
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.model.Subscription
import
chat.rocket.core.internal.model.Subscription
import
chat.rocket.core.internal.realtime.*
import
chat.rocket.core.internal.realtime.*
...
@@ -26,10 +24,12 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
...
@@ -26,10 +24,12 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
private
val
getChatRoomsInteractor
:
GetChatRoomsInteractor
,
private
val
getChatRoomsInteractor
:
GetChatRoomsInteractor
,
private
val
saveChatRoomsInteractor
:
SaveChatRoomsInteractor
,
private
val
saveChatRoomsInteractor
:
SaveChatRoomsInteractor
,
private
val
refreshSettingsInteractor
:
RefreshSettingsInteractor
,
private
val
refreshSettingsInteractor
:
RefreshSettingsInteractor
,
settingsRepository
:
SettingsRepository
,
factory
:
RocketChatClientFactory
)
{
factory
:
RocketChatClientFactory
)
{
private
val
client
:
RocketChatClient
=
factory
.
create
(
serverInteractor
.
get
()
!!
)
private
val
client
:
RocketChatClient
=
factory
.
create
(
serverInteractor
.
get
()
!!
)
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
var
reloadJob
:
Deferred
<
List
<
ChatRoom
>>?
=
null
private
var
reloadJob
:
Deferred
<
List
<
ChatRoom
>>?
=
null
private
val
settings
=
settingsRepository
.
get
(
currentServer
)
!!
private
val
stateChannel
=
Channel
<
State
>()
private
val
stateChannel
=
Channel
<
State
>()
...
@@ -49,8 +49,18 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
...
@@ -49,8 +49,18 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
}
}
}
}
fun
loadChatRoom
(
chatRoom
:
ChatRoom
)
=
navigator
.
toChatRoom
(
chatRoom
.
id
,
chatRoom
.
name
,
fun
loadChatRoom
(
chatRoom
:
ChatRoom
)
{
chatRoom
.
type
.
toString
(),
chatRoom
.
readonly
?:
false
)
val
roomName
=
if
(
chatRoom
.
type
is
RoomType
.
DirectMessage
&&
chatRoom
.
fullName
!=
null
&&
settings
.
useRealName
())
{
chatRoom
.
fullName
!!
}
else
{
chatRoom
.
name
}
navigator
.
toChatRoom
(
chatRoom
.
id
,
roomName
,
chatRoom
.
type
.
toString
(),
chatRoom
.
readonly
?:
false
)
}
/**
/**
* Gets a [ChatRoom] list from local repository.
* Gets a [ChatRoom] list from local repository.
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
View file @
107a4c86
...
@@ -9,6 +9,8 @@ import android.view.ViewGroup
...
@@ -9,6 +9,8 @@ import android.view.ViewGroup
import
android.widget.TextView
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.helper.UrlHelper
import
chat.rocket.android.helper.UrlHelper
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.setVisible
...
@@ -21,6 +23,7 @@ import kotlinx.android.synthetic.main.item_chat.view.*
...
@@ -21,6 +23,7 @@ import kotlinx.android.synthetic.main.item_chat.view.*
import
kotlinx.android.synthetic.main.unread_messages_badge.view.*
import
kotlinx.android.synthetic.main.unread_messages_badge.view.*
class
ChatRoomsAdapter
(
private
val
context
:
Context
,
class
ChatRoomsAdapter
(
private
val
context
:
Context
,
private
val
settings
:
PublicSettings
,
private
val
listener
:
(
ChatRoom
)
->
Unit
)
:
RecyclerView
.
Adapter
<
ChatRoomsAdapter
.
ViewHolder
>()
{
private
val
listener
:
(
ChatRoom
)
->
Unit
)
:
RecyclerView
.
Adapter
<
ChatRoomsAdapter
.
ViewHolder
>()
{
var
dataSet
:
MutableList
<
ChatRoom
>
=
ArrayList
()
var
dataSet
:
MutableList
<
ChatRoom
>
=
ArrayList
()
...
@@ -69,7 +72,11 @@ class ChatRoomsAdapter(private val context: Context,
...
@@ -69,7 +72,11 @@ class ChatRoomsAdapter(private val context: Context,
}
}
private
fun
bindName
(
chatRoom
:
ChatRoom
,
textView
:
TextView
)
{
private
fun
bindName
(
chatRoom
:
ChatRoom
,
textView
:
TextView
)
{
textView
.
content
=
chatRoom
.
name
if
(
chatRoom
.
type
is
RoomType
.
DirectMessage
&&
settings
.
useRealName
())
{
textView
.
content
=
chatRoom
.
fullName
?:
chatRoom
.
name
}
else
{
textView
.
content
=
chatRoom
.
name
}
}
}
private
fun
bindLastMessageDateTime
(
chatRoom
:
ChatRoom
,
textView
:
TextView
)
{
private
fun
bindLastMessageDateTime
(
chatRoom
:
ChatRoom
,
textView
:
TextView
)
{
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
107a4c86
...
@@ -11,6 +11,8 @@ import android.view.*
...
@@ -11,6 +11,8 @@ import android.view.*
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter
import
chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter
import
chat.rocket.android.chatrooms.presentation.ChatRoomsView
import
chat.rocket.android.chatrooms.presentation.ChatRoomsView
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.showToast
...
@@ -26,6 +28,8 @@ import javax.inject.Inject
...
@@ -26,6 +28,8 @@ import javax.inject.Inject
class
ChatRoomsFragment
:
Fragment
(),
ChatRoomsView
{
class
ChatRoomsFragment
:
Fragment
(),
ChatRoomsView
{
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
@Inject
lateinit
var
serverInteractor
:
GetCurrentServerInteractor
@Inject
lateinit
var
settingsRepository
:
SettingsRepository
private
var
searchView
:
SearchView
?
=
null
private
var
searchView
:
SearchView
?
=
null
companion
object
{
companion
object
{
...
@@ -107,7 +111,9 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
...
@@ -107,7 +111,9 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_start
),
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_end
)))
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
recycler_view
.
adapter
=
ChatRoomsAdapter
(
this
)
{
chatRoom
->
// TODO - use a ViewModel Mapper instead of using settings on the adapter
recycler_view
.
adapter
=
ChatRoomsAdapter
(
this
,
settingsRepository
.
get
(
serverInteractor
.
get
()
!!
)
!!
)
{
chatRoom
->
presenter
.
loadChatRoom
(
chatRoom
)
presenter
.
loadChatRoom
(
chatRoom
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/server/domain/SettingsRepository.kt
View file @
107a4c86
...
@@ -48,30 +48,30 @@ const val ALLOW_MESSAGE_PINNING = "Message_AllowPinning"
...
@@ -48,30 +48,30 @@ const val ALLOW_MESSAGE_PINNING = "Message_AllowPinning"
* If you need to access a Setting, add a const val key above, add it to the filter on
* If you need to access a Setting, add a const val key above, add it to the filter on
* ServerPresenter.kt and a extension function to access it
* ServerPresenter.kt and a extension function to access it
*/
*/
fun
Map
<
String
,
Value
<
Any
>>
.
googleEnabled
():
Boolean
=
this
[
ACCOUNT_GOOGLE
]
?.
value
==
true
fun
PublicSettings
.
googleEnabled
():
Boolean
=
this
[
ACCOUNT_GOOGLE
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
facebookEnabled
():
Boolean
=
this
[
ACCOUNT_FACEBOOK
]
?.
value
==
true
fun
PublicSettings
.
facebookEnabled
():
Boolean
=
this
[
ACCOUNT_FACEBOOK
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
githubEnabled
():
Boolean
=
this
[
ACCOUNT_GITHUB
]
?.
value
==
true
fun
PublicSettings
.
githubEnabled
():
Boolean
=
this
[
ACCOUNT_GITHUB
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
linkedinEnabled
():
Boolean
=
this
[
ACCOUNT_LINKEDIN
]
?.
value
==
true
fun
PublicSettings
.
linkedinEnabled
():
Boolean
=
this
[
ACCOUNT_LINKEDIN
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
meteorEnabled
():
Boolean
=
this
[
ACCOUNT_METEOR
]
?.
value
==
true
fun
PublicSettings
.
meteorEnabled
():
Boolean
=
this
[
ACCOUNT_METEOR
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
twitterEnabled
():
Boolean
=
this
[
ACCOUNT_TWITTER
]
?.
value
==
true
fun
PublicSettings
.
twitterEnabled
():
Boolean
=
this
[
ACCOUNT_TWITTER
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
gitlabEnabled
():
Boolean
=
this
[
ACCOUNT_GITLAB
]
?.
value
==
true
fun
PublicSettings
.
gitlabEnabled
():
Boolean
=
this
[
ACCOUNT_GITLAB
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
wordpressEnabled
():
Boolean
=
this
[
ACCOUNT_WORDPRESS
]
?.
value
==
true
fun
PublicSettings
.
wordpressEnabled
():
Boolean
=
this
[
ACCOUNT_WORDPRESS
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
useRealName
():
Boolean
=
this
[
USE_REALNAME
]
?.
value
==
true
fun
PublicSettings
.
useRealName
():
Boolean
=
this
[
USE_REALNAME
]
?.
value
==
true
// Message settings
// Message settings
fun
Map
<
String
,
Value
<
Any
>>
.
showDeletedStatus
():
Boolean
=
this
[
SHOW_DELETED_STATUS
]
?.
value
==
true
fun
PublicSettings
.
showDeletedStatus
():
Boolean
=
this
[
SHOW_DELETED_STATUS
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
showEditedStatus
():
Boolean
=
this
[
SHOW_EDITED_STATUS
]
?.
value
==
true
fun
PublicSettings
.
showEditedStatus
():
Boolean
=
this
[
SHOW_EDITED_STATUS
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
allowedMessagePinning
():
Boolean
=
this
[
ALLOW_MESSAGE_PINNING
]
?.
value
==
true
fun
PublicSettings
.
allowedMessagePinning
():
Boolean
=
this
[
ALLOW_MESSAGE_PINNING
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
allowedMessageEditing
():
Boolean
=
this
[
ALLOW_MESSAGE_EDITING
]
?.
value
==
true
fun
PublicSettings
.
allowedMessageEditing
():
Boolean
=
this
[
ALLOW_MESSAGE_EDITING
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
allowedMessageDeleting
():
Boolean
=
this
[
ALLOW_MESSAGE_DELETING
]
?.
value
==
true
fun
PublicSettings
.
allowedMessageDeleting
():
Boolean
=
this
[
ALLOW_MESSAGE_DELETING
]
?.
value
==
true
fun
Map
<
String
,
Value
<
Any
>>
.
registrationEnabled
():
Boolean
{
fun
PublicSettings
.
registrationEnabled
():
Boolean
{
val
value
=
this
[
ACCOUNT_REGISTRATION
]
val
value
=
this
[
ACCOUNT_REGISTRATION
]
return
value
?.
value
==
"Public"
return
value
?.
value
==
"Public"
}
}
fun
Map
<
String
,
Value
<
Any
>>
.
uploadMimeTypeFilter
():
Array
<
String
>
{
fun
PublicSettings
.
uploadMimeTypeFilter
():
Array
<
String
>
{
val
values
=
this
[
UPLOAD_WHITELIST_MIMETYPES
]
?.
value
val
values
=
this
[
UPLOAD_WHITELIST_MIMETYPES
]
?.
value
values
?.
let
{
it
as
String
}
?.
split
(
","
)
?.
let
{
values
?.
let
{
it
as
String
}
?.
split
(
","
)
?.
let
{
return
it
.
mapToTypedArray
{
it
.
trim
()
}
return
it
.
mapToTypedArray
{
it
.
trim
()
}
...
@@ -80,8 +80,8 @@ fun Map<String, Value<Any>>.uploadMimeTypeFilter(): Array<String> {
...
@@ -80,8 +80,8 @@ fun Map<String, Value<Any>>.uploadMimeTypeFilter(): Array<String> {
return
arrayOf
(
"*/*"
)
return
arrayOf
(
"*/*"
)
}
}
fun
Map
<
String
,
Value
<
Any
>>
.
uploadMaxFileSize
():
Int
{
fun
PublicSettings
.
uploadMaxFileSize
():
Int
{
return
this
[
UPLOAD_MAX_FILE_SIZE
]
?.
value
?.
let
{
it
as
Int
}
?:
Int
.
MAX_VALUE
return
this
[
UPLOAD_MAX_FILE_SIZE
]
?.
value
?.
let
{
it
as
Int
}
?:
Int
.
MAX_VALUE
}
}
fun
Map
<
String
,
Value
<
Any
>>.
baseUrl
()
:
String
?
=
this
[
SITE_URL
]
?.
value
as
String
fun
PublicSettings
.
baseUrl
():
String
?
=
this
[
SITE_URL
]
?.
value
as
String
\ No newline at end of file
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/infraestructure/SharedPreferencesSettingsRepository.kt
View file @
107a4c86
...
@@ -2,19 +2,19 @@ package chat.rocket.android.server.infraestructure
...
@@ -2,19 +2,19 @@ package chat.rocket.android.server.infraestructure
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.LocalRepository.Companion.SETTINGS_KEY
import
chat.rocket.android.infrastructure.LocalRepository.Companion.SETTINGS_KEY
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.core.internal.SettingsAdapter
import
chat.rocket.core.internal.SettingsAdapter
import
chat.rocket.core.model.Value
class
SharedPreferencesSettingsRepository
(
private
val
localRepository
:
LocalRepository
)
:
SettingsRepository
{
class
SharedPreferencesSettingsRepository
(
private
val
localRepository
:
LocalRepository
)
:
SettingsRepository
{
private
val
adapter
=
SettingsAdapter
().
lenient
()
private
val
adapter
=
SettingsAdapter
().
lenient
()
override
fun
save
(
url
:
String
,
settings
:
Map
<
String
,
Value
<
Any
>>
)
{
override
fun
save
(
url
:
String
,
settings
:
PublicSettings
)
{
localRepository
.
save
(
"$SETTINGS_KEY$url"
,
adapter
.
toJson
(
settings
))
localRepository
.
save
(
"$SETTINGS_KEY$url"
,
adapter
.
toJson
(
settings
))
}
}
override
fun
get
(
url
:
String
):
Map
<
String
,
Value
<
Any
>>
?
{
override
fun
get
(
url
:
String
):
PublicSettings
?
{
val
settings
=
localRepository
.
get
(
"$SETTINGS_KEY$url"
)
val
settings
=
localRepository
.
get
(
"$SETTINGS_KEY$url"
)
settings
?.
let
{
settings
?.
let
{
return
adapter
.
fromJson
(
it
)
return
adapter
.
fromJson
(
it
)
...
...
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