From c7e03abdbb713cd659c32b71c1b40e03c7befd4f Mon Sep 17 00:00:00 2001 From: Pronay sarker Date: Wed, 13 Nov 2024 20:51:01 +0600 Subject: [PATCH 1/2] splash cleanup fix errors --- feature/splash/build.gradle.kts | 9 +++++ .../feature/splash/ExampleInstrumentedTest.kt | 17 +++++++--- feature/splash/src/main/AndroidManifest.xml | 9 +++++ .../splash/navigation/SplashNavigation.kt | 19 ++++++++--- .../splash/navigation/SplashScreens.kt | 12 +++++-- .../feature/splash/splash/SplashScreen.kt | 34 ++++++++++++------- .../splash/splash/SplashScreenViewmodel.kt | 15 +++++--- .../mifos/feature/splash/ExampleUnitTest.kt | 14 ++++++-- .../CheckerInboxPendingTasksActivity.kt | 2 +- .../src/main/res/layout/activity_splash.xml | 9 ----- .../src/main/res/layout/fragment_splash.xml | 13 ------- .../src/main/res/menu/splash_screen.xml | 15 -------- .../src/main/res/navigation/nav_graph.xml | 16 --------- 13 files changed, 99 insertions(+), 85 deletions(-) delete mode 100755 mifosng-android/src/main/res/layout/activity_splash.xml delete mode 100755 mifosng-android/src/main/res/layout/fragment_splash.xml delete mode 100755 mifosng-android/src/main/res/menu/splash_screen.xml diff --git a/feature/splash/build.gradle.kts b/feature/splash/build.gradle.kts index fcdf2a24745..d4a05dd1786 100644 --- a/feature/splash/build.gradle.kts +++ b/feature/splash/build.gradle.kts @@ -1,3 +1,12 @@ +/* + * Copyright 2024 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ plugins { alias(libs.plugins.mifos.android.feature) alias(libs.plugins.mifos.android.library.compose) 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 index 8992390a5b5..9d9ec54fbac 100644 --- a/feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt +++ b/feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt @@ -1,13 +1,20 @@ +/* + * Copyright 2024 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ package com.mifos.feature.splash -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import junit.framework.TestCase.assertEquals import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * @@ -21,4 +28,4 @@ class ExampleInstrumentedTest { 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 index a5918e68abc..1dc76da0f7e 100644 --- a/feature/splash/src/main/AndroidManifest.xml +++ b/feature/splash/src/main/AndroidManifest.xml @@ -1,4 +1,13 @@ + \ 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 index 6fe06714bda..e4f73ac38cd 100644 --- 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 @@ -1,3 +1,12 @@ +/* + * Copyright 2024 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ package com.mifos.feature.splash.navigation import androidx.navigation.NavGraphBuilder @@ -7,7 +16,7 @@ import com.mifos.feature.splash.splash.SplashScreen fun NavGraphBuilder.splashNavGraph( navigatePasscode: () -> Unit, - navigateLogin: () -> Unit + navigateLogin: () -> Unit, ) { navigation( startDestination = SplashScreens.SplashScreen.route, @@ -15,21 +24,21 @@ fun NavGraphBuilder.splashNavGraph( ) { splashScreenRoute( navigateLogin = navigateLogin, - navigatePasscode = navigatePasscode + navigatePasscode = navigatePasscode, ) } } fun NavGraphBuilder.splashScreenRoute( navigatePasscode: () -> Unit, - navigateLogin: () -> Unit + navigateLogin: () -> Unit, ) { composable( route = SplashScreens.SplashScreen.route, ) { SplashScreen( navigatePasscode = navigatePasscode, - navigateLogin = navigateLogin + 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 index ee4762d7ee9..2943581b753 100644 --- 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 @@ -1,3 +1,12 @@ +/* + * Copyright 2024 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ package com.mifos.feature.splash.navigation sealed class SplashScreens(val route: String) { @@ -5,5 +14,4 @@ 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 index 4afc3b89470..a9ce41f1c16 100644 --- 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 @@ -1,3 +1,12 @@ +/* + * Copyright 2024 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ package com.mifos.feature.splash.splash import androidx.compose.foundation.Image @@ -20,27 +29,27 @@ import com.mifos.core.designsystem.theme.SummerSky import com.mifos.feature.splash.R @Composable -fun SplashScreen( - viewmodel: SplashScreenViewmodel = hiltViewModel(), +internal fun SplashScreen( navigatePasscode: () -> Unit, - navigateLogin: () -> Unit + viewmodel: SplashScreenViewmodel = hiltViewModel(), + navigateLogin: () -> Unit, ) { val state by viewmodel.isAuthenticated.collectAsStateWithLifecycle() SplashScreen( state = state, navigatePasscode = navigatePasscode, - navigateLogin = navigateLogin + navigateLogin = navigateLogin, ) } @Composable -fun SplashScreen( +internal fun SplashScreen( state: Boolean?, navigatePasscode: () -> Unit, - navigateLogin: () -> Unit + navigateLogin: () -> Unit, + modifier: Modifier = Modifier, ) { - when (state) { false -> navigateLogin() true -> navigatePasscode() @@ -48,19 +57,20 @@ fun SplashScreen( } MifosScaffold( - containerColor = SummerSky + modifier = modifier, + containerColor = SummerSky, ) { paddingValues -> Column( modifier = Modifier .padding(paddingValues) .fillMaxSize(), verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Image( modifier = Modifier.size(100.dp), painter = painterResource(id = R.drawable.feature_splash_icon), - contentDescription = null + contentDescription = null, ) } } @@ -72,6 +82,6 @@ private fun SplashScreenPreview() { SplashScreen( state = false, navigatePasscode = {}, - navigateLogin = {} + 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 index f4883f73a33..a4bacd67ad0 100644 --- 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 @@ -1,6 +1,14 @@ +/* + * Copyright 2024 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ package com.mifos.feature.splash.splash -import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.mifos.core.datastore.PrefManager @@ -14,7 +22,7 @@ import javax.inject.Inject @HiltViewModel class SplashScreenViewmodel @Inject constructor( - private val prefManager: PrefManager + private val prefManager: PrefManager, ) : ViewModel() { private val _isAuthenticated = MutableStateFlow(null) @@ -28,5 +36,4 @@ class SplashScreenViewmodel @Inject constructor( delay(2000) _isAuthenticated.value = prefManager.isAuthenticated() } - -} \ No newline at end of file +} 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 index 8da7f2fdf58..d313d85f15a 100644 --- a/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt +++ b/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt @@ -1,9 +1,17 @@ +/* + * Copyright 2024 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ package com.mifos.feature.splash +import junit.framework.TestCase.assertEquals import org.junit.Test -import org.junit.Assert.* - /** * Example local unit test, which will execute on the development machine (host). * @@ -14,4 +22,4 @@ class ExampleUnitTest { fun addition_isCorrect() { assertEquals(4, 2 + 2) } -} \ No newline at end of file +} diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt index d3c9bc5183b..32ef02c6802 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt @@ -20,7 +20,7 @@ class CheckerInboxPendingTasksActivity : MifosBaseActivity() { supportFragmentManager.findFragmentById(R.id.container_nav_host_fragment) as NavHostFragment navHostFragment.navController.apply { popBackStack() - navigate(R.id.checkerInboxTasksFragment) +// navigate(R.id.checkerInboxTasksFragment) } } } diff --git a/mifosng-android/src/main/res/layout/activity_splash.xml b/mifosng-android/src/main/res/layout/activity_splash.xml deleted file mode 100755 index 5c36fffd2b6..00000000000 --- a/mifosng-android/src/main/res/layout/activity_splash.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/mifosng-android/src/main/res/layout/fragment_splash.xml b/mifosng-android/src/main/res/layout/fragment_splash.xml deleted file mode 100755 index 84c3136f482..00000000000 --- a/mifosng-android/src/main/res/layout/fragment_splash.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/mifosng-android/src/main/res/menu/splash_screen.xml b/mifosng-android/src/main/res/menu/splash_screen.xml deleted file mode 100755 index f7106ad9566..00000000000 --- a/mifosng-android/src/main/res/menu/splash_screen.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - diff --git a/mifosng-android/src/main/res/navigation/nav_graph.xml b/mifosng-android/src/main/res/navigation/nav_graph.xml index b96f665baa3..8affb1b62a3 100644 --- a/mifosng-android/src/main/res/navigation/nav_graph.xml +++ b/mifosng-android/src/main/res/navigation/nav_graph.xml @@ -74,22 +74,6 @@ app:argType="integer" /> - - - - - - - - Date: Sat, 16 Nov 2024 15:28:30 +0600 Subject: [PATCH 2/2] fixed conflicts --- .../src/main/res/navigation/home_nav_graph.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/mifosng-android/src/main/res/navigation/home_nav_graph.xml b/mifosng-android/src/main/res/navigation/home_nav_graph.xml index 1e3b8ecc0f7..1b37b7b04af 100644 --- a/mifosng-android/src/main/res/navigation/home_nav_graph.xml +++ b/mifosng-android/src/main/res/navigation/home_nav_graph.xml @@ -39,15 +39,6 @@ - - -