From 87d1d2613161df6d2e4f556206f6fa9c6d8ac813 Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Fri, 6 Sep 2024 18:20:54 +0500 Subject: [PATCH 1/7] added progress indicator while quering/fetching the data on insight screen --- .../ui/usersetting/UserInsightScreenFragment.kt | 3 +++ .../ui/usersetting/UserSettingInsightScreen.kt | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserInsightScreenFragment.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserInsightScreenFragment.kt index 8eac284142..44636d522c 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserInsightScreenFragment.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserInsightScreenFragment.kt @@ -21,6 +21,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment @@ -56,6 +57,8 @@ class UserInsightScreenFragment : Fragment() { buildDate = userSettingViewModel.getBuildDate(), unsyncedResourcesFlow = userSettingViewModel.unsyncedResourcesMutableSharedFlow, navController = findNavController(), + showProgressIndicator = + userSettingViewModel.showProgressIndicatorFlow.collectAsState().value, onRefreshRequest = { userSettingViewModel.fetchUnsyncedResources() }, dateFormat = userSettingViewModel.getDateFormat(), ) diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt index f6ed79d691..6be9c62c50 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt @@ -21,6 +21,7 @@ import android.os.Build import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row @@ -36,6 +37,7 @@ import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.Divider import androidx.compose.material.Icon import androidx.compose.material.IconButton @@ -74,6 +76,7 @@ import org.smartregister.fhircore.engine.ui.theme.DividerColor import org.smartregister.fhircore.engine.ui.theme.LoginDarkColor import org.smartregister.fhircore.engine.util.extension.DEFAULT_FORMAT_SDF_DD_MM_YYYY import org.smartregister.fhircore.engine.util.extension.formatDate +import org.smartregister.fhircore.quest.ui.pin.CIRCULAR_PROGRESS_INDICATOR const val USER_INSIGHT_TOP_APP_BAR = "userInsightToAppBar" const val INSIGHT_UNSYNCED_DATA = "insightUnsyncedData" @@ -94,6 +97,7 @@ fun UserSettingInsightScreen( dividerColor: Color = DividerColor, unsyncedResourcesFlow: MutableSharedFlow>>, navController: NavController, + showProgressIndicator: Boolean = false, onRefreshRequest: () -> Unit, dateFormat: String = DEFAULT_FORMAT_SDF_DD_MM_YYYY, ) { @@ -273,6 +277,17 @@ fun UserSettingInsightScreen( } } } + if (showProgressIndicator) { + Box( + modifier = Modifier.fillMaxSize(), + contentAlignment = Alignment.Center, + ) { + CircularProgressIndicator( + modifier = Modifier.size(24.dp).testTag(CIRCULAR_PROGRESS_INDICATOR).wrapContentWidth(), + strokeWidth = 1.6.dp, + ) + } + } } } From b9b009cdd498f2789f43a62f83f211892e739887 Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Fri, 6 Sep 2024 18:36:07 +0500 Subject: [PATCH 2/7] added tests --- .../ui/usersetting/UserSettingInsightScreenTest.kt | 10 ++++++++++ .../quest/ui/usersetting/UserSettingInsightScreen.kt | 1 + .../fhircore/quest/ui/usersetting/UserSettingScreen.kt | 1 - 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt index b476d3c0d7..96d48a8425 100644 --- a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt +++ b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt @@ -18,6 +18,7 @@ package org.smartregister.fhircore.quest.integration.ui.usersetting import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createEmptyComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText @@ -30,6 +31,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.smartregister.fhircore.engine.util.extension.DEFAULT_FORMAT_SDF_DD_MM_YYYY +import org.smartregister.fhircore.quest.ui.usersetting.CIRCULAR_PROGRESS_INDICATOR import org.smartregister.fhircore.quest.ui.usersetting.INSIGHT_UNSYNCED_DATA import org.smartregister.fhircore.quest.ui.usersetting.UserSettingInsightScreen @@ -100,6 +102,13 @@ class UserSettingInsightScreenTest { composeRule.onNodeWithTag(INSIGHT_UNSYNCED_DATA).assertDoesNotExist() } + @Test + fun testProgressIndicatorShowWhenFetchingTheData() { + val unsyncedResources = emptyList>() + initComposable(unsyncedResourcesFlow = MutableStateFlow(unsyncedResources)) + composeRule.onNodeWithTag(CIRCULAR_PROGRESS_INDICATOR).assertExists().assertIsDisplayed() + } + private fun initComposable( unsyncedResourcesFlow: MutableSharedFlow>> = MutableSharedFlow(), ) { @@ -118,6 +127,7 @@ class UserSettingInsightScreenTest { buildDate = "29 jan 2023", unsyncedResourcesFlow = unsyncedResourcesFlow, navController = rememberNavController(), + showProgressIndicator = true, onRefreshRequest = {}, dateFormat = DEFAULT_FORMAT_SDF_DD_MM_YYYY, ) diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt index 6be9c62c50..08b7c803bb 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt @@ -80,6 +80,7 @@ import org.smartregister.fhircore.quest.ui.pin.CIRCULAR_PROGRESS_INDICATOR const val USER_INSIGHT_TOP_APP_BAR = "userInsightToAppBar" const val INSIGHT_UNSYNCED_DATA = "insightUnsyncedData" +const val CIRCULAR_PROGRESS_INDICATOR = "progressIndicator" @SuppressLint("UnusedMaterialScaffoldPaddingParameter") @Composable diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingScreen.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingScreen.kt index b141d04125..5b77487a83 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingScreen.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingScreen.kt @@ -93,7 +93,6 @@ import org.smartregister.fhircore.engine.ui.theme.LighterBlue import org.smartregister.fhircore.engine.ui.theme.LoginDarkColor import org.smartregister.fhircore.engine.util.annotation.PreviewWithBackgroundExcludeGenerated import org.smartregister.fhircore.engine.util.extension.appVersion -import org.smartregister.fhircore.quest.ui.pin.CIRCULAR_PROGRESS_INDICATOR const val RESET_DATABASE_DIALOG = "resetDatabaseDialog" const val USER_SETTING_ROW_LOGOUT = "userSettingRowLogout" From e8acafc50500efaeded728bc687aa156b2ad4469 Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Tue, 24 Sep 2024 16:09:58 +0500 Subject: [PATCH 3/7] feedback updated --- .../engine/src/main/res/values-es/strings.xml | 1 + .../engine/src/main/res/values-fr/strings.xml | 1 + .../engine/src/main/res/values-in/strings.xml | 1 + .../engine/src/main/res/values-sw/strings.xml | 1 + .../engine/src/main/res/values/strings.xml | 1 + .../usersetting/UserSettingInsightScreen.kt | 40 +++++++++++++------ 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/android/engine/src/main/res/values-es/strings.xml b/android/engine/src/main/res/values-es/strings.xml index 757d0475bb..5ba9f19d9c 100644 --- a/android/engine/src/main/res/values-es/strings.xml +++ b/android/engine/src/main/res/values-es/strings.xml @@ -55,6 +55,7 @@ Reintentar sincronización Sincronización en curso Cargando + Cargando… Mensaje de error al cerrar sesión: %1$s No se puede cerrar sesión: ya se ha cerrado sesión o el dispositivo está desconectado. No se pudo cargar la configuración. Inténtalo de nuevo más tarde diff --git a/android/engine/src/main/res/values-fr/strings.xml b/android/engine/src/main/res/values-fr/strings.xml index 71df4675e0..6b47354642 100644 --- a/android/engine/src/main/res/values-fr/strings.xml +++ b/android/engine/src/main/res/values-fr/strings.xml @@ -55,6 +55,7 @@ Réessayer la synchronisation Synchronisation en cours Chargement + Chargement… Message d\'erreur de déconnexion %1$s Impossible de se déconnecter : Déjà déconnecté ou l\'appareil est hors ligne. Impossible de charger la configuration. Veuillez réessayer plus tard diff --git a/android/engine/src/main/res/values-in/strings.xml b/android/engine/src/main/res/values-in/strings.xml index 5933ffa823..4200c79864 100644 --- a/android/engine/src/main/res/values-in/strings.xml +++ b/android/engine/src/main/res/values-in/strings.xml @@ -52,6 +52,7 @@ Coba lagi sinkronisasi Sinkronisasi sedang berlangsung Memuat + Memuat… Pesan kesalahan logout: %1$s Tidak dapat logout: Sudah logout atau perangkat sedang offline. Tidak dapat memuat konfigurasi. Silakan coba lagi nanti diff --git a/android/engine/src/main/res/values-sw/strings.xml b/android/engine/src/main/res/values-sw/strings.xml index 0b80b4bf86..becad88e54 100644 --- a/android/engine/src/main/res/values-sw/strings.xml +++ b/android/engine/src/main/res/values-sw/strings.xml @@ -45,6 +45,7 @@ Jaribu kusawazisha tena Kusawazisha inaendelea Inapakia + Inapakia… Hitilafu kounyesha fomu Hitilafu imetokea, haiwezi kuhifadhi fomu Badilisha picha diff --git a/android/engine/src/main/res/values/strings.xml b/android/engine/src/main/res/values/strings.xml index cb1930e273..1b7d763251 100644 --- a/android/engine/src/main/res/values/strings.xml +++ b/android/engine/src/main/res/values/strings.xml @@ -56,6 +56,7 @@ Retry sync Sync in progress Loading + Loading… Logout error message: %1$s Unable to logout: Already logged out or device is offline. Could not load configuration. Please try again later diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt index 08b7c803bb..6902c94833 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt @@ -21,7 +21,6 @@ import android.os.Build import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row @@ -128,7 +127,32 @@ fun UserSettingInsightScreen( horizontalAlignment = Alignment.Start, contentPadding = PaddingValues(vertical = 24.dp, horizontal = 16.dp), ) { - if (unsyncedResources.isNotEmpty()) { + if (showProgressIndicator) { + item { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier.fillMaxWidth(), + ) { + Text( + text = stringResource(id = R.string.loading_ellipsis), + style = TextStyle(color = Color.Black, fontSize = 20.sp), + fontWeight = FontWeight.Bold, + ) + Spacer(modifier = Modifier.width(8.dp)) + CircularProgressIndicator( + modifier = + Modifier.size(24.dp).testTag(CIRCULAR_PROGRESS_INDICATOR).wrapContentWidth(), + strokeWidth = 1.6.dp, + ) + } + } + item { + Spacer(modifier = Modifier.height(16.dp)) + Divider(color = dividerColor) + Spacer(modifier = Modifier.height(24.dp)) + } + } else if (unsyncedResources.isNotEmpty()) { item { Text( text = stringResource(id = R.string.unsynced_resources), @@ -278,17 +302,6 @@ fun UserSettingInsightScreen( } } } - if (showProgressIndicator) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - CircularProgressIndicator( - modifier = Modifier.size(24.dp).testTag(CIRCULAR_PROGRESS_INDICATOR).wrapContentWidth(), - strokeWidth = 1.6.dp, - ) - } - } } } @@ -384,6 +397,7 @@ fun UserSettingInsightScreenPreview() { buildDate = "29 Jan 2023", unsyncedResourcesFlow = MutableSharedFlow(), navController = rememberNavController(), + showProgressIndicator = true, onRefreshRequest = {}, dateFormat = DEFAULT_FORMAT_SDF_DD_MM_YYYY, ) From ea30d237c2e292c9806fd7de17be786767c8ee6d Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Tue, 8 Oct 2024 01:09:40 +0500 Subject: [PATCH 4/7] tests updated --- .../ui/usersetting/UserSettingInsightScreenTest.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt index 96d48a8425..e8d71fd95e 100644 --- a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt +++ b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt @@ -105,12 +105,16 @@ class UserSettingInsightScreenTest { @Test fun testProgressIndicatorShowWhenFetchingTheData() { val unsyncedResources = emptyList>() - initComposable(unsyncedResourcesFlow = MutableStateFlow(unsyncedResources)) + initComposable( + unsyncedResourcesFlow = MutableStateFlow(unsyncedResources), + showProgressIndicator = true + ) composeRule.onNodeWithTag(CIRCULAR_PROGRESS_INDICATOR).assertExists().assertIsDisplayed() } private fun initComposable( unsyncedResourcesFlow: MutableSharedFlow>> = MutableSharedFlow(), + showProgressIndicator: Boolean = false, ) { scenario.onActivity { activity -> activity.setContent { @@ -127,7 +131,7 @@ class UserSettingInsightScreenTest { buildDate = "29 jan 2023", unsyncedResourcesFlow = unsyncedResourcesFlow, navController = rememberNavController(), - showProgressIndicator = true, + showProgressIndicator = showProgressIndicator, onRefreshRequest = {}, dateFormat = DEFAULT_FORMAT_SDF_DD_MM_YYYY, ) From b74d13c7c9ca5029e2712d0b111cb19c48ecd656 Mon Sep 17 00:00:00 2001 From: Aurangzaib Umer Date: Tue, 8 Oct 2024 01:20:42 +0500 Subject: [PATCH 5/7] spotless ran --- .../integration/ui/usersetting/UserSettingInsightScreenTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt index e8d71fd95e..b50e02d312 100644 --- a/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt +++ b/android/quest/src/androidTest/java/org/smartregister/fhircore/quest/integration/ui/usersetting/UserSettingInsightScreenTest.kt @@ -107,7 +107,7 @@ class UserSettingInsightScreenTest { val unsyncedResources = emptyList>() initComposable( unsyncedResourcesFlow = MutableStateFlow(unsyncedResources), - showProgressIndicator = true + showProgressIndicator = true, ) composeRule.onNodeWithTag(CIRCULAR_PROGRESS_INDICATOR).assertExists().assertIsDisplayed() } From 6464ca44df5c2cc4778da0c6ecd79a833de90234 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Tue, 8 Oct 2024 15:59:44 +0300 Subject: [PATCH 6/7] Trigger CI From 284799ef7c3f8e1fc53732345cf94bae1ab20eb3 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Fri, 1 Nov 2024 17:54:41 +0300 Subject: [PATCH 7/7] =?UTF-8?q?Fix=20build=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt index 6902c94833..de718ebb84 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/usersetting/UserSettingInsightScreen.kt @@ -75,7 +75,6 @@ import org.smartregister.fhircore.engine.ui.theme.DividerColor import org.smartregister.fhircore.engine.ui.theme.LoginDarkColor import org.smartregister.fhircore.engine.util.extension.DEFAULT_FORMAT_SDF_DD_MM_YYYY import org.smartregister.fhircore.engine.util.extension.formatDate -import org.smartregister.fhircore.quest.ui.pin.CIRCULAR_PROGRESS_INDICATOR const val USER_INSIGHT_TOP_APP_BAR = "userInsightToAppBar" const val INSIGHT_UNSYNCED_DATA = "insightUnsyncedData" @@ -142,7 +141,7 @@ fun UserSettingInsightScreen( Spacer(modifier = Modifier.width(8.dp)) CircularProgressIndicator( modifier = - Modifier.size(24.dp).testTag(CIRCULAR_PROGRESS_INDICATOR).wrapContentWidth(), + Modifier.testTag(CIRCULAR_PROGRESS_INDICATOR).size(24.dp).wrapContentWidth(), strokeWidth = 1.6.dp, ) }