diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java index 1864324..709242b 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java @@ -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 diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java index 50a4800..cecbaca 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java @@ -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() {