Skip to content

Commit

Permalink
# This is a combination of 9 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

refactor: openMF#2636 Use MaterialTheme colors for a uniform theme (openMF#2637)

# This is the commit message openMF#2:

refactor: savings module (openMF#2635)

# This is the commit message openMF#3:

refactor: qr module (openMF#2638)

# This is the commit message openMF#4:

A

migrate transfer process screen to compose screen openMF#2583 (openMF#2585)

refactor: qr code display migration (openMF#2609)

Migrate Beneficiary List from XML to compose (openMF#2607)

"Added MIfos Logo to RegistrationScreen" (openMF#2613)

* Added Image to RegistrationScreen

* "Added Image to RegistrationScreen"

Bug: Resolved Swipe Refresh Not Working in RecentTransaction Screen Compose (openMF#2617)

* "Resolved Swipe Refresh Not Working"

* Resolved Swipe Refresh Not Working

* Centered the Swipe Refresh And Added Padding

migrate saving accounts transaction screen to compose openMF#2588 (openMF#2596)

* migrate saving accounts transaction screen to compose openMF#2588

* Update SavingAccountsTransactionTopBar.kt

* init

* init

* refactor: savings accounts screen migration

* refactor: savings accounts screen migration

---------

Co-authored-by: Avneet Singh <avneetmaankiya@gmail.com>

fix#2615 Missing TopAppBar navigation back implementation in AddBeneficiaryScreen (openMF#2616)

fix#2610: Scrolling Disabled in TransferProcessFragment (openMF#2611)

fix#2610: Scrolling Disabled in TransferProcessFragment

fix#2610: Scrolling Disabled in TransferProcessFragment

Beneficiary application (openMF#2618)

Settings screen migration (openMF#2619)

refactor: Registration Module

# This is the commit message openMF#5:

refactor: Login module

# This is the commit message openMF#6:

refactor: Login module

# This is the commit message openMF#7:

refactor: Recent Login module

# This is the commit message openMF#8:

A

migrate transfer process screen to compose screen openMF#2583 (openMF#2585)

refactor: qr code display migration (openMF#2609)

Migrate Beneficiary List from XML to compose (openMF#2607)

"Added MIfos Logo to RegistrationScreen" (openMF#2613)

* Added Image to RegistrationScreen

* "Added Image to RegistrationScreen"

Bug: Resolved Swipe Refresh Not Working in RecentTransaction Screen Compose (openMF#2617)

* "Resolved Swipe Refresh Not Working"

* Resolved Swipe Refresh Not Working

* Centered the Swipe Refresh And Added Padding

migrate saving accounts transaction screen to compose openMF#2588 (openMF#2596)

* migrate saving accounts transaction screen to compose openMF#2588

* Update SavingAccountsTransactionTopBar.kt

* init

* init

* refactor: savings accounts screen migration

* refactor: savings accounts screen migration

---------

Co-authored-by: Avneet Singh <avneetmaankiya@gmail.com>

fix#2615 Missing TopAppBar navigation back implementation in AddBeneficiaryScreen (openMF#2616)

fix#2610: Scrolling Disabled in TransferProcessFragment (openMF#2611)

fix#2610: Scrolling Disabled in TransferProcessFragment

fix#2610: Scrolling Disabled in TransferProcessFragment

Beneficiary application (openMF#2618)

Settings screen migration (openMF#2619)

refactor: Registration Module

# This is the commit message openMF#9:

refactor: Login module

refactor: Login module

refactor: Recent Login module

refactor: transfer process module (openMF#2644)
  • Loading branch information
Shermine237 authored and akashmeruva9 committed Jul 5, 2024
1 parent 33ab709 commit d98e904
Show file tree
Hide file tree
Showing 128 changed files with 1,173 additions and 1,383 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ dependencies {
implementation(projects.core.datastore)
implementation(projects.ui)
implementation(projects.feature.loan)
implementation(projects.feature.login)
implementation(projects.feature.registration)
implementation(projects.feature.beneficiary)
implementation(projects.feature.guarantor)

implementation(projects.feature.savings)
implementation(projects.feature.qr)
implementation(projects.feature.transferProcess)

implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation(libs.androidx.lifecycle.ktx)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/mifos/mobile/ui/about/AboutUsHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun AboutUsHeader() {
Text(
text = stringResource(id = R.string.app_name),
style = MaterialTheme.typography.headlineMedium,
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
color = MaterialTheme.colorScheme.onSurface,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
Expand All @@ -43,7 +43,7 @@ fun AboutUsHeader() {
Text(
text = stringResource(id = R.string.about_app_description),
style = MaterialTheme.typography.titleSmall.copy(),
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
color = MaterialTheme.colorScheme.onSurface,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/org/mifos/mobile/ui/about/AboutUsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.ui.unit.dp
import org.mifos.mobile.core.model.enums.AboutUsListItemId
import org.mifos.mobile.core.ui.component.AboutUsItemCard
import org.mifos.mobile.core.ui.component.MifosItemCard
import org.mifos.mobile.core.ui.theme.MifosMobileTheme

@Composable
fun AboutUsScreen(viewModel: AboutUsViewModel) {
Expand Down Expand Up @@ -64,8 +65,10 @@ fun AboutUsScreen(viewModel: AboutUsViewModel) {

}

@Preview(showSystemUi = true, device = "id:pixel_5")
@Composable
@Preview
fun AboutScreenPreview() {
AboutUsScreen(AboutUsViewModel())
MifosMobileTheme {
AboutUsScreen(AboutUsViewModel())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.mifos.mobile.R
import org.mifos.mobile.databinding.ActivitySavingsAccountApplicationBinding
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.core.model.enums.SavingsAccountState
import org.mifos.mobile.ui.savings_account_application.SavingsAccountApplicationFragment.Companion.newInstance
import org.mifos.mobile.ui.savings_account.SavingsAccountApplicationFragment.Companion.newInstance

/*
* Created by saksham on 30/June/2018
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ import org.mifos.mobile.R
import org.mifos.mobile.core.ui.theme.MifosMobileTheme
import org.mifos.mobile.databinding.FragmentBeneficiaryAddOptionsBinding
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.ui.beneficiary_application.BeneficiaryApplicationComposeFragment
import org.mifos.mobile.core.model.enums.BeneficiaryState
import org.mifos.mobile.core.model.enums.RequestAccessType
import org.mifos.mobile.ui.fragments.base.BaseFragment
import org.mifos.mobile.ui.qr.QrCodeReaderFragment
import org.mifos.mobile.ui.qr_code_import.QrCodeImportComposeFragment
import org.mifos.mobile.ui.qr.QrCodeImportComposeFragment
import org.mifos.mobile.utils.CheckSelfPermissionAndRequest
import org.mifos.mobile.utils.CheckSelfPermissionAndRequest.checkSelfPermission
import org.mifos.mobile.utils.CheckSelfPermissionAndRequest.requestPermission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ fun ClientAccountsScreen(
1 -> openNextActivity(currentPage)
}
},
contentColor = if (isSystemInDarkTheme()) MaterialTheme.colorScheme.secondary
else MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.primary,
content = {
Icon(
imageVector = MifosIcons.Add,
contentDescription = "Create Account",
tint = if (isSystemInDarkTheme()) Color.Black else Color.White
tint = MaterialTheme.colorScheme.onSurface
)
}
),
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/mifos/mobile/ui/help/HelpScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fun HelpScreen(
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 8.dp),
style = MaterialTheme.typography.titleMedium,
color = if (isSystemInDarkTheme()) Color.White else Color.Black
color = MaterialTheme.colorScheme.onSurface
)

if (!faqArrayList.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.mifos.mobile.ui.client_charge.ClientChargeComposeFragment
import org.mifos.mobile.core.model.enums.AccountType
import org.mifos.mobile.core.model.enums.ChargeType
import org.mifos.mobile.ui.fragments.base.BaseFragment
import org.mifos.mobile.ui.savings_make_transfer.SavingsMakeTransferComposeFragment
import org.mifos.mobile.ui.savings_account.SavingsMakeTransferComposeFragment
import org.mifos.mobile.ui.third_party_transfer.ThirdPartyTransferComposeFragment
import org.mifos.mobile.ui.user_profile.UserProfileActivity
import org.mifos.mobile.core.datastore.PreferencesHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import org.mifos.mobile.ui.loan_account_transaction.LoanAccountTransactionFragme
import org.mifos.mobile.ui.loan_account_withdraw.LoanAccountWithdrawFragment
import org.mifos.mobile.ui.loan_account_application.LoanApplicationFragment
import org.mifos.mobile.ui.loan_repayment_schedule.LoanRepaymentScheduleFragment
import org.mifos.mobile.ui.savings_make_transfer.SavingsMakeTransferFragment
import org.mifos.mobile.ui.fragments.base.BaseFragment
import org.mifos.mobile.ui.loan_account_summary.LoanAccountSummaryFragment
import org.mifos.mobile.ui.qr_code_display.QrCodeDisplayComposeFragment
import org.mifos.mobile.ui.savings_make_transfer.SavingsMakeTransferComposeFragment
import org.mifos.mobile.ui.qr.QrCodeDisplayComposeFragment
import org.mifos.mobile.ui.savings_account.SavingsMakeTransferComposeFragment
import org.mifos.mobile.utils.*
import javax.inject.Inject

Expand Down Expand Up @@ -154,7 +153,7 @@ class LoanAccountsDetailFragment : BaseFragment() {
}

private fun onQrCodeClicked() {
val accountDetailsInJson = QrCodeGenerator.getAccountDetailsInString(
val accountDetailsInJson = org.mifos.mobile.feature.qr.utils.QrCodeGenerator.getAccountDetailsInString(
viewModel.loanWithAssociations?.accountNo,
preferencesHelper.officeName,
AccountType.LOAN,
Expand Down
187 changes: 8 additions & 179 deletions app/src/main/java/org/mifos/mobile/ui/login/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@ package org.mifos.mobile.ui.login

import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import org.mifos.mobile.MifosSelfServiceApp.Companion.context
import org.mifos.mobile.R
import org.mifos.mobile.core.ui.theme.MifosMobileTheme
import org.mifos.mobile.feature.login.screens.LoginScreen
import org.mifos.mobile.ui.activities.PassCodeActivity
import org.mifos.mobile.ui.registration.RegistrationActivity
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.utils.LoginUiState
import org.mifos.mobile.core.common.Network

/**
* @author Vishwajeet
Expand All @@ -26,189 +17,26 @@ import org.mifos.mobile.core.common.Network
@AndroidEntryPoint
class LoginActivity : BaseActivity() {

private val viewModel: LoginViewModel by viewModels()

private lateinit var usernameContent: String
private lateinit var passwordContent: String
// private val viewModel: LoginViewModel by viewModels()
// private lateinit var usernameContent: String
// private lateinit var passwordContent: String

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MifosMobileTheme {

LoginScreen(
login = { username, password ->
usernameContent = username
passwordContent = password
onLoginClicked()
},
createAccount = { onRegisterClicked() },
getUsernameError = { validateUsername(it) },
getPasswordError = { validatePassword(it) }
startRegisterActivity = { onRegisterClicked() },
startPassCodeActivity = { startPassCodeActivity() },
)
}
}

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.loginUiState.collect { state ->
when (state) {
LoginUiState.Loading -> showProgress()

LoginUiState.Error -> {
hideProgress()
showMessage(context?.getString(R.string.login_failed))
}

LoginUiState.LoginSuccess -> {
onLoginSuccess()
}

is LoginUiState.LoadClientSuccess -> {
hideProgress()
showPassCodeActivity(state.clientName)
}

LoginUiState.Initial -> {}
}
}
}
}
}

/**
* Called when Login is user has successfully logged in
*/
private fun onLoginSuccess() {
viewModel.loadClient()
}

/**
* Shows ProgressDialog when called
*/
private fun showProgress() {
showProgressDialog(getString(R.string.progress_message_login))
}

/**
* Hides the progressDialog which is being shown
*/
private fun hideProgress() {
hideProgressDialog()
}

/**
* Starts [PassCodeActivity]
*/
private fun showPassCodeActivity(clientName: String?) {
showToast(getString(R.string.toast_welcome, clientName))
startPassCodeActivity()
}

/**
* It is called whenever any error occurs while executing a request
*
* @param errorMessage Error message that tells the user about the problem.
*/
private fun showMessage(errorMessage: String?) {
showToast(errorMessage!!, Toast.LENGTH_LONG)
}

/**
* Called when Login Button is clicked, used for logging in the user
*/

private fun onLoginClicked() {
if (Network.isConnected(this)) {
if (isCredentialsValid(usernameContent, passwordContent))
viewModel.login(usernameContent, passwordContent)
} else {
showMessage(context?.getString(R.string.no_internet_connection))
}
}

private fun isCredentialsValid(username: String, password: String): Boolean {
var credentialValid = true
when {
viewModel.isFieldEmpty(username) -> {
credentialValid = false
}

viewModel.isUsernameLengthInadequate(username) -> {
credentialValid = false
}

viewModel.usernameHasSpaces(username) -> {
credentialValid = false
}
}

when {
viewModel.isFieldEmpty(password) -> {
credentialValid = false
}

viewModel.isPasswordLengthInadequate(password) -> {
credentialValid = false
}
}
return credentialValid
}

private fun validateUsername(username: String): String {
var usernameError = ""
when {
viewModel.isFieldEmpty(username) -> {
usernameError = context?.getString(
R.string.error_validation_blank,
context?.getString(R.string.username),
).toString()
}

viewModel.isUsernameLengthInadequate(username) -> {
usernameError = context?.getString(
R.string.error_validation_minimum_chars,
resources?.getString(R.string.username),
resources?.getInteger(R.integer.username_minimum_length),
).toString()
}

viewModel.usernameHasSpaces(username) -> {
usernameError = context?.getString(
R.string.error_validation_cannot_contain_spaces,
resources?.getString(R.string.username),
context?.getString(R.string.not_contain_username),
).toString()
}
}
return usernameError
}

private fun validatePassword(password: String): String {
var passwordError = ""
when {
viewModel.isFieldEmpty(password) -> {
passwordError = context?.getString(
R.string.error_validation_blank,
context?.getString(R.string.password),
).toString()

}

viewModel.isPasswordLengthInadequate(password) -> {
passwordError = context?.getString(
R.string.error_validation_minimum_chars,
resources?.getString(R.string.password),
resources?.getInteger(R.integer.password_minimum_length),
).toString()
}
}
return passwordError
}

private fun onRegisterClicked() {
startActivity(Intent(this@LoginActivity, RegistrationActivity::class.java))
}

/**
* Starts [PassCodeActivity] with `Constans.INTIAL_LOGIN` as true
*/
Expand All @@ -219,4 +47,5 @@ class LoginActivity : BaseActivity() {
startActivity(intent)
finish()
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mifos.mobile.ui.qr_code_display
package org.mifos.mobile.ui.qr

import android.os.Bundle
import android.view.LayoutInflater
Expand All @@ -10,6 +10,8 @@ import org.mifos.mobile.core.ui.component.mifosComposeView
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.ui.fragments.base.BaseFragment
import org.mifos.mobile.core.common.Constants
import org.mifos.mobile.feature.qr.qr_code_display.QrCodeDisplayScreen
import org.mifos.mobile.feature.qr.qr_code_display.QrCodeDisplayViewModel

@AndroidEntryPoint
class QrCodeDisplayComposeFragment : BaseFragment() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mifos.mobile.ui.qr_code_import
package org.mifos.mobile.ui.qr

import android.os.Build
import android.os.Bundle
Expand All @@ -19,6 +19,7 @@ import org.mifos.mobile.core.model.enums.BeneficiaryState
import org.mifos.mobile.ui.fragments.base.BaseFragment
import com.google.zxing.Result
import org.mifos.mobile.core.model.entity.beneficiary.Beneficiary
import org.mifos.mobile.ui.qr_code_import.QrCodeImportScreen

@AndroidEntryPoint
class QrCodeImportComposeFragment : BaseFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.mifos.mobile.core.model.entity.beneficiary.Beneficiary
import org.mifos.mobile.core.ui.component.mifosComposeView
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.core.model.enums.BeneficiaryState
import org.mifos.mobile.feature.qr.qr.QrCodeReaderScreen
import org.mifos.mobile.ui.beneficiary_application.BeneficiaryApplicationComposeFragment
import org.mifos.mobile.ui.fragments.base.BaseFragment

Expand Down
Loading

0 comments on commit d98e904

Please sign in to comment.