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
65db658e
Unverified
Commit
65db658e
authored
Mar 23, 2019
by
Divyanshu Bhargava
Committed by
GitHub
Mar 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'beta' into fix-2133
parents
c8cd83d1
81dc71d8
Changes
10
Hide 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 @
65db658e
...
...
@@ -85,20 +85,20 @@ class LoginPresenter @Inject constructor(
}
}
val
myself
=
retryIO
(
"me()"
)
{
client
.
me
()
}
if
(
myself
.
username
!=
null
)
{
myself
.
username
?.
let
{
username
->
val
user
=
User
(
id
=
myself
.
id
,
roles
=
myself
.
roles
,
status
=
myself
.
status
,
name
=
myself
.
name
,
emails
=
myself
.
emails
?.
map
{
Email
(
it
.
address
?:
""
,
it
.
verified
)
},
username
=
myself
.
username
,
username
=
username
,
utcOffset
=
myself
.
utcOffset
)
localRepository
.
saveCurrentUser
(
currentServer
,
user
)
saveCurrentServer
.
save
(
currentServer
)
localRepository
.
save
(
LocalRepository
.
CURRENT_USERNAME_KEY
,
myself
.
username
)
saveAccount
(
myself
.
username
!!
)
localRepository
.
save
(
LocalRepository
.
CURRENT_USERNAME_KEY
,
username
)
saveAccount
(
username
)
saveToken
(
token
)
analyticsManager
.
logLogin
(
AuthenticationEvent
.
AuthenticationWithUserAndPassword
,
...
...
@@ -133,7 +133,7 @@ class LoginPresenter @Inject constructor(
fun
forgotPassword
()
=
navigator
.
toForgotPassword
()
private
suspend
fun
saveAccount
(
username
:
String
)
{
private
fun
saveAccount
(
username
:
String
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
...
...
app/src/main/java/chat/rocket/android/authentication/loginoptions/presentation/LoginOptionsPresenter.kt
View file @
65db658e
...
...
@@ -173,7 +173,7 @@ class LoginOptionsPresenter @Inject constructor(
settings
=
settingsInteractor
.
get
(
currentServer
)
}
private
suspend
fun
saveAccount
(
username
:
String
)
{
private
fun
saveAccount
(
username
:
String
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAPresenter.kt
View file @
65db658e
...
...
@@ -94,7 +94,7 @@ class TwoFAPresenter @Inject constructor(
}
}
private
suspend
fun
saveAccount
(
me
:
Myself
)
{
private
fun
saveAccount
(
me
:
Myself
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
65db658e
...
...
@@ -210,7 +210,7 @@ class MainPresenter @Inject constructor(
}
}
private
suspend
fun
saveAccount
(
uiModel
:
NavHeaderUiModel
)
{
private
fun
saveAccount
(
uiModel
:
NavHeaderUiModel
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
...
...
app/src/main/java/chat/rocket/android/server/domain/AccountsRepository.kt
View file @
65db658e
...
...
@@ -3,6 +3,7 @@ package chat.rocket.android.server.domain
import
chat.rocket.android.server.domain.model.Account
interface
AccountsRepository
{
fun
save
(
account
:
Account
)
fun
load
():
List
<
Account
>
fun
remove
(
serverUrl
:
String
)
...
...
app/src/main/java/chat/rocket/android/server/domain/GetAccountInteractor.kt
View file @
65db658e
...
...
@@ -3,7 +3,8 @@ package chat.rocket.android.server.domain
import
javax.inject.Inject
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
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/domain/RemoveAccountInteractor.kt
View file @
65db658e
...
...
@@ -3,7 +3,8 @@ package chat.rocket.android.server.domain
import
javax.inject.Inject
class
RemoveAccountInteractor
@Inject
constructor
(
val
repository
:
AccountsRepository
)
{
suspend
fun
remove
(
serverUrl
:
String
)
{
fun
remove
(
serverUrl
:
String
)
{
repository
.
remove
(
serverUrl
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/domain/SaveAccountInteractor.kt
View file @
65db658e
...
...
@@ -4,5 +4,5 @@ import chat.rocket.android.server.domain.model.Account
import
javax.inject.Inject
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 @
65db658e
...
...
@@ -15,7 +15,12 @@ class SharedPreferencesAccountsRepository(
)
:
AccountsRepository
{
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
>
{
...
...
@@ -23,7 +28,7 @@ class SharedPreferencesAccountsRepository(
val
type
=
Types
.
newParameterizedType
(
List
::
class
.
java
,
Account
::
class
.
java
)
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
)
{
...
...
@@ -33,8 +38,6 @@ class SharedPreferencesAccountsRepository(
private
fun
save
(
accounts
:
List
<
Account
>)
{
val
type
=
Types
.
newParameterizedType
(
List
::
class
.
java
,
Account
::
class
.
java
)
val
adapter
=
moshi
.
adapter
<
List
<
Account
>>(
type
)
preferences
.
edit
{
putString
(
ACCOUNTS_KEY
,
adapter
.
toJson
(
accounts
))
}
preferences
.
edit
{
putString
(
ACCOUNTS_KEY
,
adapter
.
toJson
(
accounts
))
}
}
}
\ No newline at end of file
app/src/main/res/layout/item_add_account.xml
View file @
65db658e
...
...
@@ -3,27 +3,27 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:
padding=
"16dp
"
android:
background=
"?selectableItemBackground
"
>
android:
background=
"?selectableItemBackground
"
android:
padding=
"16dp
"
>
<ImageView
android:id=
"@+id/server_logo"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:src=
"@drawable/ic_add_24dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body2"
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_constraintEnd_toEndOf=
"parent"
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>
\ 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