diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5c6d57ba..42208050 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,6 +27,13 @@ + + + + + + + diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java index b7de7cd9..06c6b937 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java @@ -277,18 +277,33 @@ public class MainActivity extends BaseActivity setupDrawer(); + checkIntent(); + + if (savedInstanceState != null){ + setFilterString(savedInstanceState.getString("filterString", "")); + } + } + + private void checkIntent() { Intent callingIntent = getIntent(); if (callingIntent != null && callingIntent.getAction() != null) { if (callingIntent.getAction().equals(INTENT_SCAN_QR)) { scanQRCode(); } else if (callingIntent.getAction().equals(INTENT_ENTER_DETAILS)) { ManualEntryDialog.show(MainActivity.this, settings, adapter); + } else if (callingIntent.getAction().equals(Intent.ACTION_VIEW) && !requireAuthentication) { + try { + Entry entry = new Entry(getIntent().getDataString()); + entry.updateOTP(); + entry.setLastUsed(System.currentTimeMillis()); + adapter.addEntry(entry); + adapter.saveEntries(); + Toast.makeText(this, R.string.toast_intent_creation_succeeded, Toast.LENGTH_LONG).show(); + } catch (Exception e) { + Toast.makeText(this, R.string.toast_intent_creation_failed, Toast.LENGTH_LONG).show(); + } } } - - if (savedInstanceState != null){ - setFilterString(savedInstanceState.getString("filterString", "")); - } } @Override @@ -321,6 +336,7 @@ public class MainActivity extends BaseActivity updateEncryption(null); } else { populateAdapter(); + checkIntent(); } } } diff --git a/app/src/main/res/values/strings_main.xml b/app/src/main/res/values/strings_main.xml index 68e730e9..6aba68ca 100644 --- a/app/src/main/res/values/strings_main.xml +++ b/app/src/main/res/values/strings_main.xml @@ -10,7 +10,7 @@ Settings All tags No tags - + %d s @@ -59,6 +59,8 @@ This entry already exists Invalid QR Code Encryption key not loaded + Invalid intent-provided code + Intent-provided code added Authenticate