Skip to content

Commit

Permalink
Merge pull request #8 from OutSystems/feat/RMET-2763/scan-orientation
Browse files Browse the repository at this point in the history
RMET-2763 OSBarcodeLib-Android - Scan Orientation
  • Loading branch information
alexgerardojacinto authored Nov 20, 2023
2 parents a268dc3 + 68c06fa commit 6102584
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ The changes documented here do not include those from the original repository.

## [Unreleased]

### 17-11-2023
Android - Implement Scan Orientation (Portrait, Landscape, Adaptive) (https://outsystemsrd.atlassian.net/browse/RMET-2763)

### 16-11-2023
Android - Implement Scan Button (https://outsystemsrd.atlassian.net/browse/RMET-2762)

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>0.0.23</version>
<version>0.0.24</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.outsystems.plugins.barcode.view
import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
Expand Down Expand Up @@ -73,6 +74,8 @@ class OSBARCScannerActivity : ComponentActivity() {
private const val LOG_TAG = "OSBARCScannerActivity"
private const val SCAN_PARAMETERS = "SCAN_PARAMETERS"
private const val CAM_DIRECTION_FRONT = 2
private const val ORIENTATION_PORTRAIT = 1
private const val ORIENTATION_LANDSCAPE = 2
}

/**
Expand All @@ -81,8 +84,15 @@ class OSBARCScannerActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
actionBar?.hide()

val parameters = intent.extras?.getSerializable(SCAN_PARAMETERS) as OSBARCScanParameters

// possibly lock orientation, the screen is adaptive by default
if (parameters.scanOrientation == ORIENTATION_PORTRAIT) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
} else if (parameters.scanOrientation == ORIENTATION_LANDSCAPE) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
}

scanning = !parameters.scanButton
selector = CameraSelector.Builder()
.requireLensFacing(if (parameters.cameraDirection == CAM_DIRECTION_FRONT) CameraSelector.LENS_FACING_FRONT else CameraSelector.LENS_FACING_BACK)
Expand Down

0 comments on commit 6102584

Please sign in to comment.