Skip to content

Commit

Permalink
refactor: Login module
Browse files Browse the repository at this point in the history
  • Loading branch information
akashmeruva9 committed Jul 5, 2024
1 parent ec8d6b8 commit 4af7c15
Show file tree
Hide file tree
Showing 30 changed files with 466 additions and 212 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ dependencies {
implementation(projects.feature.savings)
implementation(projects.feature.qr)
implementation(projects.feature.transferProcess)
implementation(projects.feature.account)



Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.mifos.mobile.ui.client_accounts


import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
Expand All @@ -16,6 +15,7 @@ import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.core.model.enums.AccountType
import org.mifos.mobile.ui.fragments.base.BaseFragment
import org.mifos.mobile.core.common.Constants
import org.mifos.mobile.feature.account.client_account.screens.ClientAccountsScreen

/*
~This project is licensed under the open source MPL V2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.mifos.mobile.ui.enums.AccountType
import org.mifos.mobile.ui.fragments.base.BaseFragment
import org.mifos.mobile.core.common.Constants
import org.mifos.mobile.core.common.utils.ParcelableAndSerializableUtils.getCheckedSerializable
import org.mifos.mobile.utils.StatusUtils
import org.mifos.mobile.feature.account.utils.StatusUtils
import javax.inject.Inject
/*
Expand Down
114 changes: 0 additions & 114 deletions app/src/main/java/org/mifos/mobile/utils/StatusUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,120 +11,6 @@ import org.mifos.mobile.ui.getThemeAttributeColor
*/
object StatusUtils {

fun getSavingsAccountStatusList(context: Context?): List<CheckboxStatus> {
val arrayList = ArrayList<CheckboxStatus>()
arrayList.add(
CheckboxStatus(
context?.getString(R.string.active),
ContextCompat.getColor(context!!, R.color.deposit_green),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.approved),
ContextCompat.getColor(context, R.color.light_green),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.approval_pending),
ContextCompat
.getColor(context, R.color.light_yellow),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.matured),
ContextCompat.getColor(context, R.color.red_light),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.closed),
context.getThemeAttributeColor(R.attr.colorOnSurface),
),
)
return arrayList
}

fun getLoanAccountStatusList(context: Context?): List<CheckboxStatus> {
val arrayList = ArrayList<CheckboxStatus>()
arrayList.add(
CheckboxStatus(
context?.getString(R.string.in_arrears),
ContextCompat.getColor(context!!, R.color.red),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.active),
ContextCompat.getColor(context, R.color.deposit_green),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.waiting_for_disburse),
ContextCompat.getColor(context, R.color.blue),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.approval_pending),
ContextCompat
.getColor(context, R.color.light_yellow),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.overpaid),
ContextCompat.getColor(context, R.color.purple),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.closed),
context.getThemeAttributeColor(R.attr.colorOnSurface),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.withdrawn),
context.getThemeAttributeColor(R.attr.colorOnSurfaceVariant),
),
)
return arrayList
}

fun getShareAccountStatusList(context: Context?): List<CheckboxStatus> {
val arrayList = ArrayList<CheckboxStatus>()
arrayList.add(
CheckboxStatus(
context?.getString(R.string.active),
ContextCompat.getColor(context!!, R.color.deposit_green),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.approved),
ContextCompat.getColor(context, R.color.light_green),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.approval_pending),
ContextCompat
.getColor(context, R.color.light_yellow),
),
)
arrayList.add(
CheckboxStatus(
context.getString(R.string.closed),
ContextCompat.getColor(context, R.color.light_blue),
),
)
return arrayList
}

