summaryrefslogtreecommitdiff
path: root/sample/src/main/java/example/zxing/CustomScannerActivity.java
diff options
context:
space:
mode:
authorAmadeu Cavalcante <amadeu01@gmail.com>2018-10-16 03:24:58 +0300
committerAmadeu Cavalcante <amadeu01@gmail.com>2018-10-16 03:24:58 +0300
commit65aaa93a270990f2cf98b0861d11132eab173a83 (patch)
tree1a564fc533fab92824bd2712bb1ab30147347e73 /sample/src/main/java/example/zxing/CustomScannerActivity.java
parentaec45c4f10e3769d7449bcb7b82b5d09689512a4 (diff)
downloadzxing-android-embedded-65aaa93a270990f2cf98b0861d11132eab173a83.tar.xz
Added support for programmatically change ViewfinderView mask color
Diffstat (limited to 'sample/src/main/java/example/zxing/CustomScannerActivity.java')
-rw-r--r--sample/src/main/java/example/zxing/CustomScannerActivity.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/sample/src/main/java/example/zxing/CustomScannerActivity.java b/sample/src/main/java/example/zxing/CustomScannerActivity.java
index 6d301baa..1c0de0cb 100644
--- a/sample/src/main/java/example/zxing/CustomScannerActivity.java
+++ b/sample/src/main/java/example/zxing/CustomScannerActivity.java
@@ -2,6 +2,7 @@ package example.zxing;
import android.app.Activity;
import android.content.pm.PackageManager;
+import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
@@ -9,6 +10,9 @@ import android.widget.Button;
import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
+import com.journeyapps.barcodescanner.ViewfinderView;
+
+import java.util.Random;
/**
* Custom Scannner Activity extending from Activity to display a custom layout form scanner view.
@@ -19,6 +23,7 @@ public class CustomScannerActivity extends Activity implements
private CaptureManager capture;
private DecoratedBarcodeView barcodeScannerView;
private Button switchFlashlightButton;
+ private ViewfinderView viewfinderView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -30,6 +35,8 @@ public class CustomScannerActivity extends Activity implements
switchFlashlightButton = (Button)findViewById(R.id.switch_flashlight);
+ viewfinderView = (ViewfinderView) findViewById(R.id.zxing_viewfinder_view);
+
// if the device does not have flashlight in its camera,
// then remove the switch flashlight button...
if (!hasFlash()) {
@@ -87,6 +94,12 @@ public class CustomScannerActivity extends Activity implements
}
}
+ public void changeMaskColor(View view) {
+ Random rnd = new Random();
+ int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
+ viewfinderView.setMaskColor(color);
+ }
+
@Override
public void onTorchOn() {
switchFlashlightButton.setText(R.string.turn_off_flashlight);