From 39f9fd401c0896542c7ac1dac4718bd017e79764 Mon Sep 17 00:00:00 2001 From: Aditya Gupta <94394661+Aditya-gupta99@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:24:36 +0530 Subject: [PATCH] feat: Implement compose navigation on splash , auth, passcode module (#2194) --- .../com/mifos/core/common/utils/Constants.kt | 1 + .../mifos/core/designsystem/theme/Color.kt | 3 +- .../login/{presentation => }/LoginScreen.kt | 2 +- .../login/{presentation => }/LoginUiState.kt | 2 +- .../{presentation => }/LoginViewModel.kt | 2 +- .../feature/auth/navigation/AuthNavigation.kt | 45 ++++++++++ .../feature/auth/navigation/AuthScreens.kt | 9 ++ feature/passcode/.gitignore | 1 + feature/passcode/build.gradle.kts | 25 ++++++ feature/passcode/consumer-rules.pro | 0 feature/passcode/proguard-rules.pro | 21 +++++ .../passcode/ExampleInstrumentedTest.kt | 24 ++++++ feature/passcode/src/main/AndroidManifest.xml | 4 + .../passcode/navigation/PasscodeNavigation.kt | 38 +++++++++ .../passcode/navigation/PasscodeScreens.kt | 7 ++ .../passcode/passcode/PasscodeScreen.kt | 44 ++++++++++ .../passcode/passcode/PasscodeViewmodel.kt | 17 ++++ .../mifos/feature/passcode/ExampleUnitTest.kt | 17 ++++ feature/splash/.gitignore | 1 + feature/splash/build.gradle.kts | 23 ++++++ feature/splash/consumer-rules.pro | 0 feature/splash/proguard-rules.pro | 21 +++++ .../feature/splash/ExampleInstrumentedTest.kt | 24 ++++++ feature/splash/src/main/AndroidManifest.xml | 4 + .../splash/navigation/SplashNavigation.kt | 35 ++++++++ .../splash/navigation/SplashScreens.kt | 9 ++ .../feature/splash/splash/SplashScreen.kt | 77 ++++++++++++++++++ .../splash/splash/SplashScreenViewmodel.kt | 32 ++++++++ .../main/res/drawable/feature_splash_icon.png | Bin 0 -> 2834 bytes .../mifos/feature/splash/ExampleUnitTest.kt | 17 ++++ mifosng-android/build.gradle.kts | 2 + mifosng-android/src/main/AndroidManifest.xml | 10 +-- .../com/mifos/mifosxdroid/AndroidClient.kt | 41 ++++++++++ ...rdActivity.kt => AndroidClientActivity.kt} | 4 +- .../activity/login/LoginActivity.kt | 6 +- .../splashscreen/SplashScreenActivity.kt | 36 -------- .../mifosxdroid/core/MifosBaseActivity.kt | 4 +- .../HomeNavigation.kt} | 34 +++++++- .../mifosxdroid/navigation/HomeScreens.kt | 7 ++ .../mifosxdroid/passcode/PassCodeActivity.kt | 8 +- settings.gradle.kts | 2 + 41 files changed, 595 insertions(+), 64 deletions(-) rename feature/auth/src/main/java/com/mifos/feature/auth/login/{presentation => }/LoginScreen.kt (99%) rename feature/auth/src/main/java/com/mifos/feature/auth/login/{presentation => }/LoginUiState.kt (90%) rename feature/auth/src/main/java/com/mifos/feature/auth/login/{presentation => }/LoginViewModel.kt (98%) create mode 100644 feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt create mode 100644 feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt create mode 100644 feature/passcode/.gitignore create mode 100644 feature/passcode/build.gradle.kts create mode 100644 feature/passcode/consumer-rules.pro create mode 100644 feature/passcode/proguard-rules.pro create mode 100644 feature/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt create mode 100644 feature/passcode/src/main/AndroidManifest.xml create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt create mode 100644 feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt create mode 100644 feature/splash/.gitignore create mode 100644 feature/splash/build.gradle.kts create mode 100644 feature/splash/consumer-rules.pro create mode 100644 feature/splash/proguard-rules.pro create mode 100644 feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt create mode 100644 feature/splash/src/main/AndroidManifest.xml create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt create mode 100644 feature/splash/src/main/res/drawable/feature_splash_icon.png create mode 100644 feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt create mode 100644 mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt rename mifosng-android/src/main/java/com/mifos/mifosxdroid/{DashboardActivity.kt => AndroidClientActivity.kt} (81%) delete mode 100644 mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt rename mifosng-android/src/main/java/com/mifos/mifosxdroid/{AndroidClientApp.kt => navigation/HomeNavigation.kt} (92%) create mode 100644 mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt diff --git a/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt b/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt index c456a11a48e..bc86777a765 100644 --- a/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt +++ b/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt @@ -216,4 +216,5 @@ object Constants { const val REPORT_TYPE_ITEM = "report_type_item" const val REPORT_PARAMETER_RESPONSE = "report_parameter_response" const val LOAN_WITH_ASSOCIATIONS = "loanWithAssociation" + const val PASSCODE_INITIAL_LOGIN = "passcode_initial_login" } \ No newline at end of file diff --git a/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt b/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt index 8575c31bfed..34932289d9b 100644 --- a/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt +++ b/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt @@ -9,4 +9,5 @@ val LightGray = Color(0xFFD3D3D3) val BluePrimary = Color(0xFF2D5BA8) val BluePrimaryDark = Color(0xFF9BB1E3) val BlueSecondary = Color(0xFFD7E2FC) -val LightGreen = Color(0xFF99CC00) \ No newline at end of file +val LightGreen = Color(0xFF99CC00) +val SummerSky = Color(0xFF29B6F6) \ No newline at end of file diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginScreen.kt b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginScreen.kt similarity index 99% rename from feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginScreen.kt rename to feature/auth/src/main/java/com/mifos/feature/auth/login/LoginScreen.kt index 63f753236d4..08d80f378a1 100644 --- a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginScreen.kt +++ b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginScreen.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.auth.login.presentation +package com.mifos.feature.auth.login import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginUiState.kt b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginUiState.kt similarity index 90% rename from feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginUiState.kt rename to feature/auth/src/main/java/com/mifos/feature/auth/login/LoginUiState.kt index fdb409b0c37..48b5c57ad7b 100644 --- a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginUiState.kt +++ b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginUiState.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.auth.login.presentation +package com.mifos.feature.auth.login /** * Created by Aditya Gupta on 06/08/23. diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginViewModel.kt b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt similarity index 98% rename from feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginViewModel.kt rename to feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt index 65e7ef2c556..3217fec6cc2 100644 --- a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginViewModel.kt +++ b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.auth.login.presentation +package com.mifos.feature.auth.login import android.content.Context import androidx.lifecycle.ViewModel diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt new file mode 100644 index 00000000000..d72e070a583 --- /dev/null +++ b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt @@ -0,0 +1,45 @@ +package com.mifos.feature.auth.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import androidx.navigation.navigation +import com.mifos.feature.auth.login.LoginScreen + +fun NavGraphBuilder.authNavGraph( + navigateHome: () -> Unit, + navigatePasscode: () -> Unit, + updateServerConfig: () -> Unit +) { + navigation( + startDestination = AuthScreens.LoginScreen.route, + route = AuthScreens.LoginScreenRoute.route + ) { + loginRoute( + navigatePasscode = navigatePasscode, + navigateHome = navigateHome, + updateServerConfig = updateServerConfig + ) + } + +} + +fun NavGraphBuilder.loginRoute( + navigateHome: () -> Unit, + navigatePasscode: () -> Unit, + updateServerConfig: () -> Unit +) { + composable( + route = AuthScreens.LoginScreen.route + ) { + LoginScreen( + homeIntent = navigateHome, + passcodeIntent = navigatePasscode, + onClickToUpdateServerConfig = updateServerConfig + ) + } +} + +fun NavController.navigateToLogin() { + navigate(AuthScreens.LoginScreen.route) +} \ No newline at end of file diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt new file mode 100644 index 00000000000..d64d4948e74 --- /dev/null +++ b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt @@ -0,0 +1,9 @@ +package com.mifos.feature.auth.navigation + +sealed class AuthScreens(val route: String) { + + data object LoginScreenRoute : AuthScreens("login_screen_route") + + data object LoginScreen : AuthScreens("login_screen") + +} \ No newline at end of file diff --git a/feature/passcode/.gitignore b/feature/passcode/.gitignore new file mode 100644 index 00000000000..42afabfd2ab --- /dev/null +++ b/feature/passcode/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/passcode/build.gradle.kts b/feature/passcode/build.gradle.kts new file mode 100644 index 00000000000..f3e8f90b5af --- /dev/null +++ b/feature/passcode/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + alias(libs.plugins.mifos.android.feature) + alias(libs.plugins.mifos.android.library.compose) + alias(libs.plugins.mifos.android.library.jacoco) +} + +android { + namespace = "com.mifos.feature.passcode" +} + +dependencies { + implementation(projects.core.domain) + + //DBFlow dependencies + kapt(libs.dbflow.processor) + implementation(libs.dbflow) + kapt(libs.github.dbflow.processor) + testImplementation(libs.hilt.android.testing) + testImplementation(projects.core.testing) + + androidTestImplementation(projects.core.testing) + + // passcode dependency + implementation("com.github.openMF.mifos-passcode:compose:1.0.3") +} \ No newline at end of file diff --git a/feature/passcode/consumer-rules.pro b/feature/passcode/consumer-rules.pro new file mode 100644 index 00000000000..e69de29bb2d diff --git a/feature/passcode/proguard-rules.pro b/feature/passcode/proguard-rules.pro new file mode 100644 index 00000000000..481bb434814 --- /dev/null +++ b/feature/passcode/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/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt b/feature/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt new file mode 100644 index 00000000000..73c1fc6f9b2 --- /dev/null +++ b/feature/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.mifos.feature.passcode + +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("com.mifos.feature.passcode.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/feature/passcode/src/main/AndroidManifest.xml b/feature/passcode/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..a5918e68abc --- /dev/null +++ b/feature/passcode/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + +</manifest> \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt new file mode 100644 index 00000000000..72562661abb --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt @@ -0,0 +1,38 @@ +package com.mifos.feature.passcode.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavType +import androidx.navigation.compose.composable +import androidx.navigation.navArgument +import androidx.navigation.navigation +import com.mifos.core.common.utils.Constants +import com.mifos.feature.passcode.passcode.PasscodeScreen + +fun NavGraphBuilder.passcodeNavGraph( + navController: NavController +) { + navigation( + startDestination = PasscodeScreens.PasscodeScreen.route, + route = "passcode_screen_route" + ) { + passcodeScreenRoute() + } +} + +fun NavGraphBuilder.passcodeScreenRoute( + +) { + composable( + route = PasscodeScreens.PasscodeScreen.route, + arguments = listOf( + navArgument( + name = Constants.PASSCODE_INITIAL_LOGIN, + builder = { type = NavType.BoolType }) + ) + ) { + PasscodeScreen( + + ) + } +} \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt new file mode 100644 index 00000000000..35656df6ba4 --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt @@ -0,0 +1,7 @@ +package com.mifos.feature.passcode.navigation + +sealed class PasscodeScreens(val route: String) { + + data object PasscodeScreen : PasscodeScreens("passcode_screen") + +} \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt new file mode 100644 index 00000000000..8b8dd7cd27c --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt @@ -0,0 +1,44 @@ +package com.mifos.feature.passcode.passcode + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.mifos.core.designsystem.component.MifosScaffold + +@Composable +fun PasscodeScreen( + viewmodel: PasscodeViewmodel = hiltViewModel() +) { + + val passcodeStatus by viewmodel.passcodeStatus.collectAsStateWithLifecycle() + + +} + +@Composable +fun PasscodeScreen( + +) { + + MifosScaffold { paddingValues -> + Column(modifier = Modifier.padding(paddingValues)) { + com.mifos.compose.component.PasscodeScreen( + onForgotButton = { }, + onSkipButton = { }, + onPasscodeConfirm = { }, + onPasscodeRejected = { } + ) + } + } +} + +@Preview +@Composable +private fun PasscodeScreenPreview() { + PasscodeScreen() +} \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt new file mode 100644 index 00000000000..3d8e63b537e --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt @@ -0,0 +1,17 @@ +package com.mifos.feature.passcode.passcode + +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.ViewModel +import com.mifos.core.common.utils.Constants +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class PasscodeViewmodel @Inject constructor( + private val savedStateHandle: SavedStateHandle +) : ViewModel() { + + val passcodeStatus = + savedStateHandle.getStateFlow(key = Constants.PASSCODE_INITIAL_LOGIN, initialValue = false) + +} \ No newline at end of file diff --git a/feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt b/feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt new file mode 100644 index 00000000000..9a506a4c167 --- /dev/null +++ b/feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.mifos.feature.passcode + +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/feature/splash/.gitignore b/feature/splash/.gitignore new file mode 100644 index 00000000000..42afabfd2ab --- /dev/null +++ b/feature/splash/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/splash/build.gradle.kts b/feature/splash/build.gradle.kts new file mode 100644 index 00000000000..fcdf2a24745 --- /dev/null +++ b/feature/splash/build.gradle.kts @@ -0,0 +1,23 @@ +plugins { + alias(libs.plugins.mifos.android.feature) + alias(libs.plugins.mifos.android.library.compose) + alias(libs.plugins.mifos.android.library.jacoco) +} + +android { + namespace = "com.mifos.feature.splash" +} + +dependencies { + implementation(projects.core.domain) + + //DBFlow dependencies + kapt(libs.dbflow.processor) + implementation(libs.dbflow) + kapt(libs.github.dbflow.processor) + testImplementation(libs.hilt.android.testing) + testImplementation(projects.core.testing) + + androidTestImplementation(projects.core.testing) + +} \ No newline at end of file diff --git a/feature/splash/consumer-rules.pro b/feature/splash/consumer-rules.pro new file mode 100644 index 00000000000..e69de29bb2d diff --git a/feature/splash/proguard-rules.pro b/feature/splash/proguard-rules.pro new file mode 100644 index 00000000000..481bb434814 --- /dev/null +++ b/feature/splash/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/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt b/feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt new file mode 100644 index 00000000000..8992390a5b5 --- /dev/null +++ b/feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.mifos.feature.splash + +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("com.mifos.feature.splash.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/feature/splash/src/main/AndroidManifest.xml b/feature/splash/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..a5918e68abc --- /dev/null +++ b/feature/splash/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + +</manifest> \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt new file mode 100644 index 00000000000..6fe06714bda --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt @@ -0,0 +1,35 @@ +package com.mifos.feature.splash.navigation + +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import androidx.navigation.navigation +import com.mifos.feature.splash.splash.SplashScreen + +fun NavGraphBuilder.splashNavGraph( + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + navigation( + startDestination = SplashScreens.SplashScreen.route, + route = SplashScreens.SplashScreenRoute.route, + ) { + splashScreenRoute( + navigateLogin = navigateLogin, + navigatePasscode = navigatePasscode + ) + } +} + +fun NavGraphBuilder.splashScreenRoute( + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + composable( + route = SplashScreens.SplashScreen.route, + ) { + SplashScreen( + navigatePasscode = navigatePasscode, + navigateLogin = navigateLogin + ) + } +} \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt new file mode 100644 index 00000000000..ee4762d7ee9 --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt @@ -0,0 +1,9 @@ +package com.mifos.feature.splash.navigation + +sealed class SplashScreens(val route: String) { + + data object SplashScreenRoute : SplashScreens("splash_screen_route") + + data object SplashScreen : SplashScreens("splash_screen") + +} \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt new file mode 100644 index 00000000000..4afc3b89470 --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt @@ -0,0 +1,77 @@ +package com.mifos.feature.splash.splash + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.mifos.core.designsystem.component.MifosScaffold +import com.mifos.core.designsystem.theme.SummerSky +import com.mifos.feature.splash.R + +@Composable +fun SplashScreen( + viewmodel: SplashScreenViewmodel = hiltViewModel(), + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + val state by viewmodel.isAuthenticated.collectAsStateWithLifecycle() + + SplashScreen( + state = state, + navigatePasscode = navigatePasscode, + navigateLogin = navigateLogin + ) +} + +@Composable +fun SplashScreen( + state: Boolean?, + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + + when (state) { + false -> navigateLogin() + true -> navigatePasscode() + else -> {} + } + + MifosScaffold( + containerColor = SummerSky + ) { paddingValues -> + Column( + modifier = Modifier + .padding(paddingValues) + .fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + modifier = Modifier.size(100.dp), + painter = painterResource(id = R.drawable.feature_splash_icon), + contentDescription = null + ) + } + } +} + +@Preview +@Composable +private fun SplashScreenPreview() { + SplashScreen( + state = false, + navigatePasscode = {}, + navigateLogin = {} + ) +} \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt new file mode 100644 index 00000000000..f4883f73a33 --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt @@ -0,0 +1,32 @@ +package com.mifos.feature.splash.splash + +import android.util.Log +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.mifos.core.datastore.PrefManager +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class SplashScreenViewmodel @Inject constructor( + private val prefManager: PrefManager +) : ViewModel() { + + private val _isAuthenticated = MutableStateFlow<Boolean?>(null) + val isAuthenticated = _isAuthenticated.asStateFlow() + + init { + checkAuthenticationStatus() + } + + private fun checkAuthenticationStatus() = viewModelScope.launch(Dispatchers.IO) { + delay(2000) + _isAuthenticated.value = prefManager.isAuthenticated() + } + +} \ No newline at end of file diff --git a/feature/splash/src/main/res/drawable/feature_splash_icon.png b/feature/splash/src/main/res/drawable/feature_splash_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d8f0bdc33ad9d6c2c3aa6a48612009b8e80d41fc GIT binary patch literal 2834 zcmZ`*dpOhkAK%PnVsi<(jnK^{a@3}|<d%if%sq!(4$5ULhU^?BE2rFY$)#CMZYyEZ z*}j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mTG|d)wG&c`nJphN&sidsJNhZ|X=azZL-$KbV7abw<FMqcprXjQ7sLGm?6Aw$59Q zC{Gwp1|hLMT1tX8O3!+GcSluEr!375yOPa$%BJ;#^a@sK2x`CxFHsTir<|JBS4*OA znCJlgrh?NS=3gBxfN`Ch2&m>9qq>}}Nq~JuFmw^d&B=J-DDKFV57s#OV|#-#=?1iY z(HKh|vl8p9|MscOeRP+<%QMq1fToX4Qvp<ruxT)0O*Ykl0!KP)w{Yyd1Us)MRM!|M zlb(bBY6DBml(;M<ff|evt_=Kepl9qCDkj9Q>7uYbHwpl%w|CyFLdQWEx9=?&Pv1CH zK(PE=ER{&lSR?Wr@7{isnJ2HxIq<(_x#wXnXv;p4W~xn_k^N&qUPpaB+T9{A{1<HO BO)LNa literal 0 HcmV?d00001 diff --git a/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt b/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt new file mode 100644 index 00000000000..8da7f2fdf58 --- /dev/null +++ b/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.mifos.feature.splash + +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/mifosng-android/build.gradle.kts b/mifosng-android/build.gradle.kts index 1bb25e05323..ca7b3499c0f 100644 --- a/mifosng-android/build.gradle.kts +++ b/mifosng-android/build.gradle.kts @@ -143,6 +143,8 @@ dependencies { implementation(projects.feature.document) implementation(projects.feature.dataTable) implementation(projects.feature.search) + implementation(projects.feature.splash) + implementation(projects.feature.passcode) implementation(projects.core.common) implementation(projects.core.ui) diff --git a/mifosng-android/src/main/AndroidManifest.xml b/mifosng-android/src/main/AndroidManifest.xml index 8d20d0817f4..8237eccdfed 100755 --- a/mifosng-android/src/main/AndroidManifest.xml +++ b/mifosng-android/src/main/AndroidManifest.xml @@ -36,16 +36,10 @@ android:name="com.google.android.geo.API_KEY" android:value="${GEO_API_KEY}" /> - <activity android:name=".DashboardActivity" - android:exported="true" - /> - <activity - android:name=".activity.splashscreen.SplashScreenActivity" + android:name=".AndroidClientActivity" android:exported="true" - android:label="@string/app_name" - android:screenOrientation="portrait" - android:theme="@style/SplashScreen"> + android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt new file mode 100644 index 00000000000..5e795b7d9cf --- /dev/null +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt @@ -0,0 +1,41 @@ +package com.mifos.mifosxdroid + +import androidx.compose.runtime.Composable +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.rememberNavController +import com.mifos.feature.auth.navigation.authNavGraph +import com.mifos.feature.auth.navigation.navigateToLogin +import com.mifos.feature.passcode.navigation.passcodeNavGraph +import com.mifos.feature.splash.navigation.SplashScreens +import com.mifos.feature.splash.navigation.splashNavGraph +import com.mifos.mifosxdroid.navigation.HomeScreens +import com.mifos.mifosxdroid.navigation.homeGraph +import com.mifos.mifosxdroid.navigation.navigateHome + +@Composable +fun AndroidClient() { + + val navController = rememberNavController() + + NavHost( + navController = navController, + startDestination = SplashScreens.SplashScreenRoute.route + ) { + splashNavGraph( + navigatePasscode = navController::navigateHome, + navigateLogin = navController::navigateToLogin + ) + + passcodeNavGraph( + navController = navController + ) + + authNavGraph( + navigatePasscode = {}, + navigateHome = navController::navigateHome, + updateServerConfig = {} + ) + + homeGraph() + } +} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/DashboardActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientActivity.kt similarity index 81% rename from mifosng-android/src/main/java/com/mifos/mifosxdroid/DashboardActivity.kt rename to mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientActivity.kt index ca93dccbca5..07aec95c3de 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/DashboardActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientActivity.kt @@ -6,12 +6,12 @@ import androidx.activity.compose.setContent import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint -class DashboardActivity : ComponentActivity() { +class AndroidClientActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - AndroidClientApp() + AndroidClient() } } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt index d51d7f6cc8f..a352a958093 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt @@ -6,12 +6,8 @@ package com.mifos.mifosxdroid.activity.login import android.content.Intent import android.os.Bundle -import android.util.Log import androidx.activity.compose.setContent -import androidx.navigation.findNavController -import androidx.navigation.fragment.findNavController -import com.mifos.feature.auth.login.presentation.LoginScreen -import com.mifos.mifosxdroid.R +import com.mifos.feature.auth.login.LoginScreen import com.mifos.mifosxdroid.activity.home.HomeActivity import com.mifos.mifosxdroid.activity.setting.UpdateServerConfigFragment import com.mifos.mifosxdroid.core.MifosBaseActivity diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt deleted file mode 100644 index 06646cb6b49..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This project is licensed under the open source MPL V2. - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.mifosxdroid.activity.splashscreen - -import android.content.Intent -import android.os.Bundle -import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import com.mifos.mifosxdroid.activity.login.LoginActivity -import com.mifos.mifosxdroid.core.MifosBaseActivity -import com.mifos.mifosxdroid.passcode.PassCodeActivity -import com.mifos.mobile.passcode.utils.PassCodeConstants -import com.mifos.utils.PrefManager - -/** - * This is the First Activity which can be used for initial checks, inits at app Startup - */ -class SplashScreenActivity : MifosBaseActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - val splashScreen = installSplashScreen() - super.onCreate(savedInstanceState) - splashScreen.setKeepOnScreenCondition { true } - if (!PrefManager.isAuthenticated()) { - startActivity(Intent(this@SplashScreenActivity, LoginActivity::class.java)) - } else { - val intent = Intent( - this@SplashScreenActivity, - PassCodeActivity::class.java - ) - intent.putExtra(PassCodeConstants.PASSCODE_INITIAL_LOGIN, true) - startActivity(intent) - } - finish() - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt index e9f36a0e0f9..7bddb27de68 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt @@ -15,8 +15,8 @@ import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager +import com.mifos.mifosxdroid.AndroidClientActivity import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.activity.splashscreen.SplashScreenActivity import com.mifos.mifosxdroid.passcode.PassCodeActivity import com.mifos.mobile.passcode.BasePassCodeActivity import com.mifos.utils.Constants @@ -117,7 +117,7 @@ open class MifosBaseActivity : BasePassCodeActivity(), BaseActivityCallback { startActivity( Intent( this@MifosBaseActivity, - SplashScreenActivity::class.java + AndroidClientActivity::class.java ) ) Toast.makeText( diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientApp.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeNavigation.kt similarity index 92% rename from mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientApp.kt rename to mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeNavigation.kt index 5717539e07a..27a7c173a51 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientApp.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeNavigation.kt @@ -1,6 +1,6 @@ @file:OptIn(ExperimentalMaterial3Api::class) -package com.mifos.mifosxdroid +package com.mifos.mifosxdroid.navigation import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement @@ -51,17 +51,47 @@ import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController +import androidx.navigation.navigation import com.mifos.core.designsystem.theme.Black import com.mifos.core.designsystem.theme.White +import com.mifos.feature.splash.navigation.SplashScreens +import com.mifos.mifosxdroid.HomeDestinationsScreen +import com.mifos.mifosxdroid.R import com.mifos.mifosxdroid.components.MifosNavigationBar import com.mifos.mifosxdroid.components.Navigation import com.mifos.mifosxdroid.components.NavigationConstants import kotlinx.coroutines.launch +fun NavGraphBuilder.homeGraph() { + navigation( + startDestination = HomeScreens.HomeScreen.route, + route = "home_screen_route" + ) { + homeNavigate() + } +} + +fun NavGraphBuilder.homeNavigate() { + composable( + route = HomeScreens.HomeScreen.route + ) { + HomeNavigation() + } +} + +fun NavController.navigateHome() { + navigate(HomeScreens.HomeScreen.route) { + popBackStack(route = SplashScreens.SplashScreenRoute.route, inclusive = true) + } +} + @Composable -fun AndroidClientApp() { +fun HomeNavigation() { val navController = rememberNavController() val navBackStackEntry by navController.currentBackStackEntryAsState() diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt new file mode 100644 index 00000000000..8b740caeb45 --- /dev/null +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt @@ -0,0 +1,7 @@ +package com.mifos.mifosxdroid.navigation + +sealed class HomeScreens(val route: String) { + + data object HomeScreen : HomeScreens("home_screen") + +} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt index ec39d577b90..adcbb7e3f35 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt @@ -4,10 +4,8 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.core.widget.NestedScrollView -import com.mifos.mifosxdroid.DashboardActivity +import com.mifos.mifosxdroid.AndroidClientActivity import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.activity.home.HomeActivity -import com.mifos.mifosxdroid.activity.splashscreen.SplashScreenActivity import com.mifos.mifosxdroid.core.util.Toaster import com.mifos.mobile.passcode.MifosPassCodeActivity import com.mifos.mobile.passcode.utils.EncryptionUtil @@ -36,7 +34,7 @@ class PassCodeActivity : MifosPassCodeActivity() { } override fun startLoginActivity() { - startActivity(Intent(this, SplashScreenActivity::class.java)) + startActivity(Intent(this, AndroidClientActivity::class.java)) finish() } @@ -49,7 +47,7 @@ class PassCodeActivity : MifosPassCodeActivity() { } override fun startNextActivity() { - startActivity(Intent(this, DashboardActivity::class.java)) + startActivity(Intent(this, AndroidClientActivity::class.java)) } override fun onBackPressed() { diff --git a/settings.gradle.kts b/settings.gradle.kts index 81c609e281b..da9a287441d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -50,3 +50,5 @@ include(":feature:document") include(":feature:savings") include(":feature:data-table") include(":feature:search") +include(":feature:splash") +include(":feature:passcode")