From 2347f9c57e186a7c5281777f846aef41b4fad932 Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Tue, 3 Oct 2023 21:10:06 +0200 Subject: [PATCH] Error when camera permission denied --- .../code_guard/scanner/QRScannerActivity.java | 9 +++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 10 insertions(+) diff --git a/app/src/main/java/com/cringe_studios/code_guard/scanner/QRScannerActivity.java b/app/src/main/java/com/cringe_studios/code_guard/scanner/QRScannerActivity.java index cd0846d..0fb4666 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/scanner/QRScannerActivity.java +++ b/app/src/main/java/com/cringe_studios/code_guard/scanner/QRScannerActivity.java @@ -83,6 +83,15 @@ public class QRScannerActivity extends BaseActivity { scanner = new QRScanner(); } + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + + if(requestCode == 1234 && grantResults[0] != PackageManager.PERMISSION_GRANTED) { + error(getString(R.string.error_no_camera_permission)); + } + } + void bindPreview(@NonNull ProcessCameraProvider cameraProvider) { Preview preview = new Preview.Builder() .build(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 18cab12..c0d3b13 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -149,6 +149,7 @@ "Failed to read image: " Icon pack already exists Failed to import icon pack + No camera permission Image from icon pack Image from gallery