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
d8aea109
Commit
d8aea109
authored
Mar 21, 2019
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes the server list only showing the current logged in server.
parent
1a3b7ba9
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
29 additions
and
23 deletions
+29
-23
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+5
-5
LoginOptionsPresenter.kt
...cation/loginoptions/presentation/LoginOptionsPresenter.kt
+1
-1
TwoFAPresenter.kt
...d/authentication/twofactor/presentation/TwoFAPresenter.kt
+1
-1
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+1
-1
AccountsRepository.kt
...a/chat/rocket/android/server/domain/AccountsRepository.kt
+1
-0
GetAccountInteractor.kt
...chat/rocket/android/server/domain/GetAccountInteractor.kt
+2
-1
RemoveAccountInteractor.kt
...t/rocket/android/server/domain/RemoveAccountInteractor.kt
+2
-1
SaveAccountInteractor.kt
...hat/rocket/android/server/domain/SaveAccountInteractor.kt
+1
-1
SharedPreferencesAccountsRepository.kt
...er/infraestructure/SharedPreferencesAccountsRepository.kt
+8
-5
item_add_account.xml
app/src/main/res/layout/item_add_account.xml
+7
-7
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
d8aea109
...
@@ -85,20 +85,20 @@ class LoginPresenter @Inject constructor(
...
@@ -85,20 +85,20 @@ class LoginPresenter @Inject constructor(
}
}
}
}
val
myself
=
retryIO
(
"me()"
)
{
client
.
me
()
}
val
myself
=
retryIO
(
"me()"
)
{
client
.
me
()
}
if
(
myself
.
username
!=
null
)
{
myself
.
username
?.
let
{
username
->
val
user
=
User
(
val
user
=
User
(
id
=
myself
.
id
,
id
=
myself
.
id
,
roles
=
myself
.
roles
,
roles
=
myself
.
roles
,
status
=
myself
.
status
,
status
=
myself
.
status
,
name
=
myself
.
name
,
name
=
myself
.
name
,
emails
=
myself
.
emails
?.
map
{
Email
(
it
.
address
?:
""
,
it
.
verified
)
},
emails
=
myself
.
emails
?.
map
{
Email
(
it
.
address
?:
""
,
it
.
verified
)
},
username
=
myself
.
username
,
username
=
username
,
utcOffset
=
myself
.
utcOffset
utcOffset
=
myself
.
utcOffset
)
)
localRepository
.
saveCurrentUser
(
currentServer
,
user
)
localRepository
.
saveCurrentUser
(
currentServer
,
user
)
saveCurrentServer
.
save
(
currentServer
)
saveCurrentServer
.
save
(
currentServer
)
localRepository
.
save
(
LocalRepository
.
CURRENT_USERNAME_KEY
,
myself
.
username
)
localRepository
.
save
(
LocalRepository
.
CURRENT_USERNAME_KEY
,
username
)
saveAccount
(
myself
.
username
!!
)
saveAccount
(
username
)
saveToken
(
token
)
saveToken
(
token
)
analyticsManager
.
logLogin
(
analyticsManager
.
logLogin
(
AuthenticationEvent
.
AuthenticationWithUserAndPassword
,
AuthenticationEvent
.
AuthenticationWithUserAndPassword
,
...
@@ -133,7 +133,7 @@ class LoginPresenter @Inject constructor(
...
@@ -133,7 +133,7 @@ class LoginPresenter @Inject constructor(
fun
forgotPassword
()
=
navigator
.
toForgotPassword
()
fun
forgotPassword
()
=
navigator
.
toForgotPassword
()
private
suspend
fun
saveAccount
(
username
:
String
)
{
private
fun
saveAccount
(
username
:
String
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
currentServer
.
serverLogoUrl
(
it
)
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/loginoptions/presentation/LoginOptionsPresenter.kt
View file @
d8aea109
...
@@ -173,7 +173,7 @@ class LoginOptionsPresenter @Inject constructor(
...
@@ -173,7 +173,7 @@ class LoginOptionsPresenter @Inject constructor(
settings
=
settingsInteractor
.
get
(
currentServer
)
settings
=
settingsInteractor
.
get
(
currentServer
)
}
}
private
suspend
fun
saveAccount
(
username
:
String
)
{
private
fun
saveAccount
(
username
:
String
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
currentServer
.
serverLogoUrl
(
it
)
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAPresenter.kt
View file @
d8aea109
...
@@ -94,7 +94,7 @@ class TwoFAPresenter @Inject constructor(
...
@@ -94,7 +94,7 @@ class TwoFAPresenter @Inject constructor(
}
}
}
}
private
suspend
fun
saveAccount
(
me
:
Myself
)
{
private
fun
saveAccount
(
me
:
Myself
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
currentServer
.
serverLogoUrl
(
it
)
}
}
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
d8aea109
...
@@ -210,7 +210,7 @@ class MainPresenter @Inject constructor(
...
@@ -210,7 +210,7 @@ class MainPresenter @Inject constructor(
}
}
}
}
private
suspend
fun
saveAccount
(
uiModel
:
NavHeaderUiModel
)
{
private
fun
saveAccount
(
uiModel
:
NavHeaderUiModel
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
currentServer
.
serverLogoUrl
(
it
)
}
}
...
...
app/src/main/java/chat/rocket/android/server/domain/AccountsRepository.kt
View file @
d8aea109
...
@@ -3,6 +3,7 @@ package chat.rocket.android.server.domain
...
@@ -3,6 +3,7 @@ package chat.rocket.android.server.domain
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.domain.model.Account
interface
AccountsRepository
{
interface
AccountsRepository
{
fun
save
(
account
:
Account
)
fun
save
(
account
:
Account
)
fun
load
():
List
<
Account
>
fun
load
():
List
<
Account
>
fun
remove
(
serverUrl
:
String
)
fun
remove
(
serverUrl
:
String
)
...
...
app/src/main/java/chat/rocket/android/server/domain/GetAccountInteractor.kt
View file @
d8aea109
...
@@ -3,7 +3,8 @@ package chat.rocket.android.server.domain
...
@@ -3,7 +3,8 @@ package chat.rocket.android.server.domain
import
javax.inject.Inject
import
javax.inject.Inject
class
GetAccountInteractor
@Inject
constructor
(
val
repository
:
AccountsRepository
)
{
class
GetAccountInteractor
@Inject
constructor
(
val
repository
:
AccountsRepository
)
{
suspend
fun
get
(
url
:
String
)
=
repository
.
load
().
firstOrNull
{
account
->
fun
get
(
url
:
String
)
=
repository
.
load
().
firstOrNull
{
account
->
url
==
account
.
serverUrl
url
==
account
.
serverUrl
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/domain/RemoveAccountInteractor.kt
View file @
d8aea109
...
@@ -3,7 +3,8 @@ package chat.rocket.android.server.domain
...
@@ -3,7 +3,8 @@ package chat.rocket.android.server.domain
import
javax.inject.Inject
import
javax.inject.Inject
class
RemoveAccountInteractor
@Inject
constructor
(
val
repository
:
AccountsRepository
)
{
class
RemoveAccountInteractor
@Inject
constructor
(
val
repository
:
AccountsRepository
)
{
suspend
fun
remove
(
serverUrl
:
String
)
{
fun
remove
(
serverUrl
:
String
)
{
repository
.
remove
(
serverUrl
)
repository
.
remove
(
serverUrl
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/domain/SaveAccountInteractor.kt
View file @
d8aea109
...
@@ -4,5 +4,5 @@ import chat.rocket.android.server.domain.model.Account
...
@@ -4,5 +4,5 @@ import chat.rocket.android.server.domain.model.Account
import
javax.inject.Inject
import
javax.inject.Inject
class
SaveAccountInteractor
@Inject
constructor
(
val
repository
:
AccountsRepository
)
{
class
SaveAccountInteractor
@Inject
constructor
(
val
repository
:
AccountsRepository
)
{
suspend
fun
save
(
account
:
Account
)
=
repository
.
save
(
account
)
fun
save
(
account
:
Account
)
=
repository
.
save
(
account
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/infraestructure/SharedPreferencesAccountsRepository.kt
View file @
d8aea109
...
@@ -15,7 +15,12 @@ class SharedPreferencesAccountsRepository(
...
@@ -15,7 +15,12 @@ class SharedPreferencesAccountsRepository(
)
:
AccountsRepository
{
)
:
AccountsRepository
{
override
fun
save
(
account
:
Account
)
{
override
fun
save
(
account
:
Account
)
{
save
(
load
().
filter
{
item
->
item
.
serverUrl
!=
item
.
serverUrl
}.
toMutableList
().
apply
{
add
(
0
,
account
)
})
load
().
filter
{
it
.
serverUrl
!=
account
.
serverUrl
}
.
toMutableList
()
.
apply
{
add
(
0
,
account
)
save
(
this
)
}
}
}
override
fun
load
():
List
<
Account
>
{
override
fun
load
():
List
<
Account
>
{
...
@@ -23,7 +28,7 @@ class SharedPreferencesAccountsRepository(
...
@@ -23,7 +28,7 @@ class SharedPreferencesAccountsRepository(
val
type
=
Types
.
newParameterizedType
(
List
::
class
.
java
,
Account
::
class
.
java
)
val
type
=
Types
.
newParameterizedType
(
List
::
class
.
java
,
Account
::
class
.
java
)
val
adapter
=
moshi
.
adapter
<
List
<
Account
>>(
type
)
val
adapter
=
moshi
.
adapter
<
List
<
Account
>>(
type
)
return
json
?.
let
{
adapter
.
fromJson
(
it
)
?:
emptyList
()
}
?:
emptyList
()
return
json
?.
let
{
adapter
.
fromJson
(
it
)
}
?:
emptyList
()
}
}
override
fun
remove
(
serverUrl
:
String
)
{
override
fun
remove
(
serverUrl
:
String
)
{
...
@@ -33,8 +38,6 @@ class SharedPreferencesAccountsRepository(
...
@@ -33,8 +38,6 @@ class SharedPreferencesAccountsRepository(
private
fun
save
(
accounts
:
List
<
Account
>)
{
private
fun
save
(
accounts
:
List
<
Account
>)
{
val
type
=
Types
.
newParameterizedType
(
List
::
class
.
java
,
Account
::
class
.
java
)
val
type
=
Types
.
newParameterizedType
(
List
::
class
.
java
,
Account
::
class
.
java
)
val
adapter
=
moshi
.
adapter
<
List
<
Account
>>(
type
)
val
adapter
=
moshi
.
adapter
<
List
<
Account
>>(
type
)
preferences
.
edit
{
preferences
.
edit
{
putString
(
ACCOUNTS_KEY
,
adapter
.
toJson
(
accounts
))
}
putString
(
ACCOUNTS_KEY
,
adapter
.
toJson
(
accounts
))
}
}
}
}
}
\ No newline at end of file
app/src/main/res/layout/item_add_account.xml
View file @
d8aea109
...
@@ -3,27 +3,27 @@
...
@@ -3,27 +3,27 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:
padding=
"16dp
"
android:
background=
"?selectableItemBackground
"
android:
background=
"?selectableItemBackground
"
>
android:
padding=
"16dp
"
>
<ImageView
<ImageView
android:id=
"@+id/server_logo"
android:id=
"@+id/server_logo"
android:layout_width=
"40dp"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_height=
"40dp"
android:src=
"@drawable/ic_add_24dp"
android:src=
"@drawable/ic_add_24dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintBottom_toBottomOf=
"parent"
/>
<TextView
<TextView
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body2"
android:text=
"@string/action_add_account"
android:text=
"@string/action_add_account"
a
pp:layout_constraintTop_toTopOf=
"parent
"
a
ndroid:textAppearance=
"@style/TextAppearance.AppCompat.Body2
"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@id/server_logo"
app:layout_constraintStart_toEndOf=
"@id/server_logo"
app:layout_constraint
End_toEnd
Of=
"parent"
/>
app:layout_constraint
Top_toTop
Of=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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