Fix intent-handling logic

* Strip the intent action after handling so it doesn't get evaluated multiple times
 * Only check intents after authentication
This commit is contained in:
Jakob Nixdorf 2019-10-31 09:42:12 +01:00
parent 20a4512699
commit 551c73c637
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -277,8 +277,6 @@ public class MainActivity extends BaseActivity
setupDrawer();
checkIntent();
if (savedInstanceState != null){
setFilterString(savedInstanceState.getString("filterString", ""));
}
@ -287,13 +285,17 @@ public class MainActivity extends BaseActivity
private void checkIntent() {
Intent callingIntent = getIntent();
if (callingIntent != null && callingIntent.getAction() != null) {
if (callingIntent.getAction().equals(INTENT_SCAN_QR)) {
// Cache and reset the action to prevent the same intent from being evaluated multiple times
String intentAction = callingIntent.getAction();
callingIntent.setAction(null);
if (intentAction.equals(INTENT_SCAN_QR)) {
scanQRCode();
} else if (callingIntent.getAction().equals(INTENT_ENTER_DETAILS)) {
} else if (intentAction.equals(INTENT_ENTER_DETAILS)) {
ManualEntryDialog.show(MainActivity.this, settings, adapter);
} else if (callingIntent.getAction().equals(Intent.ACTION_VIEW) && !requireAuthentication) {
} else if (intentAction.equals(Intent.ACTION_VIEW)) {
try {
Entry entry = new Entry(getIntent().getDataString());
Entry entry = new Entry(callingIntent.getDataString());
entry.updateOTP();
entry.setLastUsed(System.currentTimeMillis());
adapter.addEntry(entry);
@ -336,8 +338,8 @@ public class MainActivity extends BaseActivity
updateEncryption(null);
} else {
populateAdapter();
checkIntent();
}
checkIntent();
}
}