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
299e823c
Unverified
Commit
299e823c
authored
Apr 06, 2018
by
Rafael Kellermann Streit
Committed by
GitHub
Apr 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop-2.x' into chore/increment_build_beta4
parents
12696d20
3e3b5726
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
31 deletions
+50
-31
DrawableHelper.kt
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
+12
-10
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+8
-3
MainView.kt
...in/java/chat/rocket/android/main/presentation/MainView.kt
+2
-2
MainActivity.kt
...src/main/java/chat/rocket/android/main/ui/MainActivity.kt
+12
-6
NavHeaderViewModel.kt
.../chat/rocket/android/main/viewmodel/NavHeaderViewModel.kt
+7
-3
NavHeaderViewModelMapper.kt
...rocket/android/main/viewmodel/NavHeaderViewModelMapper.kt
+9
-6
nav_header.xml
app/src/main/res/layout/nav_header.xml
+0
-1
No files found.
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
View file @
299e823c
...
...
@@ -106,19 +106,21 @@ object DrawableHelper {
* @return The user status drawable.
*/
fun
getUserStatusDrawable
(
userStatus
:
UserStatus
,
context
:
Context
):
Drawable
{
val
userStatusDrawable
=
getDrawableFromId
(
R
.
drawable
.
ic_user_status_black
,
context
).
mutate
()
wrapDrawable
(
userStatusDrawable
)
when
(
userStatus
)
{
is
UserStatus
.
Online
->
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusOnline
)
is
UserStatus
.
Busy
->
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusBusy
)
is
UserStatus
.
Away
->
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusAway
)
is
UserStatus
.
Offline
->
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusOffline
)
else
->
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusOffline
)
return
when
(
userStatus
)
{
is
UserStatus
.
Online
->
{
getDrawableFromId
(
R
.
drawable
.
ic_status_online_24dp
,
context
)
}
is
UserStatus
.
Away
->
{
getDrawableFromId
(
R
.
drawable
.
ic_status_away_24dp
,
context
)
}
is
UserStatus
.
Busy
->
{
getDrawableFromId
(
R
.
drawable
.
ic_status_busy_24dp
,
context
)
}
else
->
getDrawableFromId
(
R
.
drawable
.
ic_status_invisible_24dp
,
context
)
}
return
userStatusDrawable
}
// TODO Why we need to UserStatus?
// TODO Why we need t
w
o UserStatus?
/**
* Returns the user status drawable.
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
299e823c
...
...
@@ -57,7 +57,6 @@ class MainPresenter @Inject constructor(
try
{
val
me
=
retryIO
(
"me"
)
{
client
.
me
()
}
val
model
=
navHeaderMapper
.
mapToViewModel
(
me
)
saveAccount
(
model
)
view
.
setupNavHeader
(
model
,
getAccountsInteractor
.
get
())
}
catch
(
ex
:
Exception
)
{
...
...
@@ -78,11 +77,17 @@ class MainPresenter @Inject constructor(
}
}
private
suspend
fun
saveAccount
(
me
:
NavHeaderViewModel
)
{
private
suspend
fun
saveAccount
(
viewModel
:
NavHeaderViewModel
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
val
account
=
Account
(
currentServer
,
icon
,
me
.
serverLogo
,
me
.
username
,
me
.
avatar
)
val
account
=
Account
(
currentServer
,
icon
,
viewModel
.
serverLogo
,
viewModel
.
userDisplayName
,
viewModel
.
userAvatar
)
saveAccountInteractor
.
save
(
account
)
}
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainView.kt
View file @
299e823c
...
...
@@ -18,10 +18,10 @@ interface MainView : MessageView, VersionCheckView {
/**
* Setups the navigation header.
*
* @param
m
odel The [NavHeaderViewModel].
* @param
viewM
odel The [NavHeaderViewModel].
* @param accounts The list of accounts.
*/
fun
setupNavHeader
(
m
odel
:
NavHeaderViewModel
,
accounts
:
List
<
Account
>)
fun
setupNavHeader
(
viewM
odel
:
NavHeaderViewModel
,
accounts
:
List
<
Account
>)
fun
closeServerSelection
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt
View file @
299e823c
...
...
@@ -92,13 +92,19 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
}
}
override
fun
setupNavHeader
(
m
odel
:
NavHeaderViewModel
,
accounts
:
List
<
Account
>)
{
Timber
.
d
(
"Setting up nav header: $
m
odel"
)
override
fun
setupNavHeader
(
viewM
odel
:
NavHeaderViewModel
,
accounts
:
List
<
Account
>)
{
Timber
.
d
(
"Setting up nav header: $
viewM
odel"
)
with
(
headerLayout
)
{
text_user_name
.
text
=
model
.
username
text_server_url
.
text
=
model
.
server
image_avatar
.
setImageURI
(
model
.
avatar
)
server_logo
.
setImageURI
(
model
.
serverLogo
)
image_user_status
.
setImageDrawable
(
DrawableHelper
.
getUserStatusDrawable
(
viewModel
.
userStatus
!!
,
this
.
context
)
)
text_user_name
.
text
=
viewModel
.
userDisplayName
text_server_url
.
text
=
viewModel
.
serverUrl
image_avatar
.
setImageURI
(
viewModel
.
userAvatar
)
server_logo
.
setImageURI
(
viewModel
.
serverLogo
)
setupAccountsList
(
headerLayout
,
accounts
)
}
}
...
...
app/src/main/java/chat/rocket/android/main/viewmodel/NavHeaderViewModel.kt
View file @
299e823c
package
chat.rocket.android.main.viewmodel
import
chat.rocket.common.model.UserStatus
data class
NavHeaderViewModel
(
val
username
:
String
,
val
server
:
String
,
val
avatar
:
String
?,
val
userDisplayName
:
String
,
val
userStatus
:
UserStatus
?,
val
userAvatar
:
String
?,
val
serverUrl
:
String
,
val
serverLogo
:
String
?
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/main/viewmodel/NavHeaderViewModelMapper.kt
View file @
299e823c
...
...
@@ -6,21 +6,24 @@ import chat.rocket.android.util.extensions.serverLogoUrl
import
chat.rocket.core.model.Myself
import
javax.inject.Inject
class
NavHeaderViewModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
class
NavHeaderViewModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
var
settings
:
PublicSettings
=
getSettingsInteractor
.
get
(
currentServer
)
fun
mapToViewModel
(
me
:
Myself
):
NavHeaderViewModel
{
val
username
=
mapUsername
(
me
)
val
thumb
=
me
.
username
?.
let
{
currentServer
.
avatarUrl
(
it
)
}
val
displayName
=
mapDisplayName
(
me
)
val
status
=
me
.
status
val
avatar
=
me
.
username
?.
let
{
currentServer
.
avatarUrl
(
it
)
}
val
image
=
settings
.
wideTile
()
?:
settings
.
faviconLarge
()
val
logo
=
image
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
return
NavHeaderViewModel
(
username
,
currentServer
,
thumb
,
logo
)
return
NavHeaderViewModel
(
displayName
,
status
,
avatar
,
currentServer
,
logo
)
}
private
fun
map
Usern
ame
(
me
:
Myself
):
String
{
private
fun
map
DisplayN
ame
(
me
:
Myself
):
String
{
val
username
=
me
.
username
val
realName
=
me
.
name
val
senderName
=
if
(
settings
.
useRealName
())
realName
else
username
...
...
app/src/main/res/layout/nav_header.xml
View file @
299e823c
...
...
@@ -45,7 +45,6 @@
android:id=
"@+id/image_user_status"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:src=
"@drawable/ic_status_online_24dp"
app:layout_constraintStart_toStartOf=
"parent"
/>
<TextView
...
...
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