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 fullyLaunched;
|
||||||
|
|
||||||
|
private boolean lockOnPause = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -59,6 +61,8 @@ public class MainActivity extends BaseActivity {
|
|||||||
qrScanner = new QRScanner();
|
qrScanner = new QRScanner();
|
||||||
|
|
||||||
startQRCodeScan = registerForActivityResult(new QRScannerContract(), obj -> {
|
startQRCodeScan = registerForActivityResult(new QRScannerContract(), obj -> {
|
||||||
|
lockOnPause = true;
|
||||||
|
|
||||||
if(obj == null) return; // Cancelled
|
if(obj == null) return; // Cancelled
|
||||||
|
|
||||||
if(!obj.isSuccess()) {
|
if(!obj.isSuccess()) {
|
||||||
@ -204,6 +208,7 @@ public class MainActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void scanCode() {
|
public void scanCode() {
|
||||||
|
lockOnPause = false;
|
||||||
startQRCodeScan.launch(null);
|
startQRCodeScan.launch(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +309,7 @@ public class MainActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
OTPDatabase.unloadDatabase();
|
if(lockOnPause) OTPDatabase.unloadDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,7 +121,7 @@ public class GroupFragment extends NamedFragment {
|
|||||||
if(vh == null) continue;
|
if(vh == null) continue;
|
||||||
try {
|
try {
|
||||||
vh.getBinding().otpCode.setText(OTPListItem.formatCode(vh.getOTPData().getPin()));
|
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());
|
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() {
|
public void addOTP() {
|
||||||
// TODO
|
// TODO
|
||||||
|
requireActivity().openOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void viewOTP() {
|
public void viewOTP() {
|
||||||
|
Loading…
Reference in New Issue
Block a user