From e3287f35b3ad991a9d43132e6a3d03f4c6ec9983 Mon Sep 17 00:00:00 2001 From: alexandr Date: Wed, 21 Feb 2024 13:14:19 +0200 Subject: [PATCH 1/8] [MS-214] Adding scroll view to the fragment_sync_info.xml --- .../main/res/layout/fragment_sync_info.xml | 658 +++++++++--------- 1 file changed, 332 insertions(+), 326 deletions(-) diff --git a/feature/dashboard/src/main/res/layout/fragment_sync_info.xml b/feature/dashboard/src/main/res/layout/fragment_sync_info.xml index 55cef3bd59..90ec6e3ae6 100644 --- a/feature/dashboard/src/main/res/layout/fragment_sync_info.xml +++ b/feature/dashboard/src/main/res/layout/fragment_sync_info.xml @@ -1,363 +1,369 @@ - + android:layout_height="match_parent"> - + tools:context=".settings.syncinfo.SyncInfoFragment"> - - - - - + android:layout_height="wrap_content" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + - + - - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + - - - - + + + + - - + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - + android:orientation="vertical" + android:padding="10dp"> + + + + + + + + + + + app:layout_constraintBottom_toTopOf="@+id/moduleSelectionButton" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/syncButton" + tools:ignore="SpeakableTextPresentCheck"> + android:text="@string/dashboard_sync_info_selected_modules" + android:textAlignment="center" /> - + - + android:fadeScrollbars="false" + android:orientation="vertical" + android:padding="10dp" + android:scrollbars="vertical" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" + tools:itemCount="100" + tools:listitem="@layout/item_module_count" /> - - - - - - - - - - - - - - - + android:layout_marginStart="10dp" + android:layout_marginTop="15dp" + android:layout_marginEnd="10dp" + android:layout_marginBottom="15dp" + android:text="@string/dashboard_sync_info_select_modules_button" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="@+id/modulesTabHost" + app:layout_constraintStart_toStartOf="@+id/modulesTabHost" + app:layout_constraintTop_toBottomOf="@+id/modulesTabHost" /> + + - + + \ No newline at end of file From 8d9e4967707b8f008d0d7be1e70c94612dc62a2d Mon Sep 17 00:00:00 2001 From: alexandr Date: Wed, 21 Feb 2024 13:16:12 +0200 Subject: [PATCH 2/8] [MS-214] Reverting the portrait screen orientation for DashboardActivity. Currently, we will be focusing on the rotation support for the biometrics flow only --- feature/dashboard/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/feature/dashboard/src/main/AndroidManifest.xml b/feature/dashboard/src/main/AndroidManifest.xml index acee9f0642..d3f97fcc5d 100644 --- a/feature/dashboard/src/main/AndroidManifest.xml +++ b/feature/dashboard/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ From b2e75fb42860fecb15e326799f6879c0e1c386df Mon Sep 17 00:00:00 2001 From: alexandr Date: Wed, 21 Feb 2024 13:20:19 +0200 Subject: [PATCH 3/8] [MS-214] Adding 'isGraphInitialized' flag to the OrchestratorActivity to track the graph's initialization state --- .../orchestrator/OrchestratorActivity.kt | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt index 94e05bbd47..8de35158e2 100644 --- a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt +++ b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt @@ -2,6 +2,7 @@ package com.simprints.feature.orchestrator import android.content.Intent import android.os.Bundle +import android.os.PersistableBundle import androidx.core.os.bundleOf import androidx.navigation.findNavController import com.simprints.core.tools.activity.BaseActivity @@ -11,13 +12,21 @@ import com.simprints.infra.uibase.navigation.handleResult import com.simprints.infra.uibase.viewbinding.viewBinding import dagger.hilt.android.AndroidEntryPoint +private const val KEY_IS_GRAPH_INITIALIZED = "KEY_IS_GRAPH_INITIALIZED" + @AndroidEntryPoint internal class OrchestratorActivity : BaseActivity() { private val binding by viewBinding(ActivityOrchestratorBinding::inflate) + /** + * Flag for the navigation graph initialization state. The graph should only be initialized once + * during the existence of this activity, and the flag tracks graph's state. + */ + private var isGraphInitialized = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + isGraphInitialized = savedInstanceState?.getBoolean(KEY_IS_GRAPH_INITIALIZED) ?: false setContentView(binding.root) binding.orchestrationHost.handleResult(this, R.id.orchestratorRootFragment) { result -> @@ -27,14 +36,21 @@ internal class OrchestratorActivity : BaseActivity() { } override fun onStart() { - super.onStart() - val action = intent.action.orEmpty() - val extras = intent.extras ?: bundleOf() - - findNavController(R.id.orchestrationHost).setGraph( - R.navigation.graph_orchestration, - OrchestratorFragmentArgs(action, extras).toBundle() - ) + if(!isGraphInitialized) { + super.onStart() + val action = intent.action.orEmpty() + val extras = intent.extras ?: bundleOf() + + findNavController(R.id.orchestrationHost).setGraph( + R.navigation.graph_orchestration, + OrchestratorFragmentArgs(action, extras).toBundle() + ) + isGraphInitialized = true + } } + override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) { + outState.putBoolean(KEY_IS_GRAPH_INITIALIZED, isGraphInitialized) + super.onSaveInstanceState(outState, outPersistentState) + } } From a41d4d113f376dc1098034b0b30b74d51a34e129 Mon Sep 17 00:00:00 2001 From: alexandr Date: Wed, 21 Feb 2024 13:21:55 +0200 Subject: [PATCH 4/8] [MS-214] Moving the 'isActivityRestored' and 'requestProcessed' flags from OrchestratorFragment to its ViewModel. Also, setting the correct state of the 'isActivityRestored' flag --- .../feature/orchestrator/OrchestratorFragment.kt | 8 +++----- .../feature/orchestrator/OrchestratorViewModel.kt | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorFragment.kt b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorFragment.kt index f83e099756..e6989a32fc 100644 --- a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorFragment.kt +++ b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorFragment.kt @@ -61,9 +61,6 @@ import javax.inject.Inject @AndroidEntryPoint internal class OrchestratorFragment : Fragment(R.layout.fragment_orchestrator) { - private var isActivityRestored = false - private var requestProcessed = false - @Inject lateinit var alertConfigurationMapper: AlertConfigurationMapper @@ -79,6 +76,7 @@ internal class OrchestratorFragment : Fragment(R.layout.fragment_orchestrator) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + orchestratorVm.isActivityRestored = savedInstanceState != null observeLoginCheckVm() observeClientApiVm() @@ -177,9 +175,9 @@ internal class OrchestratorFragment : Fragment(R.layout.fragment_orchestrator) { override fun onResume() { super.onResume() - if (!isActivityRestored && !requestProcessed) { + if (!orchestratorVm.isActivityRestored && !orchestratorVm.requestProcessed) { if (loginCheckVm.isDeviceSafe()) { - requestProcessed = true + orchestratorVm.requestProcessed = true lifecycleScope.launch { val actionRequest = clientApiVm.handleIntent(args.requestAction, args.requestParams) if (actionRequest != null) { diff --git a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorViewModel.kt b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorViewModel.kt index 33e31d7287..a2bba2e095 100644 --- a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorViewModel.kt +++ b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorViewModel.kt @@ -46,6 +46,8 @@ internal class OrchestratorViewModel @Inject constructor( private val updateDailyActivity: UpdateDailyActivityUseCase, ) : ViewModel() { + var isActivityRestored = false + var requestProcessed = false private var modalities = emptySet() private var steps = emptyList() private var actionRequest: ActionRequest? = null From 6b776c92adf3e8717ba62835b1e20714298d5f86 Mon Sep 17 00:00:00 2001 From: alexandr Date: Wed, 21 Feb 2024 14:11:23 +0200 Subject: [PATCH 5/8] [MS-214] Reverting test changes to the camera's capture position calculation in ImageProxyToBitmapUseCase --- .../capture/usecases/ImageProxyToBitmapUseCase.kt | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/face/capture/src/main/java/com/simprints/face/capture/usecases/ImageProxyToBitmapUseCase.kt b/face/capture/src/main/java/com/simprints/face/capture/usecases/ImageProxyToBitmapUseCase.kt index 24dd8d9d2b..95599fa3cf 100644 --- a/face/capture/src/main/java/com/simprints/face/capture/usecases/ImageProxyToBitmapUseCase.kt +++ b/face/capture/src/main/java/com/simprints/face/capture/usecases/ImageProxyToBitmapUseCase.kt @@ -27,21 +27,10 @@ internal class ImageProxyToBitmapUseCase @Inject constructor() { bitmap.copyPixelsFromBuffer(buffer) val rotationMatrix = Matrix() rotationMatrix.postRotate(imageProxy.imageInfo.rotationDegrees.toFloat()) - - // If cropRect.left or cropRect.right is less than 0, then Bitmap.createBitmap throws an exception. - // cropRect.left is < 0 on some devices when in landscape mode - // TODO Revert these changes and review the most appropriate way to solve the issue. - var left = cropRect.left.takeIf { it >= 0 } ?: 0 - var right = cropRect.right.takeIf { it >= 0 } ?: 0 - - if(right + cropRect.height() > bitmap.height) { - val currentSum = right + cropRect.height() - right = right - ((right + cropRect.height()) - bitmap.height) - } val croppedRotatedBitmap = Bitmap.createBitmap( bitmap, - left, - right, + cropRect.left, + cropRect.top, cropRect.width(), cropRect.height(), rotationMatrix, From 6376ecaf4454c51943444babce0ddeb509a8f740 Mon Sep 17 00:00:00 2001 From: alexandr Date: Wed, 21 Feb 2024 14:12:34 +0200 Subject: [PATCH 6/8] [MS-214] Reverting temporary 'limitLength' comment --- .../src/main/java/com/simprints/infra/logging/Simber.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/infra/logging/src/main/java/com/simprints/infra/logging/Simber.kt b/infra/logging/src/main/java/com/simprints/infra/logging/Simber.kt index 0419ea8b24..73b8f673fe 100644 --- a/infra/logging/src/main/java/com/simprints/infra/logging/Simber.kt +++ b/infra/logging/src/main/java/com/simprints/infra/logging/Simber.kt @@ -171,10 +171,9 @@ object Simber { private fun limitLength(message: String, max: Int): String { if (message.length > max) { - // TODO revert comment -// if (BuildConfig.DEBUG) { -// throw IllegalArgumentException("String must be less than $max characters.") -// } + if (BuildConfig.DEBUG) { + throw IllegalArgumentException("String must be less than $max characters.") + } return message.substring(0, max) } From cfb2be16206fab9de924db89c538fb847b7d260e Mon Sep 17 00:00:00 2001 From: alexandr Date: Wed, 21 Feb 2024 14:22:49 +0200 Subject: [PATCH 7/8] [MS-214] Moving 'super.onStart()' call out of the conditional statement --- .../com/simprints/feature/orchestrator/OrchestratorActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt index 8de35158e2..3eaf2f0628 100644 --- a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt +++ b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt @@ -36,8 +36,8 @@ internal class OrchestratorActivity : BaseActivity() { } override fun onStart() { + super.onStart() if(!isGraphInitialized) { - super.onStart() val action = intent.action.orEmpty() val extras = intent.extras ?: bundleOf() From b6688356f6e75e3a0e47707c5265e09f5c651ca2 Mon Sep 17 00:00:00 2001 From: alexandr Date: Thu, 22 Feb 2024 15:44:29 +0200 Subject: [PATCH 8/8] [MS-214] Moving 'KEY_IS_GRAPH_INITIALIZED' to the compantion object --- .../simprints/feature/orchestrator/OrchestratorActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt index 3eaf2f0628..dbe69c2748 100644 --- a/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt +++ b/feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/OrchestratorActivity.kt @@ -12,8 +12,6 @@ import com.simprints.infra.uibase.navigation.handleResult import com.simprints.infra.uibase.viewbinding.viewBinding import dagger.hilt.android.AndroidEntryPoint -private const val KEY_IS_GRAPH_INITIALIZED = "KEY_IS_GRAPH_INITIALIZED" - @AndroidEntryPoint internal class OrchestratorActivity : BaseActivity() { @@ -53,4 +51,8 @@ internal class OrchestratorActivity : BaseActivity() { outState.putBoolean(KEY_IS_GRAPH_INITIALIZED, isGraphInitialized) super.onSaveInstanceState(outState, outPersistentState) } + + companion object { + private const val KEY_IS_GRAPH_INITIALIZED = "KEY_IS_GRAPH_INITIALIZED" + } }