Skip to content

Commit

Permalink
RMET-3597 ::: Android 15 - Support edge-to-edge and drop Configuratio…
Browse files Browse the repository at this point in the history
…n for layout size (#37)

* fix: edge-to-edge support for barcode scan on Android 15

References: https://outsystemsrd.atlassian.net/browse/RMET-3597

* fix: replace configuration with WindowMetrics to retrieve screen size

Left orientation as-is because it only impacts close-to-square devices

References: https://outsystemsrd.atlassian.net/browse/RMET-3597

* chore: Update CHANGELOG.md

References: https://outsystemsrd.atlassian.net/browse/RMET-3597

* chore: set pom.xml version to dev

---------

Co-authored-by: Alexandre Jacinto <[email protected]>
  • Loading branch information
1 parent 27f00e4 commit af98889
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

The changes documented here do not include those from the original repository.

## [Unreleased]

### 05-11-2024
- Fix: Edge-to-edge support on Android 15 (https://outsystemsrd.atlassian.net/browse/RMET-3597)

## [1.1.4]

### 08-10-2024
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ dependencies {
implementation "androidx.activity:activity-compose:1.4.0"
implementation 'androidx.compose.material3:material3:1.0.0'
implementation 'androidx.compose.material3:material3-window-size-class:1.0.0'
implementation 'androidx.window:window:1.3.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.outsystems</groupId>
<artifactId>osbarcode-android</artifactId>
<version>1.1.4</version>
<version>1.1.5-dev</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.drawscope.clipPath
import androidx.compose.ui.graphics.toComposeRect
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
Expand All @@ -89,6 +90,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import androidx.window.layout.WindowMetricsCalculator
import com.outsystems.plugins.barcode.R
import com.outsystems.plugins.barcode.controller.OSBARCBarcodeAnalyzer
import com.outsystems.plugins.barcode.controller.OSBARCScanLibraryFactory
Expand Down Expand Up @@ -286,7 +288,6 @@ class OSBARCScannerActivity : ComponentActivity() {
Box(
modifier = Modifier
.fillMaxSize()
.safeDrawingPadding()
) {
AndroidView(
factory = { context ->
Expand Down Expand Up @@ -338,8 +339,13 @@ class OSBARCScannerActivity : ComponentActivity() {
fun ScanScreenUI(parameters: OSBARCScanParameters, windowSizeClass: WindowSizeClass) {
// actual UI on top of the camera stream
val configuration = LocalConfiguration.current
screenHeight = configuration.screenHeightDp.dp
screenWidth = configuration.screenWidthDp.dp
val windowMetrics =
WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(this)
val rect = windowMetrics.bounds.toComposeRect()
with(LocalDensity.current) {
screenHeight = rect.height.toDp()
screenWidth = rect.width.toDp()
}

val isPortrait = configuration.orientation == Configuration.ORIENTATION_PORTRAIT

Expand Down Expand Up @@ -505,7 +511,8 @@ class OSBARCScannerActivity : ComponentActivity() {
modifier = Modifier
.fillMaxWidth()
.background(ScannerBackgroundBlack)
.weight(1f, fill = true),
.weight(1f, fill = true)
.safeDrawingPadding(),
) {
CloseButton(
modifier = Modifier
Expand Down Expand Up @@ -541,7 +548,8 @@ class OSBARCScannerActivity : ComponentActivity() {
modifier = Modifier
.fillMaxWidth()
.background(ScannerBackgroundBlack)
.weight(1f, fill = true),
.weight(1f, fill = true)
.safeDrawingPadding(),
) {
val showTorch = camera.cameraInfo.hasFlashUnit()
val showScan = parameters.scanButton
Expand Down Expand Up @@ -651,6 +659,7 @@ class OSBARCScannerActivity : ComponentActivity() {
rightButtonsWidth = with(density) { coordinates.size.width.toDp() }
}
.background(ScannerBackgroundBlack)
.safeDrawingPadding()
) {

CloseButton(
Expand Down

0 comments on commit af98889

Please sign in to comment.