Skip to content
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-2761 OSBarcodeLib-Android - Scan Instructions and Scan Button #7

Merged
merged 14 commits into from
Nov 17, 2023

Conversation

alexgerardojacinto
Copy link
Collaborator

@alexgerardojacinto alexgerardojacinto commented Nov 16, 2023

Description

  • This PR adds two different functionalities:
    • Scan Instructions: Text shown on the screen with instructions to the user. This is implemented in a Text composable.
    • Scan Button: Button used to start scanning. This is implemented in a Button composable. A scanning variable is used, and we only want to process scan results when it is true, which can happen either when there's no scan button at all, or after the scan button has been pressed.

Context

References:

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android
  • iOS
  • JavaScript

Tests

Tested on Android 14 (Pixel 7)

Screenshots (if appropriate)

screen-20231117-101012.mp4

Checklist

  • Pull request title follows the format RNMT-XXXX <title>
  • Code follows code style of this project
  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

Context: If there are scan instructions in the scan parameters, we present them in a Text composable (https://developer.android.com/jetpack/compose/text).

References: https://outsystemsrd.atlassian.net/browse/RMET-2761
Context: This way, when the text has to be presented in more than 1 line, it is centered.

References: https://outsystemsrd.atlassian.net/browse/RMET-2761
Context: When there's a scan button, we only want to start scanning when the button in clicked. For now, this behaviour is "faked" by us only sending the barcode result when the button in clicked.

References: https://outsystemsrd.atlassian.net/browse/RMET-2762
Context: This refactor was necessary to reduce the cognitive complexity of the ScanScreen method, as pointed out by SonarCloud.

References: https://outsystemsrd.atlassian.net/browse/RMET-2762
@alexgerardojacinto alexgerardojacinto changed the title Feat/rmet 2761/scan instructions RMET-2761 OSBarcodeLib-Android - Scan Instructions and Scan Button Nov 17, 2023
@alexgerardojacinto alexgerardojacinto self-assigned this Nov 17, 2023
@alexgerardojacinto alexgerardojacinto marked this pull request as ready for review November 17, 2023 10:12
import com.outsystems.plugins.barcode.controller.OSBARCBarcodeAnalyzer
import com.outsystems.plugins.barcode.controller.OSBARCScanLibraryFactory
import com.outsystems.plugins.barcode.controller.helper.OSBARCMLKitHelper
import com.outsystems.plugins.barcode.controller.helper.OSBARCZXingHelper
import com.outsystems.plugins.barcode.model.OSBARCError
import com.outsystems.plugins.barcode.model.OSBARCScanParameters
import com.outsystems.plugins.barcode.view.ui.theme.BarcodeScannerTheme
import com.outsystems.plugins.barcode.view.ui.theme.CustomGray
import com.outsystems.plugins.barcode.R
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure this compiles on MABS because because the R class won't always be under this package.
For instance, on camera, this was the solution:
https://github.com/OutSystems/OSCameraLib-Android/blob/ae2c03c57c82cf8fe852a23a099fc273bb6f2651/src/main/kotlin/com/outsystems/plugins/camera/view/ImageEditorView.kt#L99

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point. However, since this is the Android library, the path to the package of the R class will always be the same - import com.outsystems.plugins.barcode.R. Moreover, it is safer to access a resource directly through the R class than using a getResource function based on the resource's id, that may not exist.

dialogTitle = "Camera Access Not Enabled",
dialogText = "To continue, please go to the Settings app and enable it.",
confirmButtonText = "Settings",
dismissButtonText = "Ok"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought.
Could theses strings be moved into the res/strings.xml file? 🤔
I'm not sure though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point. I believe we can do that when we tackle dynamic values for these fields, using different Locales.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@alexgerardojacinto alexgerardojacinto merged commit a268dc3 into development Nov 17, 2023
4 checks passed
@alexgerardojacinto alexgerardojacinto deleted the feat/RMET-2761/scan-instructions branch January 10, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants