summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sample/src/main/java/example/zxing/CustomScannerActivity.java5
-rw-r--r--sample/src/main/res/layout/custom_barcode_scanner.xml1
-rwxr-xr-xzxing-android-embedded/res/values/zxing_attrs.xml1
-rwxr-xr-xzxing-android-embedded/src/com/journeyapps/barcodescanner/ViewfinderView.java22
4 files changed, 23 insertions, 6 deletions
diff --git a/sample/src/main/java/example/zxing/CustomScannerActivity.java b/sample/src/main/java/example/zxing/CustomScannerActivity.java
index 2292e59f..12840733 100644
--- a/sample/src/main/java/example/zxing/CustomScannerActivity.java
+++ b/sample/src/main/java/example/zxing/CustomScannerActivity.java
@@ -48,6 +48,7 @@ public class CustomScannerActivity extends Activity implements
capture.decode();
changeMaskColor(null);
+ changeLaserVisibility(true);
}
@Override
@@ -102,6 +103,10 @@ public class CustomScannerActivity extends Activity implements
viewfinderView.setMaskColor(color);
}
+ public void changeLaserVisibility(boolean visible) {
+ viewfinderView.setLaserVisibility(visible);
+ }
+
@Override
public void onTorchOn() {
switchFlashlightButton.setText(R.string.turn_off_flashlight);
diff --git a/sample/src/main/res/layout/custom_barcode_scanner.xml b/sample/src/main/res/layout/custom_barcode_scanner.xml
index 9460630e..8607280f 100644
--- a/sample/src/main/res/layout/custom_barcode_scanner.xml
+++ b/sample/src/main/res/layout/custom_barcode_scanner.xml
@@ -17,6 +17,7 @@
app:zxing_possible_result_points="@color/zxing_custom_possible_result_points"
app:zxing_result_view="@color/zxing_custom_result_view"
app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
+ app:zxing_viewfinder_laser_visibility="true"
app:zxing_viewfinder_mask="@color/zxing_custom_viewfinder_mask"/>
<TextView
diff --git a/zxing-android-embedded/res/values/zxing_attrs.xml b/zxing-android-embedded/res/values/zxing_attrs.xml
index b5960ea7..70eaece1 100755
--- a/zxing-android-embedded/res/values/zxing_attrs.xml
+++ b/zxing-android-embedded/res/values/zxing_attrs.xml
@@ -21,6 +21,7 @@
<attr name="zxing_result_view" format="color"/>
<attr name="zxing_viewfinder_laser" format="color"/>
<attr name="zxing_viewfinder_mask" format="color"/>
+ <attr name="zxing_viewfinder_laser_visibility" format="boolean"/>
</declare-styleable>
</resources>
diff --git a/zxing-android-embedded/src/com/journeyapps/barcodescanner/ViewfinderView.java b/zxing-android-embedded/src/com/journeyapps/barcodescanner/ViewfinderView.java
index 6f71a273..8891225d 100755
--- a/zxing-android-embedded/src/com/journeyapps/barcodescanner/ViewfinderView.java
+++ b/zxing-android-embedded/src/com/journeyapps/barcodescanner/ViewfinderView.java
@@ -54,6 +54,7 @@ public class ViewfinderView extends View {
protected final int resultColor;
protected final int laserColor;
protected final int resultPointColor;
+ protected boolean laserVisibility;
protected int scannerAlpha;
protected List<ResultPoint> possibleResultPoints;
protected List<ResultPoint> lastPossibleResultPoints;
@@ -84,6 +85,8 @@ public class ViewfinderView extends View {
resources.getColor(R.color.zxing_viewfinder_laser));
this.resultPointColor = attributes.getColor(R.styleable.zxing_finder_zxing_possible_result_points,
resources.getColor(R.color.zxing_possible_result_points));
+ this.laserVisibility = attributes.getBoolean(R.styleable.zxing_finder_zxing_viewfinder_laser_visibility,
+ true);
attributes.recycle();
@@ -160,13 +163,16 @@ public class ViewfinderView extends View {
paint.setAlpha(CURRENT_POINT_OPACITY);
canvas.drawBitmap(resultBitmap, null, frame, paint);
} else {
+ // If wanted, draw a red "laser scanner" line through the middle to show decoding is active
+ if (laserVisibility) {
+ paint.setColor(laserColor);
- // Draw a red "laser scanner" line through the middle to show decoding is active
- paint.setColor(laserColor);
- paint.setAlpha(SCANNER_ALPHA[scannerAlpha]);
- scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length;
- final int middle = frame.height() / 2 + frame.top;
- canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint);
+ paint.setAlpha(SCANNER_ALPHA[scannerAlpha]);
+ scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length;
+
+ final int middle = frame.height() / 2 + frame.top;
+ canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint);
+ }
final float scaleX = this.getWidth() / (float) previewSize.width;
final float scaleY = this.getHeight() / (float) previewSize.height;
@@ -247,4 +253,8 @@ public class ViewfinderView extends View {
public void setMaskColor(int maskColor) {
this.maskColor = maskColor;
}
+
+ public void setLaserVisibility(boolean visible) {
+ this.laserVisibility = visible;
+ }
}