Merge pull request #688 from jhenninger/feature/receive-shared-image

Add support for creating entries from shared images
This commit is contained in:
Alexander Bakker 2021-02-17 12:01:17 +01:00 committed by GitHub
commit 085e8e51dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View file

@ -48,6 +48,13 @@
<data android:scheme="otpauth" /> <data android:scheme="otpauth" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity> </activity>
<activity <activity
android:name=".ui.ScannerActivity" android:name=".ui.ScannerActivity"

View file

@ -300,7 +300,10 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
private void onScanImageResult(Intent intent) { private void onScanImageResult(Intent intent) {
Uri inputFile = (intent.getData()); decodeQrCodeImage(intent.getData());
}
private void decodeQrCodeImage(Uri inputFile) {
Bitmap bitmap; Bitmap bitmap;
try { try {
@ -431,6 +434,23 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
} }
private void handleSharedImage() {
if (_app.isVaultLocked()) {
return;
}
Intent intent = getIntent();
String action = intent.getAction();
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (Intent.ACTION_SEND.equals(action) && uri != null) {
intent.setAction(null);
intent.removeExtra(Intent.EXTRA_STREAM);
decodeQrCodeImage(uri);
}
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@ -475,6 +495,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
handleDeeplink(); handleDeeplink();
handleSharedImage();
updateLockIcon(); updateLockIcon();
doShortcutActions(); doShortcutActions();
updateBackupErrorBar(); updateBackupErrorBar();