fun getSavingsAccountTransactionList(context: Context?): List<CheckboxStatus> {
val arrayList = ArrayList<CheckboxStatus>()
arrayList.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mifos.mobile.models.client.ClientAccounts
import org.mifos.mobile.repositories.AccountsRepository
import org.mifos.mobile.repositories.HomeRepositoryImp
import org.mifos.mobile.ui.account.AccountsViewModel
import org.mifos.mobile.core.data.repositories.AccountsRepository
import org.mifos.mobile.core.data.repositories.HomeRepositoryImp
import org.mifos.mobile.core.model.entity.client.ClientAccounts
import org.mifos.mobile.feature.account.utils.AccountState
import org.mifos.mobile.feature.account.viewmodel.AccountsViewModel
import org.mifos.mobile.util.RxSchedulersOverrideRule
import org.mifos.mobile.utils.AccountsUiState
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mock
import org.mockito.Mockito
Expand Down Expand Up @@ -51,7 +51,10 @@ class AccountsViewModelTest {
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
accountsViewModel = AccountsViewModel(accountsRepositoryImp, homeRepositoryImp)
accountsViewModel = org.mifos.mobile.feature.account.viewmodel.AccountsViewModel(
accountsRepositoryImp,
homeRepositoryImp
)
mockClientAccounts = Mockito.mock(ClientAccounts::class.java)
}

Expand All @@ -61,15 +64,15 @@ class AccountsViewModelTest {
`when`(homeRepositoryImp.clientAccounts()).thenReturn(flowOf(mockClientAccounts))
accountsViewModel.accountsUiState.test {
accountsViewModel.loadClientAccounts()
assertEquals(AccountsUiState.Loading, awaitItem())
assertEquals(AccountState.Loading, awaitItem())
assertEquals(
AccountsUiState.ShowSavingsAccounts(mockClientAccounts.savingsAccounts), awaitItem()
AccountState.ShowSavingsAccounts(mockClientAccounts.savingsAccounts), awaitItem()
)
assertEquals(
AccountsUiState.ShowLoanAccounts(mockClientAccounts.loanAccounts), awaitItem()
AccountState.ShowLoanAccounts(mockClientAccounts.loanAccounts), awaitItem()
)
assertEquals(
AccountsUiState.ShowShareAccounts(mockClientAccounts.shareAccounts), awaitItem()
AccountState.ShowShareAccounts(mockClientAccounts.shareAccounts), awaitItem()
)
cancelAndIgnoreRemainingEvents()
}
Expand All @@ -86,9 +89,9 @@ class AccountsViewModelTest {
)
accountsViewModel.accountsUiState.test {
accountsViewModel.loadAccounts(mockAccountType)
assertEquals(AccountsUiState.Loading, awaitItem())
assertEquals(AccountState.Loading, awaitItem())
assertEquals(
AccountsUiState.ShowSavingsAccounts(mockClientAccounts.savingsAccounts), awaitItem()
AccountState.ShowSavingsAccounts(mockClientAccounts.savingsAccounts), awaitItem()
)
cancelAndIgnoreRemainingEvents()
}
Expand All @@ -101,9 +104,9 @@ class AccountsViewModelTest {
accountsViewModel.accountsUiState.test {
try {
accountsViewModel.loadAccounts(mockAccountType)
assertEquals(AccountsUiState.Loading, awaitItem())
assertEquals(AccountState.Loading, awaitItem())
} catch (e: RuntimeException) {
assertEquals(AccountsUiState.Error, awaitItem())
assertEquals(AccountState.Error, awaitItem())
}
cancelAndIgnoreRemainingEvents()
}
Expand Down
1 change: 1 addition & 0 deletions feature/account/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
22 changes: 22 additions & 0 deletions feature/account/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
}

android {
namespace = "org.mifos.mobile.feature.account"
}

dependencies {
implementation(projects.ui)
implementation(projects.core.common)
implementation(projects.core.model)
implementation(projects.core.data)
implementation(libs.reactivex.rxjava2.android)
implementation(libs.reactivex.rxjava2)
api(libs.androidx.compose.material)
implementation("com.github.rahul-gill.mifos-ui-library:uihouse:alpha-2.1")
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.espresso.core)
}
Empty file.
21 changes: 21 additions & 0 deletions feature/account/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.mifos.mobile.feature.client_charge

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.mifos.mobile.feature.client_charge.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions feature/account/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Loading

0 comments on commit 4af7c15

Please sign in to comment.