diff options
-rw-r--r-- | quickReader/res/values/strings.xml | 3 | ||||
-rw-r--r-- | quickReader/src/org/lineageos/quickreader/ScannerActivity.java | 22 |
2 files changed, 21 insertions, 4 deletions
diff --git a/quickReader/res/values/strings.xml b/quickReader/res/values/strings.xml index 897483115..8633b7c73 100644 --- a/quickReader/res/values/strings.xml +++ b/quickReader/res/values/strings.xml @@ -47,4 +47,7 @@ <string name="quick_reader_share_title">Share with\u2026</string> <!-- QuickReader: toast shown when the scanned text has been copied to the clipboard --> <string name="quick_reader_copied_message">Copied to clipboard</string> + + <!-- QuickReader: Action is only allowed when performed unlocked --> + <string name="quick_reader_only_unlocked">This action can only be performed with the device unlocked</string> </resources> diff --git a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java index 7ee6be2c6..e07cd584c 100644 --- a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java +++ b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The LineageOS Project + * Copyright (C) 2019-2020 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,8 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result super.onCreate(savedInstance); Intent intent = getIntent(); - if (intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false)) { + final boolean isSecure = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false); + if (isSecure) { // Change the window flags so that secure camera can show when locked Window win = getWindow(); WindowManager.LayoutParams params = win.getAttributes(); @@ -90,7 +91,13 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result mFlashIcon = (ImageView) findViewById(R.id.action_flash); ImageView closeIcon = (ImageView) findViewById(R.id.action_close); - mIdentifyLayout.setOnClickListener(v -> sHelper.run(this)); + mIdentifyLayout.setOnClickListener(v -> { + if (isSecure) { + showClickErrorDialog(); + } else { + sHelper.run(this); + } + }); mFlashIcon.setOnClickListener(v -> toggleFlash()); closeIcon.setOnClickListener(v -> finish()); @@ -208,6 +215,13 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result .show(); } + private void showClickErrorDialog() { + new AlertDialog.Builder(this) + .setMessage(R.string.quick_reader_only_unlocked) + .setPositiveButton(R.string.quick_reader_action_dismiss, null) + .show(); + } + private void postAnalyze(int result) { if (result == 0 || !sHelper.isValid()) { return; @@ -331,4 +345,4 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result return null; } } -}
\ No newline at end of file +} |