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
Show 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
app/src/main/java/chat/rocket/android/members/presentation/MembersNavigator.kt
View file @
2e15f4a7
package
chat.rocket.android.members.presentation
package
chat.rocket.android.members.presentation
import
chat.rocket.android.chatdetails.ui.ChatDetailsActivity
import
chat.rocket.android.chatdetails.ui.ChatDetailsActivity
import
chat.rocket.android.members.ui.TAG_MEMBER_BOTTOM_SHEET_FRAGMENT
import
chat.rocket.android.userdetails.ui.userDetailsIntent
import
chat.rocket.android.members.ui.newInstance
class
MembersNavigator
(
internal
val
activity
:
ChatDetailsActivity
)
{
class
MembersNavigator
(
internal
val
activity
:
ChatDetailsActivity
)
{
fun
toMemberDetails
(
avatarUri
:
String
,
realName
:
String
,
username
:
String
,
email
:
String
,
utcOffset
:
String
)
{
fun
toMemberDetails
(
userId
:
String
)
{
activity
.
apply
{
activity
.
apply
{
newInstance
(
avatarUri
,
realName
,
username
,
email
,
utcOffset
)
startActivity
(
this
.
userDetailsIntent
(
userId
,
""
))
.
show
(
supportFragmentManager
,
TAG_MEMBER_BOTTOM_SHEET_FRAGMENT
)
}
}
}
}
}
}
app/src/main/java/chat/rocket/android/members/presentation/MembersPresenter.kt
View file @
2e15f4a7
...
@@ -59,12 +59,6 @@ class MembersPresenter @Inject constructor(
...
@@ -59,12 +59,6 @@ class MembersPresenter @Inject constructor(
}
}
fun
toMemberDetails
(
memberUiModel
:
MemberUiModel
)
{
fun
toMemberDetails
(
memberUiModel
:
MemberUiModel
)
{
navigator
.
toMemberDetails
(
navigator
.
toMemberDetails
(
memberUiModel
.
userId
)
memberUiModel
.
avatarUri
.
toString
(),
memberUiModel
.
realName
.
toString
(),
"@${memberUiModel.username}"
,
memberUiModel
.
email
?:
""
,
memberUiModel
.
utcOffset
.
toString
()
)
}
}
}
}
app/src/main/java/chat/rocket/android/members/uimodel/MemberUiModel.kt
View file @
2e15f4a7
...
@@ -11,6 +11,7 @@ class MemberUiModel(
...
@@ -11,6 +11,7 @@ class MemberUiModel(
private
val
settings
:
Map
<
String
,
Value
<
Any
>>,
private
val
settings
:
Map
<
String
,
Value
<
Any
>>,
private
val
baseUrl
:
String
?
private
val
baseUrl
:
String
?
)
{
)
{
val
userId
:
String
=
member
.
id
val
avatarUri
:
String
?
val
avatarUri
:
String
?
val
displayName
:
String
val
displayName
:
String
val
realName
:
String
?
val
realName
:
String
?
...
...
app/src/main/java/chat/rocket/android/members/uimodel/MemberUiModelMapper.kt
View file @
2e15f4a7
...
@@ -7,7 +7,10 @@ import chat.rocket.common.model.User
...
@@ -7,7 +7,10 @@ import chat.rocket.common.model.User
import
chat.rocket.core.model.Value
import
chat.rocket.core.model.Value
import
javax.inject.Inject
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
var
settings
:
Map
<
String
,
Value
<
Any
>>
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
private
val
baseUrl
=
settings
.
baseUrl
()
private
val
baseUrl
=
settings
.
baseUrl
()
...
...
app/src/main/java/chat/rocket/android/userdetails/presentation/UserDetailsPresenter.kt
View file @
2e15f4a7
package
chat.rocket.android.userdetails.presentation
package
chat.rocket.android.userdetails.presentation
import
androidx.core.text.toSpannable
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.helper.UserHelper
import
chat.rocket.android.helper.UserHelper
...
@@ -10,8 +9,8 @@ import chat.rocket.android.util.extension.launchUI
...
@@ -10,8 +9,8 @@ import chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.retryIO
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.SimpleUser
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.core.internal.rest.createDirectMessage
import
chat.rocket.core.internal.rest.spotlight
import
chat.rocket.core.internal.rest.spotlight
import
chat.rocket.core.model.ChatRoom
import
chat.rocket.core.model.ChatRoom
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.CommonPool
...
@@ -30,7 +29,7 @@ class UserDetailsPresenter @Inject constructor(
...
@@ -30,7 +29,7 @@ class UserDetailsPresenter @Inject constructor(
private
var
currentServer
=
serverInteractor
.
get
()
!!
private
var
currentServer
=
serverInteractor
.
get
()
!!
private
val
manager
=
factory
.
create
(
currentServer
)
private
val
manager
=
factory
.
create
(
currentServer
)
private
val
client
=
manager
.
client
private
val
client
=
manager
.
client
private
val
u
serId
=
userHelper
.
user
()
?.
id
private
val
currentU
serId
=
userHelper
.
user
()
?.
id
fun
loadUserDetails
(
userId
:
String
)
{
fun
loadUserDetails
(
userId
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
...
@@ -49,12 +48,15 @@ class UserDetailsPresenter @Inject constructor(
...
@@ -49,12 +48,15 @@ class UserDetailsPresenter @Inject constructor(
client
.
spotlight
(
query
=
query
)
client
.
spotlight
(
query
=
query
)
}
}
val
matchFromSpotlight
=
spotlightResult
.
users
.
firstOrNull
()
val
matchFromSpotlight
=
spotlightResult
.
users
.
firstOrNull
{
it
.
username
==
query
}
if
(
matchFromSpotlight
!=
null
)
{
if
(
matchFromSpotlight
!=
null
)
{
with
(
matchFromSpotlight
)
{
val
result
=
retryIO
(
"createDirectMessage(${matchFromSpotlight.id}"
)
{
client
.
createDirectMessage
(
username
=
matchFromSpotlight
.
id
)
}
with
(
matchFromSpotlight
)
{
ChatRoom
(
ChatRoom
(
id
=
"$id$userId"
,
id
=
result
.
id
,
type
=
roomTypeOf
(
RoomType
.
DIRECT_MESSAGE
),
type
=
roomTypeOf
(
RoomType
.
DIRECT_MESSAGE
),
name
=
u
.
username
?:
u
.
name
.
orEmpty
(),
name
=
u
.
username
?:
u
.
name
.
orEmpty
(),
fullName
=
u
.
name
,
fullName
=
u
.
name
,
...
@@ -100,6 +102,10 @@ class UserDetailsPresenter @Inject constructor(
...
@@ -100,6 +102,10 @@ class UserDetailsPresenter @Inject constructor(
}
}
}
}
fun
createDirectMessage
(
username
:
String
)
{
}
private
suspend
fun
chatRoomByName
(
name
:
String
?
=
null
):
List
<
ChatRoom
>
=
withContext
(
CommonPool
)
{
private
suspend
fun
chatRoomByName
(
name
:
String
?
=
null
):
List
<
ChatRoom
>
=
withContext
(
CommonPool
)
{
return
@withContext
dbManager
.
chatRoomDao
().
getAllSync
().
filter
{
return
@withContext
dbManager
.
chatRoomDao
().
getAllSync
().
filter
{
if
(
name
==
null
)
{
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