Merge pull request #172 from michaelschattgen/feature-otpauthuri

Add support for deeplinking otpauth uris
This commit is contained in:
Alexander Bakker 2019-08-03 17:16:13 +02:00 committed by GitHub
commit 5dbf1c7ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View file

@ -29,6 +29,12 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="otpauth" />
</intent-filter>
</activity>
<activity
android:name=".ui.ScannerActivity"

View file

@ -402,6 +402,33 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
intent.removeExtra("action");
}
private void handleDeeplink() {
if (_db.isLocked()) {
return;
}
Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
getIntent().setData(null);
getIntent().setAction(null);
GoogleAuthInfo info = null;
try {
info = GoogleAuthInfo.parseUri(uri);
} catch (GoogleAuthInfoException e) {
Toast.makeText(this, getString(R.string.unable_to_read_qrcode), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
if (info != null) {
DatabaseEntry entry = new DatabaseEntry(info);
startEditProfileActivity(CODE_ADD_ENTRY, entry, true);
}
}
}
@Override
protected void onResume() {
super.onResume();
@ -431,6 +458,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
loadEntries();
}
handleDeeplink();
updateLockIcon();
doShortcutActions();
}