-
Notifications
You must be signed in to change notification settings - Fork 2
[TASK][YD-6940] Migrate webapp module UI to Jetpack Compose #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: YD-6939
Are you sure you want to change the base?
Conversation
Related to YD-6940
The permissions READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE are legacy permissions that grant broad, unrestricted access to the shared external storage volume. For privacy and security reasons, Google has been systematically deprecating and restricting them. After testing, it seems safe to remove them, they no longer appear to be required. Related to YD-6940
Related to YD-6940
Instead of the shake-toggled bottom sheet, show the main screen composable directly. After URL input, use navigation-compose to navigate to the web screen composable. Close-session and session-finish alert dialogs have also been migrated to Compose. Related to YD-6940
Also replace legacy AlertDialog with Composable equivalent. Related to YD-6940
Related to YD-6940
View system components were replaced with Jetpack Compose. Related to YD-6940
Related to YD-6940
Related to YD-6940
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the webapp module from the legacy View system to Jetpack Compose while updating deprecated APIs and enabling edge-to-edge display. The migration replaces the shake-to-configure behavior with a direct main screen UI and implements proper navigation between screens.
Key changes:
- Updated compile and target SDK from 33 to 34
- Migrated UI from XML layouts to Compose with MainScreen and WebScreen composables
- Replaced deprecated permission handling with ActivityResult API
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
webapp/build.gradle | Updates SDK versions and dependencies to support Compose |
webapp/src/main/AndroidManifest.xml | Removes deprecated storage permissions |
webapp/src/main/java/com/yoti/mobile/android/sdk/yotidocscan/websample/MainActivity.kt | Complete rewrite using Compose, ActivityResult APIs, and navigation |
webapp/src/main/java/com/yoti/mobile/android/sdk/yotidocscan/websample/MainScreen.kt | New Compose screen for URL input and session start |
webapp/src/main/java/com/yoti/mobile/android/sdk/yotidocscan/websample/WebScreen.kt | New Compose screen containing WebView with dialogs |
webapp/src/main/java/com/yoti/mobile/android/sdk/yotidocscan/websample/ui/Theme.kt | Compose theme definition |
webapp/src/main/java/com/yoti/mobile/android/sdk/yotidocscan/websample/AppDestinations.kt | Navigation destinations constants |
webapp/src/main/res/values/strings.xml | New string resources for Compose UI |
webapp/src/main/res/values/styles.xml | Simplified theme using Material Design |
Multiple deleted files | Removes XML layouts, drawable, colors, and accelerometer listener |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
webapp/src/main/java/com/yoti/mobile/android/sdk/yotidocscan/websample/MainActivity.kt
Show resolved
Hide resolved
webapp/src/main/java/com/yoti/mobile/android/sdk/yotidocscan/websample/WebScreen.kt
Show resolved
Hide resolved
webapp/build.gradle
Outdated
@@ -46,4 +48,10 @@ dependencies { | |||
// Multi-module projects: Add this dependency because of Android Studio Issue | |||
// and androix.navigation dependencies management https://issuetracker.google.com/issues/152245564 | |||
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2' | |||
|
|||
def composeBom = platform("androidx.compose:compose-bom:2025.04.00") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we declare the versions in a dedicated file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done here: 74bddca 🚀
value = sessionUrl, | ||
onValueChange = onSessionUrlChanged, | ||
label = { | ||
Text(text = stringResource(id = R.string.session_url_hint)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No color or font size/style ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, just use the default text style, should suffice given it's simply a demo app for YDS.
onClick = onStartSessionClicked, | ||
enabled = sessionUrl.isNotBlank() | ||
) { | ||
Text(text = stringResource(id = R.string.start_session_button)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No color or font size/style ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comment above.
webapp/build.gradle
Outdated
@@ -54,4 +54,6 @@ dependencies { | |||
implementation 'androidx.compose.material3:material3' | |||
implementation 'androidx.activity:activity-compose' | |||
debugImplementation 'androidx.compose.ui:ui-tooling' | |||
|
|||
implementation 'androidx.navigation:navigation-compose:2.8.9' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok to have the version hardcoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done here: 74bddca 🚀
AndroidView( | ||
modifier = Modifier.fillMaxSize(), | ||
factory = { context -> | ||
WebView(context).apply { | ||
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG) | ||
configureSettings(settings) | ||
configureWebViewClient(this, onPageCommitVisible) | ||
configureWebChromeClient( | ||
this, | ||
onFilePathCallbackReady, | ||
onShowCameraAndFilePickerChooser | ||
) | ||
} | ||
}, | ||
update = { webView -> | ||
sessionUrl.takeIf { it.isNotBlank() }?.let { webView.loadUrl(it) } | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a dedicated @Composable private fun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done here: a78069a 🚀
text = { Text(stringResource(id = R.string.session_finished_dialog_text)) }, | ||
confirmButton = { | ||
TextButton(onClick = onConfirm) { | ||
Text(stringResource(id = R.string.session_finished_dialog_confirm_button)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No color or font size/style ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered above
Related to YD-6940
Related to YD-6940
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purpose
The sample
webapp
module was using the old View system and deprecated APIs. This PR updates it to use Jetpack Compose and handle insets for edge-to-edge display.Approach
Scope of changes
webapp
module UI.Checklist
Tagged
@lampkicking/android-dev