mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 14:41:08 +00:00
Pass message ID to OpenKeychain
This commit is contained in:
parent
c535b3c72c
commit
4449e9fa6a
2 changed files with 17 additions and 11 deletions
|
@ -1283,6 +1283,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY_IDS);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, pgpUserIds);
|
||||
intent.putExtra(BuildConfig.APPLICATION_ID, working);
|
||||
onPgp(intent);
|
||||
} catch (Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
|
@ -1549,15 +1550,14 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
private void onPgp(Intent data) {
|
||||
final Bundle args = new Bundle();
|
||||
args.putLong("id", working);
|
||||
args.putParcelable("data", data);
|
||||
|
||||
new SimpleTask<Object>() {
|
||||
@Override
|
||||
protected Object onExecute(Context context, Bundle args) throws Throwable {
|
||||
// Get arguments
|
||||
long id = args.getLong("id");
|
||||
Intent data = args.getParcelable("data");
|
||||
long id = data.getLongExtra(BuildConfig.APPLICATION_ID, -1);
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
|
@ -1607,6 +1607,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
try {
|
||||
int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
|
||||
Log.i("Result action=" + data.getAction() + " code=" + resultCode);
|
||||
Log.logExtras(data);
|
||||
switch (resultCode) {
|
||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||
// Attach encrypted data / signature
|
||||
|
@ -1672,6 +1673,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyIds[0]);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||
intent.putExtra(BuildConfig.APPLICATION_ID, id);
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
@ -1684,11 +1686,13 @@ public class FragmentCompose extends FragmentBase {
|
|||
intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pgpKeyIds);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, identity.sign_key);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||
intent.putExtra(BuildConfig.APPLICATION_ID, id);
|
||||
return intent;
|
||||
} else {
|
||||
// Get sign key
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, pgpUserIds);
|
||||
intent.putExtra(BuildConfig.APPLICATION_ID, id);
|
||||
return intent;
|
||||
}
|
||||
} else if (OpenPgpApi.ACTION_GET_SIGN_KEY_ID.equals(data.getAction())) {
|
||||
|
@ -1700,11 +1704,13 @@ public class FragmentCompose extends FragmentBase {
|
|||
intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pgpKeyIds);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||
intent.putExtra(BuildConfig.APPLICATION_ID, id);
|
||||
return intent;
|
||||
} else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) {
|
||||
// Get signature
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_DETACHED_SIGN);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId);
|
||||
intent.putExtra(BuildConfig.APPLICATION_ID, id);
|
||||
return null;
|
||||
} else {
|
||||
// send message
|
||||
|
|
|
@ -3756,13 +3756,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
private void onDecrypt(Intent intent) {
|
||||
if (pgpService.isBound()) {
|
||||
Intent data = new Intent();
|
||||
data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
|
||||
|
||||
long id = intent.getLongExtra("id", -1);
|
||||
boolean auto = intent.getBooleanExtra("auto", false);
|
||||
|
||||
onDecrypt(data, id, auto);
|
||||
Intent data = new Intent();
|
||||
data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
|
||||
data.putExtra(BuildConfig.APPLICATION_ID, id);
|
||||
|
||||
onDecrypt(data, auto);
|
||||
} else
|
||||
Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -3779,7 +3780,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
break;
|
||||
case REQUEST_DECRYPT:
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
onDecrypt(data, message, false);
|
||||
onDecrypt(data, false);
|
||||
break;
|
||||
case REQUEST_MESSAGE_DELETE:
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
|
@ -3942,9 +3943,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}.execute(this, args, "raw:save");
|
||||
}
|
||||
|
||||
private void onDecrypt(Intent data, long id, boolean auto) {
|
||||
private void onDecrypt(Intent data, boolean auto) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putParcelable("data", data);
|
||||
args.putBoolean("auto", auto);
|
||||
|
||||
|
@ -3952,9 +3952,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
@Override
|
||||
protected PendingIntent onExecute(Context context, Bundle args) throws Throwable {
|
||||
// Get arguments
|
||||
long id = args.getLong("id");
|
||||
boolean auto = args.getBoolean("auto");
|
||||
Intent data = args.getParcelable("data");
|
||||
long id = data.getLongExtra(BuildConfig.APPLICATION_ID, -1);
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
EntityMessage message = db.message().getMessage(id);
|
||||
|
@ -4019,6 +4019,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
|
||||
Log.i("Result action=" + data.getAction() + " code=" + resultCode);
|
||||
Log.logExtras(data);
|
||||
switch (resultCode) {
|
||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||
if (inline) {
|
||||
|
@ -4092,7 +4093,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
||||
if (auto)
|
||||
return null;
|
||||
FragmentMessages.this.message = id;
|
||||
return result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
||||
|
||||
case OpenPgpApi.RESULT_CODE_ERROR:
|
||||
|
|
Loading…
Reference in a new issue