Don't lock app when scanning QR code
This commit is contained in:
parent
62b049202e
commit
2b18b591e3
@ -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
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user