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-3682 - Prepare to release version 1.1.4 #36

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

## [1.1.4]

### 08-10-2024
- Fix: Make Scanner view wider on landscape and on tablets (https://outsystemsrd.atlassian.net/browse/RMET-3682).

## [1.1.3]

### 22-08-2024
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.3</version>
<version>1.1.4</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
Expand Down Expand Up @@ -76,8 +77,10 @@ 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.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
Expand Down Expand Up @@ -390,20 +393,15 @@ class OSBARCScannerActivity : ComponentActivity() {

// rectangle size is determined by removing the padding from the border of the screen
// and the padding to the corners of the rectangle
var rectWidth: Float
var rectHeight: Float
var rectWidth: Float = canvasWidth - (ScannerAimRectCornerPadding.toPx() * 2)
var rectHeight: Float = canvasHeight - (verticalPadding.toPx() * 2) - (ScannerAimRectCornerPadding.toPx() * 2)

if (isPhone) { // for phones
rectWidth = canvasWidth - (horizontalPadding.toPx() * 2) - (ScannerAimRectCornerPadding.toPx() * 2)
rectHeight = canvasHeight - (verticalPadding.toPx() * 2) - (ScannerAimRectCornerPadding.toPx() * 2)
} else { // for tablets
if (isPortrait) {
rectWidth = (canvasWidth) - (horizontalPadding.toPx() * 2) - (ScannerAimRectCornerPadding.toPx() * 2)
rectHeight = rectWidth
} else {
rectWidth = canvasWidth - (horizontalPadding.toPx() * 2) - (ScannerAimRectCornerPadding.toPx() * 2)
rectHeight = canvasHeight - (ScannerAimRectCornerPadding.toPx() * 2)
}
} else { // for tablets
rectHeight = minOf(rectWidth, canvasHeight - (ScannerAimRectCornerPadding.toPx() * 2))
}

val rectLeft = (canvasWidth - rectWidth) / 2
Expand All @@ -423,10 +421,13 @@ class OSBARCScannerActivity : ComponentActivity() {
drawRect(color = ScannerBackgroundBlack)
}

val aimTop = rectTop - ScannerAimRectCornerPadding.toPx()
val aimLeft = rectLeft - ScannerAimRectCornerPadding.toPx()
val aimRight = aimLeft + rectWidth + (ScannerAimRectCornerPadding * 2).toPx()
val aimBottom = aimTop + rectHeight + (ScannerAimRectCornerPadding * 2).toPx()
val strokeWidth = ScannerAimStrokeWidth
val halfStroke = strokeWidth / 2

val aimTop = rectTop - ScannerAimRectCornerPadding.toPx() + halfStroke
val aimLeft = rectLeft - ScannerAimRectCornerPadding.toPx() + halfStroke
val aimRight = aimLeft + rectWidth + (ScannerAimRectCornerPadding * 2).toPx() - strokeWidth
val aimBottom = aimTop + rectHeight + (ScannerAimRectCornerPadding * 2).toPx() - strokeWidth
val aimLength = ScannerAimCornerLength.toPx()

val aimPath = Path()
Expand Down Expand Up @@ -466,7 +467,7 @@ class OSBARCScannerActivity : ComponentActivity() {
Point(aimRight - radius, aimTop),
Point(aimRight - aimLength, aimTop)
)
drawPath(aimPath, color = ScanAimWhite, style = Stroke(width = ScannerAimStrokeWidth))
drawPath(aimPath, color = ScanAimWhite, style = Stroke(width = strokeWidth))
}
)
}
Expand Down Expand Up @@ -591,23 +592,27 @@ class OSBARCScannerActivity : ComponentActivity() {
textToRectPadding: Dp,
isPhone: Boolean,
isPortrait: Boolean) {
var rightButtonsWidth by remember { mutableStateOf(0.dp) }
val density = LocalDensity.current

Row(
modifier = Modifier
.fillMaxSize(),
horizontalArrangement = Arrangement.SpaceBetween
) {

Box(
// Left spacer to maintain horizontal conformance
Spacer(
modifier = Modifier
.fillMaxHeight()
.weight(1f, fill = true)
.width(rightButtonsWidth)
.background(ScannerBackgroundBlack)
)

// Center column with scanning area
Column(
modifier = Modifier
.fillMaxHeight()
.weight(2f, fill = true),
.weight(1f),
verticalArrangement = Arrangement.Center
) {

Expand Down Expand Up @@ -636,13 +641,15 @@ class OSBARCScannerActivity : ComponentActivity() {
.weight(1f, fill = true)
.background(ScannerBackgroundBlack)
)

}

// Right column with buttons
Box(
modifier = Modifier
.fillMaxHeight()
.weight(1f, fill = true)
.onGloballyPositioned { coordinates ->
rightButtonsWidth = with(density) { coordinates.size.width.toDp() }
}
.background(ScannerBackgroundBlack)
) {

Expand All @@ -654,7 +661,7 @@ class OSBARCScannerActivity : ComponentActivity() {

Column(
modifier = Modifier
.padding(end = ScannerBorderPadding)
.padding(start = 12.dp, end = ScannerBorderPadding)
.align(Alignment.CenterEnd),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.End
Expand Down