Skip to content

Commit f5ffe2a

Browse files
committed
support restriction overshoots
1 parent ab4d06b commit f5ffe2a

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.13.16]
5+
6+
### Changed
7+
- The default scan area is now 20% bigger as the indicator indicates
8+
9+
### Added
10+
- Added setRestrictionOvershoot to BarcodeScannerView to increase the detection area by a
11+
multiplier based on the indicator
12+
413
## [0.13.15]
514

615
### Added
716
- Now warming up the image cache when adding items to the shopping cart
17+
- Added setRestrictionOvershoot to BarcodeScannerView to increase the detection area by a
18+
multiplier based on the indicator
19+
20+
### Changed
21+
- The default scan area is now 15% bigger as the indicator indicates
822

923
## [0.13.14]
1024

ui/src/main/java/io/snabble/sdk/ui/scanner/BarcodeScannerView.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public class BarcodeScannerView extends FrameLayout implements TextureView.Surfa
8181
private TextView cameraUnavailableView;
8282
private int displayOrientation;
8383
private boolean restrictScanningToIndicator = true;
84+
private float restrictionOvershoot = 1.0f;
8485
private int bitsPerPixel;
8586
private boolean indicatorEnabled = true;
8687
private FrameLayout splashView;
@@ -725,6 +726,22 @@ public void setIndicatorOffset(int offsetX, int offsetY) {
725726
*/
726727
public void setRestrictScanningToIndicator(boolean restrictScanningToIndicator) {
727728
this.restrictScanningToIndicator = restrictScanningToIndicator;
729+
updateTransform();
730+
}
731+
732+
/**
733+
* Sets the multiplicaton value that is used to allow scanning outside of the indicator if
734+
* {@link #setRestrictScanningToIndicator(boolean)} is set
735+
*
736+
* Default is 1.0
737+
*/
738+
public void setRestrictionOvershoot(float val) {
739+
if (val == 0.0f) {
740+
val = 1.0f;
741+
}
742+
743+
restrictionOvershoot = val;
744+
updateTransform();
728745
}
729746

730747
private void updateTransform() {
@@ -801,6 +818,14 @@ private void updateTransform() {
801818
rect = new Rect(0, 0, getWidth(), getHeight());
802819
}
803820

821+
rect.inset(Math.round(rect.width() * (1.0f - restrictionOvershoot)),
822+
Math.round(rect.height() * (1.0f - restrictionOvershoot)));
823+
824+
rect.left = Math.max(0, rect.left);
825+
rect.top = Math.max(0, rect.top);
826+
rect.right = Math.min(getWidth(), rect.right);
827+
rect.bottom = Math.min(getHeight(), rect.bottom);
828+
804829
float left = offsetX + surfaceWidth * ((float) rect.left / surfaceWidth);
805830
float top = offsetY + surfaceHeight * ((float) rect.top / surfaceHeight);
806831
float right = offsetX + surfaceWidth * ((float) rect.right / surfaceWidth);

ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public void onClick(View v) {
120120
});
121121

122122
barcodeScanner.setIndicatorOffset(0, Utils.dp2px(getContext(), -36));
123+
barcodeScanner.setRestrictionOvershoot(1.15f);
123124

124125
for (BarcodeFormat format : project.getSupportedBarcodeFormats()) {
125126
barcodeScanner.addBarcodeFormat(format);

0 commit comments

Comments
 (0)