Skip to content

Commit

Permalink
Merge branch 'dev' into feature/82-login-layout-new-pincode-view
Browse files Browse the repository at this point in the history
  • Loading branch information
alexxk2 committed Jun 6, 2024
2 parents 20d15bf + 55dcc83 commit ed8f70f
Show file tree
Hide file tree
Showing 120 changed files with 3,428 additions and 166 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ dependencies {

// Glide
implementation(libs.glide)
annotationProcessor(libs.compiler)
implementation(libs.glide.okhttp3)
kapt(libs.glide.compiler)

// Timber
implementation(libs.timber)
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/app/cashadvisor/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package app.cashadvisor

import android.app.Application
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import com.google.firebase.crashlytics.FirebaseCrashlytics
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
Expand All @@ -11,6 +13,7 @@ class App : Application() {

override fun onCreate() {
super.onCreate()
setRussianLocale()
configureTimber()
}

Expand Down Expand Up @@ -55,6 +58,12 @@ class App : Application() {
})
}

private fun setRussianLocale() {
val appLocale: LocaleListCompat =
LocaleListCompat.forLanguageTags("ru")
AppCompatDelegate.setApplicationLocales(appLocale)
}

companion object {
private const val DEBUG = "DEBUG"
private const val RELEASE = "RELEASE"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package app.cashadvisor.analytics.presentation.ui

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import app.cashadvisor.R
import app.cashadvisor.databinding.FragmentAnalyticsBinding
Expand Down Expand Up @@ -33,6 +33,10 @@ class AnalyticsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.profileHeader.setOnClickListener {
findNavController().navigate(R.id.action_analyticsFragment_to_profileSettingsFragment)
}

binding.btnAddBank.setOnClickListener {
findNavController().navigate(R.id.action_analyticsFragment_to_addBankSelectionFragment)
}
Expand All @@ -59,7 +63,7 @@ class AnalyticsFragment : Fragment() {
}

rbIncome.isChecked && rbFact.isChecked -> {
findNavController().navigate(addIncome)
findNavController().navigate(addIncome)
}

rbExpense.isChecked && rbPlan.isChecked -> {
Expand All @@ -71,7 +75,7 @@ class AnalyticsFragment : Fragment() {
}

rbSaving.isChecked && rbPlan.isChecked -> {
findNavController().navigate(planSaving)
findNavController().navigate(planSaving)
}

rbSaving.isChecked && rbFact.isChecked -> {
Expand All @@ -83,8 +87,6 @@ class AnalyticsFragment : Fragment() {
}




}

override fun onDestroyView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import app.cashadvisor.common.utill.exceptions.LoginException
import app.cashadvisor.common.utill.exceptions.NetworkException
import kotlinx.serialization.json.Json
import javax.inject.Inject
import kotlin.time.Duration.Companion.nanoseconds

class NetworkToLoginExceptionMapper @Inject constructor(
private val json: Json
Expand Down Expand Up @@ -57,7 +58,7 @@ class NetworkToLoginExceptionMapper @Inject constructor(
handleErrorResponse<ErrorWrongConfirmationCodeResponse>(exception.errorBody)
LoginException.LoginCodeConfirmation.UnauthorizedWrongConfirmationCode(
remainingAttempts = errorResponse.remainingAttempts,
lockDuration = errorResponse.lockDuration,
lockDuration = errorResponse.lockDurationNanoseconds.nanoseconds.inWholeMinutes,
message = errorResponse.error,
statusCode = errorResponse.statusCode
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import app.cashadvisor.common.utill.exceptions.NetworkException
import app.cashadvisor.common.utill.exceptions.RegisterException
import kotlinx.serialization.json.Json
import javax.inject.Inject
import kotlin.time.Duration.Companion.nanoseconds

class NetworkToRegisterExceptionMapper @Inject constructor(
private val json: Json
Expand Down Expand Up @@ -49,7 +50,7 @@ class NetworkToRegisterExceptionMapper @Inject constructor(
handleErrorResponse<ErrorWrongConfirmationCodeResponse>(exception.errorBody)
RegisterException.EmailCodeConfirmation.UnauthorizedWrongConfirmationCode(
remainingAttempts = errorResponse.remainingAttempts,
lockDuration = errorResponse.lockDuration,
lockDuration = errorResponse.lockDurationNanoseconds.nanoseconds.inWholeMinutes,
message = errorResponse.error,
statusCode = errorResponse.statusCode
)
Expand All @@ -69,9 +70,9 @@ class NetworkToRegisterExceptionMapper @Inject constructor(

private fun handleCommonException(exception: NetworkException): RegisterException {
return when (exception) {

is NetworkException.NoInternetConnection -> {
val errorResponse = handleErrorResponse<ErrorResponse>(exception.errorBody)
RegisterException.NoConnection(errorResponse.message)
RegisterException.NoConnection(exception.errorBody)
}

is NetworkException.Undefined -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class ErrorWrongConfirmationCodeResponse(
@SerialName("remaining_attempts") val remainingAttempts: Int,
@SerialName("lock_duration") val lockDuration: Long,
@SerialName("lock_duration") val lockDurationNanoseconds: Long,
val error: String,
@SerialName("status_code") val statusCode: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,36 @@ class InputValidationInteractorImpl @Inject constructor() : InputValidationInter
val isEmailValid = isValidText(email.trimStart().trimEnd(), REGEX_PATTERN_EMAIL)
return if (isEmailValid) {
EmailValidationState.Success(Email(value = email))
} else EmailValidationState.Error(
} else EmailValidationState.Error(
email = Email(EMPTY_VALUE),
emailValidationError = EmailValidationError.EMAIL_NOT_VALID
)
}

override suspend fun validatePassword(password: String): PasswordValidationState {
if (password.length < 8) {
return PasswordValidationState.Error(
password = Password(EMPTY_VALUE),
passwordValidationError = PasswordValidationError.PASSWORD_IS_NOT_LONG_ENOUGH
)
}

// if (password.length in 31..7) {
// return PasswordValidationState.Error(
// //password = Password(EMPTY_VALUE),
// passwordValidationError = PasswordValidationError.PASSWORD_IS_NOT_LONG_ENOUGH
// )
// }

val isPasswordValid = isValidText(password.trimStart().trimEnd(), REGEX_PATTERN_PASSWORD)
return if (isPasswordValid) {
PasswordValidationState.Success(Password(value = password))
} else PasswordValidationState.Error(
password = Password(EMPTY_VALUE),
//val isPasswordLengthValid: Boolean = isValidText(password.trimStart().trimEnd(), REGEX_PATTERN_LENGTH_PASSWORD)

return if (!isPasswordValid)
PasswordValidationState.Error(
//password = Password(EMPTY_VALUE),
passwordValidationError = PasswordValidationError.PASSWORD_NOT_VALID
)

else if (password.length !in 8 .. 30){
PasswordValidationState.Error(
//password = Password(EMPTY_VALUE),
passwordValidationError = PasswordValidationError.PASSWORD_IS_NOT_LONG_ENOUGH)
}
else PasswordValidationState.Success(Password(value = password))
}

override suspend fun validateConfirmationCode(code: String): ConfirmCodeValidationState {
Expand All @@ -63,7 +73,8 @@ class InputValidationInteractorImpl @Inject constructor() : InputValidationInter
companion object {
const val REGEX_PATTERN_EMAIL =
"""^(?=(?:(?!.*[_.-]{2,})(?!.*[_.-]$)(?!^[-_.])[a-zA-Z0-9._-]{1,49}[a-zA-Z0-9]@(?!-)[a-zA-Z0-9-]{1,63}(\.[a-zA-Z]{2,})+)$)(?=(?:.{7,114})$).*"""
const val REGEX_PATTERN_PASSWORD = """^[a-zA-Z0-9_]{8,30}$"""
const val REGEX_PATTERN_PASSWORD = """^[a-zA-Z0-9_]*$"""
const val REGEX_PATTERN_LENGTH_PASSWORD = """^{8,30}$"""
const val REGEX_PATTERN_CODE = """^[0-9]{4}$"""
const val EMPTY_VALUE = ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ sealed interface EmailValidationState {
val email: Email,
val emailValidationError: EmailValidationError
) : EmailValidationState
data object Default: EmailValidationState
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import app.cashadvisor.authorization.domain.models.PasswordValidationError
sealed interface PasswordValidationState {
data class Success(val password: Password) : PasswordValidationState
data class Error(
val password: Password,
//val password: Password,
val passwordValidationError: PasswordValidationError
) : PasswordValidationState
data object Default : PasswordValidationState
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.fragment.findNavController
import app.cashadvisor.authorization.domain.models.states.EmailValidationState
import app.cashadvisor.authorization.domain.models.states.PasswordValidationState
import app.cashadvisor.authorization.presentation.ui.models.LoginScreenSideEffects
import app.cashadvisor.authorization.presentation.ui.models.LoginScreenMessageContent
import app.cashadvisor.authorization.presentation.ui.models.LoginScreenSideEffects
import app.cashadvisor.authorization.presentation.viewmodel.LoginViewModel
import app.cashadvisor.authorization.presentation.viewmodel.models.LoginEmailValidationState
import app.cashadvisor.authorization.presentation.viewmodel.models.LoginPasswordValidationState
import app.cashadvisor.authorization.presentation.viewmodel.models.LoginScreenState
import app.cashadvisor.common.ui.BaseFragment
import app.cashadvisor.databinding.FragmentLoginBinding
Expand Down Expand Up @@ -171,43 +171,43 @@ class LoginFragment :
}
}

private fun manageEmailValidation(state: EmailValidationState?) {
private fun manageEmailValidation(state: LoginEmailValidationState?) {
state?.let {
with(binding) {
when (state) {
is EmailValidationState.Error -> {
is LoginEmailValidationState.Error -> {
showErrorEditText(etEmailInput)
}

is EmailValidationState.Success -> {
is LoginEmailValidationState.Success -> {
showSuccessEditText(etEmailInput)
}

EmailValidationState.Default -> {
LoginEmailValidationState.Default -> {
showNeutralEditText(etEmailInput)
}
}
}
}
}

private fun managePasswordValidation(state: PasswordValidationState?) {
private fun managePasswordValidation(state: LoginPasswordValidationState?) {
state?.let {
with(binding) {
when (state) {
is PasswordValidationState.Error -> {
is LoginPasswordValidationState.Error -> {
showErrorEditText(etPasswordInput)
tiPasswordInput.isHelperTextEnabled = true
tiPasswordInput.helperText =
getString(R.string.password_text_input_helper_text)
}

is PasswordValidationState.Success -> {
is LoginPasswordValidationState.Success -> {
showSuccessEditText(etPasswordInput)
tiPasswordInput.isHelperTextEnabled = false
}

PasswordValidationState.Default -> {
LoginPasswordValidationState.Default -> {
showNeutralEditText(etPasswordInput)
tiPasswordInput.isHelperTextEnabled = false
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class TestViewModel @Inject constructor(
private fun setEmail(email: String) {
viewModelScope.launch {
val result = inputValidationInteractor.validateEmail(email)

when (result) {
is EmailValidationState.Success -> {
_state.update {
Expand All @@ -87,10 +88,6 @@ class TestViewModel @Inject constructor(
it.copy(email = result.email, isEmailValid = false)
}
}

EmailValidationState.Default -> {

}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class EntryViewModel @Inject constructor() : BaseViewModel() {
private var _state = MutableStateFlow<EntryScreenState>(EntryScreenState.Default)
val state: StateFlow<EntryScreenState>
get() = _state

private var coolDownDebounce: ((Unit) -> Unit) = debounce(
COOL_DOWN_DELAY,
viewModelScope
Expand Down
Loading

0 comments on commit ed8f70f

Please sign in to comment.