Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Vladislav Bogdashkin
Room Park Android
Commits
a25d3111
Commit
a25d3111
authored
Nov 18, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update sign in layout
add sign out method impl
parent
423dc854
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
93 additions
and
18 deletions
+93
-18
ContextModule.kt
...va/com/biganto/visual/roompark/di/dagger/ContextModule.kt
+1
-0
settings.kt
...com/biganto/visual/roompark/domain/interactor/settings.kt
+4
-0
authUseCase.kt
...om/biganto/visual/roompark/domain/use_case/authUseCase.kt
+1
-0
ScreenController.kt
...ual/roompark/presentation/screen/auth/ScreenController.kt
+29
-6
ScreenPresenter.kt
...sual/roompark/presentation/screen/auth/ScreenPresenter.kt
+3
-1
ScreenViewState.kt
...sual/roompark/presentation/screen/auth/ScreenViewState.kt
+3
-0
ScreenContract.kt
...l/roompark/presentation/screen/settings/ScreenContract.kt
+2
-0
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+18
-0
ScreenDI.kt
.../visual/roompark/presentation/screen/settings/ScreenDI.kt
+11
-4
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+7
-0
ScreenViewState.kt
.../roompark/presentation/screen/settings/ScreenViewState.kt
+1
-0
authentication_screen.xml
app/src/main/res/layout/authentication_screen.xml
+8
-2
settings_screen.xml
app/src/main/res/layout/settings_screen.xml
+5
-5
No files found.
app/src/main/java/com/biganto/visual/roompark/di/dagger/ContextModule.kt
View file @
a25d3111
...
...
@@ -69,5 +69,6 @@ class AuthContractModule @Inject constructor(
is
UserState
.
Authenticated
->
true
else
->
false
}
}
}
app/src/main/java/com/biganto/visual/roompark/domain/interactor/settings.kt
View file @
a25d3111
...
...
@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.CachedDataModel
import
com.biganto.visual.roompark.domain.model.PushSwitchModel
import
com.biganto.visual.roompark.domain.model.SettingsModel
import
com.biganto.visual.roompark.domain.use_case.AuthUseCase
import
io.reactivex.Observable
import
javax.inject.Inject
...
...
@@ -11,10 +12,13 @@ import javax.inject.Inject
*/
class
SettingsInteractor
@Inject
constructor
(
private
val
auth
:
AuthUseCase
){
fun
fetchSettings
():
Observable
<
SettingsModel
>
=
Observable
.
just
(
sampleSettings
)
fun
signOut
()
=
auth
.
signOut
()
companion
object
{
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/authUseCase.kt
View file @
a25d3111
...
...
@@ -13,5 +13,6 @@ class AuthUseCase @Inject constructor(
fun
validateAuth
()
=
authContract
.
validateAuthState
()
fun
signIn
(
login
:
String
,
pwd
:
String
)
=
authContract
.
signIn
(
login
,
pwd
)
fun
signOut
()
=
authContract
.
signOut
()
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/auth/ScreenController.kt
View file @
a25d3111
...
...
@@ -33,12 +33,17 @@ class AuthScreenController :
@BindView
(
R
.
id
.
sign_in_button
)
lateinit
var
signInButton
:
MaterialButton
override
fun
tryAuth
():
Observable
<
AuthInputModel
>
=
Observable
.
defer
{
signInButton
.
clicks
()
.
doOnNext
{
signInButton
.
hideKeyboard
()}
.
map
<
AuthInputModel
>{
AuthInputModel
(
loginInput
.
editText
?.
text
?.
toString
()
?:
""
,
pwdInput
.
editText
?.
text
?.
toString
()
?:
""
)
.
doOnNext
{
signInButton
.
hideKeyboard
()
}
.
map
<
AuthInputModel
>
{
AuthInputModel
(
loginInput
.
editText
?.
text
?.
toString
()
?:
""
,
pwdInput
.
editText
?.
text
?.
toString
()
?:
""
)
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
}
override
fun
injectDependencies
()
{
getComponent
()
...
...
@@ -92,6 +97,24 @@ class AuthScreenController :
signInButton
.
isEnabled
=
true
}
private
fun
render
(
viewState
:
AuthScreenViewState
.
WrongLogin
){
// showError(viewState.exception)
viewState
.
exception
.
selectHandler
(
{
strId
->
loginInput
.
error
=
resources
?.
getString
(
strId
)},
{
message
->
loginInput
.
error
=
message
}
)
signInButton
.
isEnabled
=
true
}
private
fun
render
(
viewState
:
AuthScreenViewState
.
WrongPassword
){
viewState
.
exception
.
selectHandler
(
{
strId
->
pwdInput
.
error
=
resources
?.
getString
(
strId
)},
{
message
->
pwdInput
.
error
=
message
}
)
signInButton
.
isEnabled
=
true
}
private
fun
render
(
viewState
:
AuthScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/auth/ScreenPresenter.kt
View file @
a25d3111
...
...
@@ -24,6 +24,8 @@ class AuthScreenPresenter @Inject constructor(
override
fun
vsByCode
(
code
:
Int
):
(
ExceptionString
)
->
AuthScreenViewState
=
when
(
code
)
{
101
->
{
e
:
ExceptionString
->
AuthScreenViewState
.
SignInError
(
e
)}
111
->
{
e
:
ExceptionString
->
AuthScreenViewState
.
WrongLogin
(
e
)}
112
->
{
e
:
ExceptionString
->
AuthScreenViewState
.
WrongPassword
(
e
)}
else
->
{
e
:
ExceptionString
->
AuthScreenViewState
.
SomeError
(
e
)}
}
...
...
@@ -35,7 +37,7 @@ class AuthScreenPresenter @Inject constructor(
.
doOnNext
{
Timber
.
d
(
"auth returned $it"
)
}
.
map
{
it
}
.
map
<
AuthScreenViewState
>
{
AuthScreenViewState
.
SignedIn
()
}
.
onErrorReturn
{
parseError
(
it
)}
//
.onErrorReturn{parseError(it)}
}
// .startWith(Observable.just(AuthScreenViewState.Authorization()))
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/auth/ScreenViewState.kt
View file @
a25d3111
...
...
@@ -13,4 +13,7 @@ sealed class AuthScreenViewState : BigantoBaseViewState() {
class
SignedIn
:
AuthScreenViewState
()
class
SignInError
(
val
exception
:
ExceptionString
)
:
AuthScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
AuthScreenViewState
()
class
WrongLogin
(
val
exception
:
ExceptionString
)
:
AuthScreenViewState
()
class
WrongPassword
(
val
exception
:
ExceptionString
)
:
AuthScreenViewState
()
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenContract.kt
View file @
a25d3111
package
com.biganto.visual.roompark.presentation.screen.settings
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface
SettingsScreen
:
BigantoBaseContract
<
SettingsScreenViewState
>
{
fun
signOut
():
Observable
<
Int
>
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
a25d3111
...
...
@@ -11,10 +11,15 @@ import com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.presentation.screen.auth.AuthScreenController
import
com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import
com.biganto.visual.roompark.util.extensions.bytesToSize
import
com.bluelinelabs.conductor.RouterTransaction
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
javax.inject.Inject
...
...
@@ -28,6 +33,11 @@ class SettingsScreenController :
,
SettingsScreenPresenter
>()
,
SettingsScreen
{
override
fun
signOut
():
Observable
<
Int
>
=
signOutButton
.
clicks
()
.
map
{
1
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
injectDependencies
()
{
getComponent
()
}
...
...
@@ -57,6 +67,9 @@ class SettingsScreenController :
@BindView
(
R
.
id
.
downloadFlatCardsIcon
)
lateinit
var
flatDownloaderButton
:
ImageView
@BindView
(
R
.
id
.
signOutButton
)
lateinit
var
signOutButton
:
MaterialTextView
private
fun
setToolbar
(){
toolBar
.
showAll
()
...
...
@@ -94,6 +107,7 @@ class SettingsScreenController :
is
SettingsScreenViewState
.
Idle
->
render
(
viewState
)
is
SettingsScreenViewState
.
LoadSettingsList
->
render
(
viewState
)
is
SettingsScreenViewState
.
SomeError
->
render
(
viewState
)
is
SettingsScreenViewState
.
SignOut
->
render
(
viewState
)
}
}
...
...
@@ -104,6 +118,10 @@ class SettingsScreenController :
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
SignOut
){
router
.
setRoot
(
RouterTransaction
.
with
(
AuthScreenController
()))
}
@SuppressLint
(
"SetTextI18n"
)
private
fun
render
(
viewState
:
SettingsScreenViewState
.
LoadSettingsList
){
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenDI.kt
View file @
a25d3111
...
...
@@ -2,8 +2,10 @@ package com.biganto.visual.roompark.presentation.screen.settings
import
android.content.Context
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.di.dagger.AppComponent
import
com.biganto.visual.roompark.di.dagger.PerScreen
import
com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import
com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import
com.biganto.visual.roompark.di.dagger.*
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
dagger.Binds
import
dagger.BindsInstance
import
dagger.Component
...
...
@@ -12,7 +14,8 @@ import dagger.Module
@PerScreen
@Component
(
modules
=
[
SettingsScreenModule
::
class
],
modules
=
[
SettingsScreenModule
::
class
,
DataModule
::
class
,
RetrofitModule
::
class
,
AppModule
::
class
,
DbModule
::
class
],
dependencies
=
[
AppComponent
::
class
])
interface
SettingsScreenComponent
{
...
...
@@ -36,4 +39,8 @@ abstract class SettingsScreenModule{
@Binds
abstract
fun
provideContext
(
activity
:
RoomParkMainActivity
):
Context
@PerScreen
@Binds
abstract
fun
provideAuth
(
contract
:
AuthContractModule
):
AuthContract
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
a25d3111
...
...
@@ -26,10 +26,17 @@ class SettingsScreenPresenter @Inject constructor(
val
fetchSettings
=
interactor
.
fetchSettings
()
.
map
{
SettingsScreenViewState
.
LoadSettingsList
(
it
)
}
val
onSignOut
=
intent
(
SettingsScreen
::
signOut
)
.
flatMap
{
interactor
.
signOut
()
.
toObservable
<
SettingsScreenViewState
>()
.
map
{
SettingsScreenViewState
.
SignOut
()
}}
val
state
=
restoreStateObservable
.
mergeWith
(
fetchSettings
)
.
mergeWith
(
onSignOut
)
.
doOnError
{
Timber
.
e
(
it
)}
.
subscribeOn
(
Schedulers
.
io
())
.
onErrorReturn
(
::
parseError
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
subscribeViewState
(
state
.
cast
(
SettingsScreenViewState
::
class
.
java
),
SettingsScreen
::
render
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenViewState.kt
View file @
a25d3111
...
...
@@ -13,4 +13,5 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
class
Idle
:
SettingsScreenViewState
()
class
LoadSettingsList
(
val
settings
:
SettingsModel
)
:
SettingsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
SettingsScreenViewState
()
class
SignOut
()
:
SettingsScreenViewState
()
}
\ No newline at end of file
app/src/main/res/layout/authentication_screen.xml
View file @
a25d3111
...
...
@@ -52,13 +52,16 @@
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"16dp"
android:nextFocusDown=
"@id/password_text_input"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView3"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
android:maxLength=
"64"
android:maxLines=
"1"
/>
</com.google.android.material.textfield.TextInputLayout>
<FrameLayout
...
...
@@ -76,12 +79,15 @@
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/password_text_input"
style=
"@style/AuthTextInputLayout.Password"
android:nextFocusDown=
"@id/sign_in_button"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
android:maxLength=
"64"
android:maxLines=
"1"
/>
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
...
...
app/src/main/res/layout/settings_screen.xml
View file @
a25d3111
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/nestedScrollContainer"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<LinearLayout
xmlns:tools=
"http://schemas.android.com/tools"
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
...
...
@@ -139,11 +139,11 @@
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/signOutButton"
style=
"@style/Default_TextView.Cancel_Text"
android:text=
"СМЕНИТЬ АККАУНТ"
android:layout_margin=
"32dp"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_margin=
"32dp"
android:text=
"СМЕНИТЬ АККАУНТ"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
\ 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