Don't lock app when scanning QR code

This commit is contained in:
MrLetsplay 2023-09-24 12:30:16 +02:00
parent 62b049202e
commit 2b18b591e3
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 8 additions and 2 deletions

View File

@ -50,6 +50,8 @@ public class MainActivity extends BaseActivity {
private boolean fullyLaunched;
private boolean lockOnPause = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -59,6 +61,8 @@ public class MainActivity extends BaseActivity {
qrScanner = new QRScanner();
startQRCodeScan = registerForActivityResult(new QRScannerContract(), obj -> {
lockOnPause = true;
if(obj == null) return; // Cancelled
if(!obj.isSuccess()) {
@ -204,6 +208,7 @@ public class MainActivity extends BaseActivity {
}
public void scanCode() {
lockOnPause = false;
startQRCodeScan.launch(null);
}
@ -304,7 +309,7 @@ public class MainActivity extends BaseActivity {
@Override
protected void onStop() {
super.onStop();
OTPDatabase.unloadDatabase();
if(lockOnPause) OTPDatabase.unloadDatabase();
}
@Override

View File

@ -121,7 +121,7 @@ public class GroupFragment extends NamedFragment {
if(vh == null) continue;
try {
vh.getBinding().otpCode.setText(OTPListItem.formatCode(vh.getOTPData().getPin()));
} catch (OTPException e) {
} catch (Exception e) {
DialogUtil.showErrorDialog(requireContext(), e.getMessage() == null ? "An error occurred while refreshing the code" : e.getMessage());
}
@ -135,6 +135,7 @@ public class GroupFragment extends NamedFragment {
public void addOTP() {
// TODO
requireActivity().openOptionsMenu();
}
public void viewOTP() {