Enable sharing text to Aegis

This commit is contained in:
elena 2022-08-11 21:32:33 +01:00
parent 85e230c46a
commit 5bb32a982b
3 changed files with 20 additions and 2 deletions

View file

@ -55,6 +55,7 @@
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity

View file

@ -493,12 +493,28 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
}
break;
case Intent.ACTION_SEND:
uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (uri != null) {
if (intent.hasExtra(Intent.EXTRA_STREAM)) {
uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
intent.setAction(null);
intent.removeExtra(Intent.EXTRA_STREAM);
startDecodeQrCodeImages(Collections.singletonList(uri));
}
if (intent.hasExtra(Intent.EXTRA_TEXT)) {
String stringExtra = intent.getStringExtra(Intent.EXTRA_TEXT);
intent.setAction(null);
intent.removeExtra(Intent.EXTRA_TEXT);
GoogleAuthInfo info;
try {
info = GoogleAuthInfo.parseUri(stringExtra);
} catch (GoogleAuthInfoException e) {
Dialogs.showErrorDialog(this, R.string.unable_to_process_shared_text, e);
break;
}
VaultEntry entry = new VaultEntry(info);
startEditEntryActivityForNew(CODE_ADD_ENTRY, entry);
}
break;
case Intent.ACTION_SEND_MULTIPLE:
List<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);

View file

@ -289,6 +289,7 @@
</plurals>
<string name="unable_to_process_deeplink">Unable to process deep link</string>
<string name="unable_to_read_qrcode_file">Unable to read and process QR code from file: %s.</string>
<string name="unable_to_process_shared_text">Unable to process shared text as OTP</string>
<string name="unable_to_read_qrcode_files">Unable to read and process some of the QR codes. Only %d/%d entries will be imported.</string>
<string name="unable_to_generate_qrcode">Unable to generate QR code</string>
<string name="select_picture">Select picture</string>