-
Notifications
You must be signed in to change notification settings - Fork 2
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
RMET-2912 OSBarcodeLib-Android - Screen UI for Tablet and only scan frame area #10
Conversation
Context: According to Android's documentation, we should use the Window size classes to determine if the device the app is running on is a phone or a tablet. When in Portrait, we should use the window width to determine this (99.96% of phones will have a compact width). When in Landscape, the height of the window should be used (99.78% of phones will have a compact height). More info here: https://developer.android.com/guide/topics/large-screens/support-different-screen-sizes#window_size_classes, and here: https://developer.android.com/jetpack/compose/layouts/adaptive References: https://outsystemsrd.atlassian.net/browse/RMET-2912
Context: According to Android's documentation, we should use the Window size classes to determine if the device the app is running on is a phone or a tablet. When in Portrait, we should use the window width to determine this (99.96% of phones will have a compact width). When in Landscape, the height of the window should be used (99.78% of phones will have a compact height). More info here: https://developer.android.com/guide/topics/large-screens/support-different-screen-sizes#window_size_classes, and here: https://developer.android.com/jetpack/compose/layouts/adaptive Why we are using the landscape UI (ScanScreenUILandscape) for tablets for both orientations, portrait and landscape: because for tablets, the arrangement of the elements in the screen is always the same, in a row, where the buttons are to the right of the scan area (rectangle). This way, we can avoid code repetition. References: https://outsystemsrd.atlassian.net/browse/RMET-2912
Context: Since we want to "crop" the image passed to analyze, we need to use a Bitmap object to represent the image, so that we can "crop" it. This wouldn't be possible using the ImageProxy object directly. References: https://outsystemsrd.atlassian.net/browse/RMET-2912
Context: Since we want to "crop" the image passed to analyze, we need to use a Bitmap object to represent the image, so that we can "crop" it. This wouldn't be possible using the ImageProxy object directly. Since both libraries (ZXing and MLKit) now use a Bitmap, we might as well refactor the code and avoid code repetition. References: https://outsystemsrd.atlassian.net/browse/RMET-2912
Context: Since we only want to look for barcodes within the frame, we need to crop the image (bitmap) to analyze, before passing it to MLKit or ZXing. References: https://outsystemsrd.atlassian.net/browse/RMET-2912https://outsystemsrd.atlassian.net/browse/RMET-2912
val image = InputImage.fromMediaImage( | ||
mediaImage, | ||
val image = InputImage.fromBitmap( | ||
imageBitmap, | ||
imageProxy.imageInfo.rotationDegrees | ||
) | ||
runBlocking { |
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 needed to use runBlocking here when MLKit already provides the async work?
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.
You're right, nice catch! We don't need to use runBlocking
in this case. I think we used to have more code after scanner.process(image)
and so that's why it had the runBlocking
.
Context: The call to scanner.process is asynchronous, as it should be. As such, we don't need to use runBlocking here. References: https://outsystemsrd.atlassian.net/browse/RMET-2912
Kudos, SonarCloud Quality Gate passed! |
Description
Bitmap
objects for both libraries. Before, we were only using bitmaps for ZXing, because MLKit can deal withImageProxy
objects. Since we want to crop the image, we need to use aBitmap
. This way, we also avoid code repetition.Context
References: https://outsystemsrd.atlassian.net/browse/RMET-2912
Type of changes
Platforms affected
Tests
MABS 9 build: https://intranet.outsystems.net/MABS/BuildDetail.aspx?BuildId=ed8778ad27785e820008bbd3ffcc4ea52e3e0f62
MABS 10 build: https://intranet.outsystems.net/MABS/BuildDetail.aspx?BuildId=5c41618abb4ebfa0044ef94a00a88bfa971e5153
Tested in Pixel 7 with Android 14, and Pixel C tablet emulator with Android 14.
Screenshots (if appropriate)
UI for Tablets:
Portrait
Landscape
Only scan the frame area:
screen-20231206-180638.mp4
Checklist
RNMT-XXXX <title>