From 733f873ae32636f55307e0678712bcfdb1fce6ac Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Mon, 19 Apr 2021 16:21:37 +0200 Subject: [PATCH] Stop camera when exiting QR scan with back button (fixes #1614) (#1641) --- .../activities/QRScannerActivity.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/QRScannerActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/QRScannerActivity.java index 01eef49f..1bf9a0b3 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/QRScannerActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/QRScannerActivity.java @@ -44,12 +44,17 @@ public class QRScannerActivity extends ThemedAppCompatActivity implements Barcod this.barcodeView = findViewById(R.id.bar_code_scanner_view); findViewById(R.id.cancel_button).setOnClickListener(view -> { - pauseScanner(); - finish(); + finishScanning(); }); checkPermissionAndStartScanner(); } + + @Override + protected void onStop() { + super.onStop(); + finishScanning(); + } // endregion // region === Permissions Callback === @@ -72,7 +77,7 @@ public class QRScannerActivity extends ThemedAppCompatActivity implements Barcod Intent intent = new Intent(); intent.putExtra(QR_RESULT_ARG, code); setResult(Activity.RESULT_OK, intent); - finish(); + finishScanning(); } @Override @@ -96,8 +101,9 @@ public class QRScannerActivity extends ThemedAppCompatActivity implements Barcod this.barcodeView.decodeSingle(this); } - private void pauseScanner() { + private void finishScanning() { this.barcodeView.pause(); + finish(); } // endregion }