diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index e46b1fc8d..09a5ce39a 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -94,6 +94,7 @@ dependencies {
implementation(projects.feature.location)
implementation(projects.feature.about)
implementation(projects.feature.settings)
+ implementation(projects.feature.updatePassword)
implementation("androidx.legacy:legacy-support-v4:1.0.0")
diff --git a/app/src/main/java/org/mifos/mobile/ui/qr/QrCodeImportComposeFragment.kt b/app/src/main/java/org/mifos/mobile/ui/qr/QrCodeImportComposeFragment.kt
index db67daf61..99e575b1b 100644
--- a/app/src/main/java/org/mifos/mobile/ui/qr/QrCodeImportComposeFragment.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/qr/QrCodeImportComposeFragment.kt
@@ -19,7 +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
+import org.mifos.mobile.feature.qr.qr_code_import.QrCodeImportScreen
@AndroidEntryPoint
class QrCodeImportComposeFragment : BaseFragment() {
diff --git a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordFragment.kt b/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordFragment.kt
index 46f78a54e..c146c050f 100644
--- a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordFragment.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordFragment.kt
@@ -4,10 +4,9 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.ui.platform.ComposeView
-import androidx.compose.ui.platform.ViewCompositionStrategy
import dagger.hilt.android.AndroidEntryPoint
-import org.mifos.mobile.core.ui.theme.MifosMobileTheme
+import org.mifos.mobile.core.ui.component.mifosComposeView
+import org.mifos.mobile.feature.update_password.UpdatePasswordScreen
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.ui.fragments.base.BaseFragment
@@ -22,17 +21,12 @@ class UpdatePasswordFragment : BaseFragment() {
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
- return ComposeView(requireContext()).apply {
- setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
- setContent {
- MifosMobileTheme {
- UpdatePasswordScreen(
- navigateBack = {
- requireActivity().onBackPressedDispatcher.onBackPressed()
- }
- )
+ return mifosComposeView(requireContext()) {
+ UpdatePasswordScreen(
+ navigateBack = {
+ requireActivity().onBackPressedDispatcher.onBackPressed()
}
- }
+ )
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d12f2c173..22efeb4f0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -158,9 +158,6 @@
Change Passcode
Change App Passcode
Change Password
- Change your Account Password
- Current Password
- New Password
%1$s changed successfully
Account should to be Active to perform a
@@ -630,7 +627,6 @@
App Info
Login Failed, Please Try Again Later.
- We were unable to update password.
Password changed successfully
We were unable to register the user.
No Questions Found
diff --git a/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt
index ef8491737..98313c568 100644
--- a/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt
+++ b/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt
@@ -12,7 +12,7 @@ import org.junit.*
import org.junit.runner.RunWith
import org.mifos.mobile.core.data.repositories.ClientRepository
import org.mifos.mobile.core.data.repositories.UserAuthRepository
-import org.mifos.mobile.ui.update_password.UpdatePasswordViewModel
+import org.mifos.mobile.feature.update_password.UpdatePasswordViewModel
import org.mifos.mobile.util.RxSchedulersOverrideRule
import org.mifos.mobile.feature.registration.utils.RegistrationState
import org.mockito.Mock
@@ -40,13 +40,16 @@ class UpdatePasswordViewModelTest {
@Mock
lateinit var clientRepositoryImp: ClientRepository
- private lateinit var updatePasswordViewModel: UpdatePasswordViewModel
+ private lateinit var updatePasswordViewModel: org.mifos.mobile.feature.update_password.UpdatePasswordViewModel
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
updatePasswordViewModel =
- UpdatePasswordViewModel(userAuthRepositoryImp, clientRepositoryImp)
+ org.mifos.mobile.feature.update_password.UpdatePasswordViewModel(
+ userAuthRepositoryImp,
+ clientRepositoryImp
+ )
}
@Test
diff --git a/feature/about/src/main/res/drawable/ic_source_code.xml b/feature/about/src/main/res/drawable/ic_source_code.xml
index 70566570b..11838b8a2 100644
--- a/feature/about/src/main/res/drawable/ic_source_code.xml
+++ b/feature/about/src/main/res/drawable/ic_source_code.xml
@@ -6,7 +6,7 @@
android:viewportWidth="48"
android:viewportHeight="48">
\ No newline at end of file
diff --git a/feature/about/src/main/res/drawable/ic_website.xml b/feature/about/src/main/res/drawable/ic_website.xml
index 097fc1bde..13432f78e 100644
--- a/feature/about/src/main/res/drawable/ic_website.xml
+++ b/feature/about/src/main/res/drawable/ic_website.xml
@@ -6,6 +6,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
diff --git a/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportScreen.kt b/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportScreen.kt
index dc3acef3f..0fb9ca278 100644
--- a/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportScreen.kt
+++ b/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportScreen.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.qr_code_import
+package org.mifos.mobile.feature.qr.qr_code_import
import android.Manifest
import android.graphics.Bitmap
@@ -43,8 +43,6 @@ import org.mifos.mobile.core.ui.component.MFScaffold
import org.mifos.mobile.core.ui.component.MifosErrorComponent
import org.mifos.mobile.core.ui.component.MifosProgressIndicatorOverlay
import org.mifos.mobile.feature.qr.R
-import org.mifos.mobile.feature.qr.qr_code_import.PermissionBox
-import org.mifos.mobile.feature.qr.qr_code_import.convertToMutableBitmap
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@Composable
diff --git a/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportViewModel.kt b/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportViewModel.kt
index c76e0199a..f2839308a 100644
--- a/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportViewModel.kt
+++ b/feature/qr/src/main/java/org/mifos/mobile/feature/qr/qr_code_import/QrCodeImportViewModel.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.qr_code_import
+package org.mifos.mobile.feature.qr.qr_code_import
import android.graphics.Bitmap
import androidx.lifecycle.ViewModel
diff --git a/feature/update-password/.gitignore b/feature/update-password/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/feature/update-password/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/feature/update-password/build.gradle.kts b/feature/update-password/build.gradle.kts
new file mode 100644
index 000000000..ed0d02665
--- /dev/null
+++ b/feature/update-password/build.gradle.kts
@@ -0,0 +1,20 @@
+plugins {
+ alias(libs.plugins.mifos.android.feature)
+ alias(libs.plugins.mifos.android.library.compose)
+}
+
+
+android {
+ namespace = "org.mifos.mobile.feature.update.password"
+}
+
+dependencies {
+ implementation(projects.ui)
+ implementation(projects.core.common)
+ implementation(projects.core.model)
+ implementation(projects.core.data)
+
+ testImplementation(libs.junit)
+ androidTestImplementation(libs.androidx.test.ext.junit)
+ androidTestImplementation(libs.espresso.core)
+}
\ No newline at end of file
diff --git a/feature/update-password/consumer-rules.pro b/feature/update-password/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/feature/update-password/proguard-rules.pro b/feature/update-password/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/feature/update-password/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/feature/update-password/src/androidTest/java/org/mifos/mobile/feature/update_password/ExampleInstrumentedTest.kt b/feature/update-password/src/androidTest/java/org/mifos/mobile/feature/update_password/ExampleInstrumentedTest.kt
new file mode 100644
index 000000000..2894fdb41
--- /dev/null
+++ b/feature/update-password/src/androidTest/java/org/mifos/mobile/feature/update_password/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package org.mifos.mobile.feature.update_password
+
+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.update_password.test", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/feature/update-password/src/main/AndroidManifest.xml b/feature/update-password/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..a5918e68a
--- /dev/null
+++ b/feature/update-password/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordContent.kt b/feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordContent.kt
similarity index 97%
rename from app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordContent.kt
rename to feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordContent.kt
index 654846ebf..6aab47370 100644
--- a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordContent.kt
+++ b/feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordContent.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.update_password
+package org.mifos.mobile.feature.update_password
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
@@ -22,7 +22,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
-import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
@@ -33,10 +32,9 @@ import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
-import org.mifos.mobile.R
import org.mifos.mobile.core.ui.component.MifosOutlinedTextField
+import org.mifos.mobile.feature.update.password.R
-@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun UpdatePasswordContent(
viewModel: UpdatePasswordViewModel = hiltViewModel(),
diff --git a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordScreen.kt b/feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordScreen.kt
similarity index 88%
rename from app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordScreen.kt
rename to feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordScreen.kt
index 4ed9ef641..c1a43831b 100644
--- a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordScreen.kt
+++ b/feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordScreen.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.update_password
+package org.mifos.mobile.feature.update_password
import android.content.Context
import android.widget.Toast
@@ -23,15 +23,14 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
+import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
-import org.mifos.mobile.R
import org.mifos.mobile.core.ui.component.MifosProgressIndicator
import org.mifos.mobile.core.ui.component.MifosTopBar
import org.mifos.mobile.core.ui.theme.MifosMobileTheme
import org.mifos.mobile.core.common.Network
-import org.mifos.mobile.feature.savings.savings_account_withdraw.UiStatesParameterProvider
-import org.mifos.mobile.feature.registration.utils.RegistrationState
+import org.mifos.mobile.feature.update.password.R
@Composable
@@ -49,7 +48,7 @@ fun UpdatePasswordScreen(
@Composable
fun UpdatePasswordScreen(
- uiState: RegistrationState,
+ uiState: UpdatePasswordUiState,
navigateBack: () -> Unit
) {
val context = LocalContext.current
@@ -76,7 +75,7 @@ fun UpdatePasswordScreen(
)
when (uiState) {
- is RegistrationState.Loading -> {
+ is UpdatePasswordUiState.Loading -> {
MifosProgressIndicator(
modifier = Modifier
.fillMaxSize()
@@ -84,7 +83,7 @@ fun UpdatePasswordScreen(
)
}
- is RegistrationState.Error -> {
+ is UpdatePasswordUiState.Error -> {
if (updatePasswordButtonClicked) {
LaunchedEffect(snackbarHostState) {
snackbarHostState.showSnackbar(
@@ -96,9 +95,9 @@ fun UpdatePasswordScreen(
}
}
- is RegistrationState.Initial -> Unit
+ is UpdatePasswordUiState.Initial -> Unit
- is RegistrationState.Success -> {
+ is UpdatePasswordUiState.Success -> {
LaunchedEffect(snackbarHostState) {
snackbarHostState.showSnackbar(
context.getString(R.string.password_changed_successfully),
@@ -113,10 +112,20 @@ fun UpdatePasswordScreen(
}
}
+class UiStatesParameterProvider : PreviewParameterProvider {
+ override val values: Sequence
+ get() = sequenceOf(
+ UpdatePasswordUiState.Initial,
+ UpdatePasswordUiState.Error(1),
+ UpdatePasswordUiState.Loading,
+ UpdatePasswordUiState.Success
+ )
+}
+
@Composable
@Preview(showSystemUi = true, showBackground = true)
fun UpdatePasswordScreenPreview(
- @PreviewParameter(UiStatesParameterProvider::class) registrationUiState: RegistrationState
+ @PreviewParameter(UiStatesParameterProvider::class) updatePasswordUiState: UpdatePasswordUiState
) {
MifosMobileTheme {
UpdatePasswordScreen(navigateBack = {})
diff --git a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordViewModel.kt b/feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordViewModel.kt
similarity index 56%
rename from app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordViewModel.kt
rename to feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordViewModel.kt
index bc2b72209..94c7bd1e5 100644
--- a/app/src/main/java/org/mifos/mobile/ui/update_password/UpdatePasswordViewModel.kt
+++ b/feature/update-password/src/main/java/org/mifos/mobile/feature/update_password/UpdatePasswordViewModel.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.update_password
+package org.mifos.mobile.feature.update_password
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@@ -7,10 +7,9 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.launch
-import org.mifos.mobile.R
import org.mifos.mobile.core.data.repositories.ClientRepository
import org.mifos.mobile.core.data.repositories.UserAuthRepository
-import org.mifos.mobile.feature.registration.utils.RegistrationState
+import org.mifos.mobile.feature.update.password.R
import javax.inject.Inject
@HiltViewModel
@@ -19,19 +18,27 @@ class UpdatePasswordViewModel @Inject constructor(
private val clientRepositoryImp: ClientRepository,
) : ViewModel() {
- private val _updatePasswordUiState = MutableStateFlow(RegistrationState.Initial)
- val updatePasswordUiState: StateFlow get() = _updatePasswordUiState
+ private val _updatePasswordUiState = MutableStateFlow(UpdatePasswordUiState.Initial)
+ val updatePasswordUiState: StateFlow get() = _updatePasswordUiState
fun updateAccountPassword(newPassword: String, confirmPassword: String) {
viewModelScope.launch {
- _updatePasswordUiState.value = RegistrationState.Loading
+ _updatePasswordUiState.value = UpdatePasswordUiState.Loading
userAuthRepositoryImp.updateAccountPassword(newPassword, confirmPassword).catch {
_updatePasswordUiState.value =
- RegistrationState.Error(R.string.could_not_update_password_error)
+ UpdatePasswordUiState.Error(R.string.could_not_update_password_error)
}.collect {
- _updatePasswordUiState.value = RegistrationState.Success
+ _updatePasswordUiState.value = UpdatePasswordUiState.Success
clientRepositoryImp.updateAuthenticationToken(newPassword)
}
}
}
}
+
+
+sealed class UpdatePasswordUiState {
+ data class Error(val exception: Int) : UpdatePasswordUiState()
+ data object Success : UpdatePasswordUiState()
+ data object Loading : UpdatePasswordUiState()
+ data object Initial: UpdatePasswordUiState()
+}
\ No newline at end of file
diff --git a/feature/update-password/src/main/res/drawable/ic_lock_black_24dp.xml b/feature/update-password/src/main/res/drawable/ic_lock_black_24dp.xml
new file mode 100644
index 000000000..54a852060
--- /dev/null
+++ b/feature/update-password/src/main/res/drawable/ic_lock_black_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/feature/update-password/src/main/res/ic_lock_black_24dp.xml b/feature/update-password/src/main/res/ic_lock_black_24dp.xml
new file mode 100644
index 000000000..e69de29bb
diff --git a/feature/update-password/src/main/res/values/strings.xml b/feature/update-password/src/main/res/values/strings.xml
new file mode 100644
index 000000000..dd0ff9e54
--- /dev/null
+++ b/feature/update-password/src/main/res/values/strings.xml
@@ -0,0 +1,18 @@
+
+
+ We were unable to update password.
+ Change your Account Password
+ Current Password
+ New Password
+ %1$s changed successfully
+ Change Password
+ Confirm Password
+ %1$s cannot be blank
+ %1$s cannot be less than %2$d characters
+ OK
+ Password changed successfully
+ 6
+ No Internet Connection
+ Password does not match.
+
+
\ No newline at end of file
diff --git a/feature/update-password/src/test/java/org/mifos/mobile/feature/update_password/ExampleUnitTest.kt b/feature/update-password/src/test/java/org/mifos/mobile/feature/update_password/ExampleUnitTest.kt
new file mode 100644
index 000000000..4eec58f73
--- /dev/null
+++ b/feature/update-password/src/test/java/org/mifos/mobile/feature/update_password/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package org.mifos.mobile.feature.update_password
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 59ea5538b..f700820bd 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -45,3 +45,4 @@ include(":feature:notification")
include(":feature:location")
include(":feature:about")
include(":feature:settings")
+include(":feature:update-password")