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
2e15f4a7
Commit
2e15f4a7
authored
Dec 06, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a DM session if one do not alredy exists
parent
69a8dfe2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
50 deletions
+52
-50
MembersAdapter.kt
...ava/chat/rocket/android/members/adapter/MembersAdapter.kt
+1
-1
MembersNavigator.kt
...t/rocket/android/members/presentation/MembersNavigator.kt
+3
-5
MembersPresenter.kt
...t/rocket/android/members/presentation/MembersPresenter.kt
+2
-8
MemberUiModel.kt
...java/chat/rocket/android/members/uimodel/MemberUiModel.kt
+2
-1
MemberUiModelMapper.kt
...hat/rocket/android/members/uimodel/MemberUiModelMapper.kt
+5
-2
UserDetailsPresenter.kt
.../android/userdetails/presentation/UserDetailsPresenter.kt
+39
-33
No files found.
app/src/main/java/chat/rocket/android/members/adapter/MembersAdapter.kt
View file @
2e15f4a7
...
...
@@ -47,4 +47,4 @@ class MembersAdapter(private val listener: (MemberUiModel) -> Unit) :
setOnClickListener
{
listener
(
memberUiModel
)
}
}
}
}
\ No newline at end of file
}
app/src/main/java/chat/rocket/android/members/presentation/MembersNavigator.kt
View file @
2e15f4a7
package
chat.rocket.android.members.presentation
import
chat.rocket.android.chatdetails.ui.ChatDetailsActivity
import
chat.rocket.android.members.ui.TAG_MEMBER_BOTTOM_SHEET_FRAGMENT
import
chat.rocket.android.members.ui.newInstance
import
chat.rocket.android.userdetails.ui.userDetailsIntent
class
MembersNavigator
(
internal
val
activity
:
ChatDetailsActivity
)
{
fun
toMemberDetails
(
avatarUri
:
String
,
realName
:
String
,
username
:
String
,
email
:
String
,
utcOffset
:
String
)
{
fun
toMemberDetails
(
userId
:
String
)
{
activity
.
apply
{
newInstance
(
avatarUri
,
realName
,
username
,
email
,
utcOffset
)
.
show
(
supportFragmentManager
,
TAG_MEMBER_BOTTOM_SHEET_FRAGMENT
)
startActivity
(
this
.
userDetailsIntent
(
userId
,
""
))
}
}
}
app/src/main/java/chat/rocket/android/members/presentation/MembersPresenter.kt
View file @
2e15f4a7
...
...
@@ -59,12 +59,6 @@ class MembersPresenter @Inject constructor(
}
fun
toMemberDetails
(
memberUiModel
:
MemberUiModel
)
{
navigator
.
toMemberDetails
(
memberUiModel
.
avatarUri
.
toString
(),
memberUiModel
.
realName
.
toString
(),
"@${memberUiModel.username}"
,
memberUiModel
.
email
?:
""
,
memberUiModel
.
utcOffset
.
toString
()
)
navigator
.
toMemberDetails
(
memberUiModel
.
userId
)
}
}
\ No newline at end of file
}
app/src/main/java/chat/rocket/android/members/uimodel/MemberUiModel.kt
View file @
2e15f4a7
...
...
@@ -11,6 +11,7 @@ class MemberUiModel(
private
val
settings
:
Map
<
String
,
Value
<
Any
>>,
private
val
baseUrl
:
String
?
)
{
val
userId
:
String
=
member
.
id
val
avatarUri
:
String
?
val
displayName
:
String
val
realName
:
String
?
...
...
@@ -52,4 +53,4 @@ class MemberUiModel(
private
fun
getUserUtcOffset
():
Float
?
=
member
.
utcOffset
private
fun
getUserStatus
():
UserStatus
?
=
member
.
status
}
\ No newline at end of file
}
app/src/main/java/chat/rocket/android/members/uimodel/MemberUiModelMapper.kt
View file @
2e15f4a7
...
...
@@ -7,11 +7,14 @@ import chat.rocket.common.model.User
import
chat.rocket.core.model.Value
import
javax.inject.Inject
class
MemberUiModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
class
MemberUiModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
private
var
settings
:
Map
<
String
,
Value
<
Any
>>
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
private
val
baseUrl
=
settings
.
baseUrl
()
fun
mapToUiModelList
(
memberList
:
List
<
User
>):
List
<
MemberUiModel
>
{
return
memberList
.
map
{
MemberUiModel
(
it
,
settings
,
baseUrl
)
}
}
}
\ No newline at end of file
}
app/src/main/java/chat/rocket/android/userdetails/presentation/UserDetailsPresenter.kt
View file @
2e15f4a7
package
chat.rocket.android.userdetails.presentation
import
androidx.core.text.toSpannable
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.helper.UserHelper
...
...
@@ -10,8 +9,8 @@ import chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.SimpleUser
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.core.internal.rest.createDirectMessage
import
chat.rocket.core.internal.rest.spotlight
import
chat.rocket.core.model.ChatRoom
import
kotlinx.coroutines.experimental.CommonPool
...
...
@@ -30,7 +29,7 @@ class UserDetailsPresenter @Inject constructor(
private
var
currentServer
=
serverInteractor
.
get
()
!!
private
val
manager
=
factory
.
create
(
currentServer
)
private
val
client
=
manager
.
client
private
val
u
serId
=
userHelper
.
user
()
?.
id
private
val
currentU
serId
=
userHelper
.
user
()
?.
id
fun
loadUserDetails
(
userId
:
String
)
{
launchUI
(
strategy
)
{
...
...
@@ -49,38 +48,41 @@ class UserDetailsPresenter @Inject constructor(
client
.
spotlight
(
query
=
query
)
}
val
matchFromSpotlight
=
spotlightResult
.
users
.
firstOrNull
()
val
matchFromSpotlight
=
spotlightResult
.
users
.
firstOrNull
{
it
.
username
==
query
}
if
(
matchFromSpotlight
!=
null
)
{
with
(
matchFromSpotlight
)
{
ChatRoom
(
id
=
"$id$userId"
,
type
=
roomTypeOf
(
RoomType
.
DIRECT_MESSAGE
),
name
=
u
.
username
?:
u
.
name
.
orEmpty
(),
fullName
=
u
.
name
,
favorite
=
false
,
open
=
false
,
alert
=
false
,
status
=
status
,
client
=
client
,
broadcast
=
false
,
archived
=
false
,
default
=
false
,
description
=
null
,
groupMentions
=
null
,
userMentions
=
null
,
lastMessage
=
null
,
lastSeen
=
null
,
topic
=
null
,
announcement
=
null
,
roles
=
null
,
unread
=
0
,
readonly
=
false
,
muted
=
null
,
subscriptionId
=
""
,
timestamp
=
null
,
updatedAt
=
null
,
user
=
null
val
result
=
retryIO
(
"createDirectMessage(${matchFromSpotlight.id}"
)
{
client
.
createDirectMessage
(
username
=
matchFromSpotlight
.
id
)
}
with
(
matchFromSpotlight
)
{
ChatRoom
(
id
=
result
.
id
,
type
=
roomTypeOf
(
RoomType
.
DIRECT_MESSAGE
),
name
=
u
.
username
?:
u
.
name
.
orEmpty
(),
fullName
=
u
.
name
,
favorite
=
false
,
open
=
false
,
alert
=
false
,
status
=
status
,
client
=
client
,
broadcast
=
false
,
archived
=
false
,
default
=
false
,
description
=
null
,
groupMentions
=
null
,
userMentions
=
null
,
lastMessage
=
null
,
lastSeen
=
null
,
topic
=
null
,
announcement
=
null
,
roles
=
null
,
unread
=
0
,
readonly
=
false
,
muted
=
null
,
subscriptionId
=
""
,
timestamp
=
null
,
updatedAt
=
null
,
user
=
null
)
}
}
else
null
...
...
@@ -100,6 +102,10 @@ class UserDetailsPresenter @Inject constructor(
}
}
fun
createDirectMessage
(
username
:
String
)
{
}
private
suspend
fun
chatRoomByName
(
name
:
String
?
=
null
):
List
<
ChatRoom
>
=
withContext
(
CommonPool
)
{
return
@withContext
dbManager
.
chatRoomDao
().
getAllSync
().
filter
{
if
(
name
==
null
)
{
...
...
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