Task: compose migration import export activity#3021
Task: compose migration import export activity#3021amlwin wants to merge 6 commits intoCatimaLoyalty:mainfrom
Conversation
This commit refactors the `ImportExportActivity` from an XML-based layout to a modern UI using Jetpack Compose. The core logic is preserved, but the implementation is now more streamlined and uses declarative UI principles. Key changes include: * Replacing the `import_export_activity.xml` layout with a new `ImportExportScreen.kt` Composable. * Updating `ImportExportActivity` to use `setContent` and manage UI state with Compose `MutableState`. * Replacing traditional dialogs (`MaterialAlertDialogBuilder`) with Composable dialogs for a consistent UI. * Adding new Compose testing dependencies and updating `ImportExportActivityTest` to use `createComposeRule` for testing the new Composable UI.
The `onImportComplete` function was simplified by removing the `path: Uri` parameter, which was no longer used. Call sites in `openFileForImport` and `initiateImport` were updated accordingly to reflect this change. The unused `dataFormat` parameter was also removed from the `onImportWithPassword` lambda.
Moved `ImportExportActivityTest.kt` from the `test` source set to the `androidTest` source set. This change also adds the Robolectric dependency to the `androidTest` configuration in `app/build.gradle.kts` to support the test's execution environment.
|
Thanks, I'll try to review this later but I may not have time the coming week or two. For the failing tests, I guess the compose stuff is bloating the APK a bit (though not sure how much). Are you sure is really needed? If yes (or just really helpful), maybe you can try bumping disk-size for the Instrumented Tests steps in I can't find a default size in the code, but it looks like it may be 800MB, so 1GB might already be sufficient. |
it's required to render preview in preview pane for android studio.
will update in next commit |
Adds `disk-size: 1G` to the Android emulator setup for instrumented tests on API levels 23 and 35. This increases the available disk space for the emulators running in the CI workflow.
|
Not sure why the tests still fail, I ran it from the main branch to make sure the tests weren't just broken by something else but they work fine there :/ |
Moved `ImportExportActivityTest` from the `androidTest` directory to the `test` directory, converting it from an instrumented test to a local unit test. This change allows the test to run on the local JVM using Robolectric instead of requiring an Android emulator or device. To support this move, the Robolectric dependency was removed from `androidTestImplementation` as it is already included for unit tests. Additionally, a `ComponentActivity` declaration was added to `AndroidManifest.xml`, which is required for running Compose UI tests with Robolectric. The GitHub Actions workflow was also updated to remove the unnecessary `disk-size` parameter for the emulator runner.
Merge ComponentActivity manifest entries To resolve a manifest merger failed error during UI tests, this change adds `tools:replace="android:exported"` to the `androidx.activity.ComponentActivity` declaration in `AndroidManifest.xml`. This ensures that the `android:exported` attribute from the library's manifest is overridden, allowing the build to succeed.
|
Fixied
|
Summary
Changes
ImportExportActivity.kt
CatimaAppCompatActivitytoCatimaComponentActivitysetContentusingCatimaThememutableStateOfImportExportScreen.kt (new)
CatimaTopAppBarand Material3 componentsImportOptiondata class andImportExportDialogStatesealed class for state management@Previewcomposables for Android Studio previewsImportExportActivityTest.kt
createComposeRule,onNodeWithText, etc.)Build Configuration
androidx-compose-ui-ui-toolingdependency for Compose previewsrobolectric.propertieswithgraphics.mode=NATIVEfor Compose renderingRemoved
import_export_activity.xml- no longer needed with ComposeTest plan
./gradlew :app:testFossDebugUnitTest --tests "protect.card_locker.ImportExportActivityTest"