Pass message ID to OpenKeychain

pull/167/head
M66B 6 years ago
parent c535b3c72c
commit 4449e9fa6a

@ -1283,6 +1283,7 @@ public class FragmentCompose extends FragmentBase {
Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY_IDS); Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY_IDS);
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, pgpUserIds); intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, pgpUserIds);
intent.putExtra(BuildConfig.APPLICATION_ID, working);
onPgp(intent); onPgp(intent);
} catch (Throwable ex) { } catch (Throwable ex) {
if (ex instanceof IllegalArgumentException) if (ex instanceof IllegalArgumentException)
@ -1549,15 +1550,14 @@ public class FragmentCompose extends FragmentBase {
private void onPgp(Intent data) { private void onPgp(Intent data) {
final Bundle args = new Bundle(); final Bundle args = new Bundle();
args.putLong("id", working);
args.putParcelable("data", data); args.putParcelable("data", data);
new SimpleTask<Object>() { new SimpleTask<Object>() {
@Override @Override
protected Object onExecute(Context context, Bundle args) throws Throwable { protected Object onExecute(Context context, Bundle args) throws Throwable {
// Get arguments // Get arguments
long id = args.getLong("id");
Intent data = args.getParcelable("data"); Intent data = args.getParcelable("data");
long id = data.getLongExtra(BuildConfig.APPLICATION_ID, -1);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
@ -1607,6 +1607,7 @@ public class FragmentCompose extends FragmentBase {
try { try {
int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
Log.i("Result action=" + data.getAction() + " code=" + resultCode); Log.i("Result action=" + data.getAction() + " code=" + resultCode);
Log.logExtras(data);
switch (resultCode) { switch (resultCode) {
case OpenPgpApi.RESULT_CODE_SUCCESS: case OpenPgpApi.RESULT_CODE_SUCCESS:
// Attach encrypted data / signature // Attach encrypted data / signature
@ -1672,6 +1673,7 @@ public class FragmentCompose extends FragmentBase {
Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY); Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY);
intent.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyIds[0]); intent.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyIds[0]);
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
intent.putExtra(BuildConfig.APPLICATION_ID, id);
return intent; return intent;
} }
} }
@ -1684,11 +1686,13 @@ public class FragmentCompose extends FragmentBase {
intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pgpKeyIds); intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pgpKeyIds);
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, identity.sign_key); intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, identity.sign_key);
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
intent.putExtra(BuildConfig.APPLICATION_ID, id);
return intent; return intent;
} else { } else {
// Get sign key // Get sign key
Intent intent = new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID); Intent intent = new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, pgpUserIds); intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, pgpUserIds);
intent.putExtra(BuildConfig.APPLICATION_ID, id);
return intent; return intent;
} }
} else if (OpenPgpApi.ACTION_GET_SIGN_KEY_ID.equals(data.getAction())) { } 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_KEY_IDS, pgpKeyIds);
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId); intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId);
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
intent.putExtra(BuildConfig.APPLICATION_ID, id);
return intent; return intent;
} else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) { } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) {
// Get signature // Get signature
Intent intent = new Intent(OpenPgpApi.ACTION_DETACHED_SIGN); Intent intent = new Intent(OpenPgpApi.ACTION_DETACHED_SIGN);
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId); intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId);
intent.putExtra(BuildConfig.APPLICATION_ID, id);
return null; return null;
} else { } else {
// send message // send message

@ -3756,13 +3756,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private void onDecrypt(Intent intent) { private void onDecrypt(Intent intent) {
if (pgpService.isBound()) { if (pgpService.isBound()) {
Intent data = new Intent();
data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
long id = intent.getLongExtra("id", -1); long id = intent.getLongExtra("id", -1);
boolean auto = intent.getBooleanExtra("auto", false); 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 } else
Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_LONG).show(); Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_LONG).show();
} }
@ -3779,7 +3780,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
break; break;
case REQUEST_DECRYPT: case REQUEST_DECRYPT:
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
onDecrypt(data, message, false); onDecrypt(data, false);
break; break;
case REQUEST_MESSAGE_DELETE: case REQUEST_MESSAGE_DELETE:
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
@ -3942,9 +3943,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}.execute(this, args, "raw:save"); }.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(); Bundle args = new Bundle();
args.putLong("id", id);
args.putParcelable("data", data); args.putParcelable("data", data);
args.putBoolean("auto", auto); args.putBoolean("auto", auto);
@ -3952,9 +3952,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override @Override
protected PendingIntent onExecute(Context context, Bundle args) throws Throwable { protected PendingIntent onExecute(Context context, Bundle args) throws Throwable {
// Get arguments // Get arguments
long id = args.getLong("id");
boolean auto = args.getBoolean("auto"); boolean auto = args.getBoolean("auto");
Intent data = args.getParcelable("data"); Intent data = args.getParcelable("data");
long id = data.getLongExtra(BuildConfig.APPLICATION_ID, -1);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id); 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); int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
Log.i("Result action=" + data.getAction() + " code=" + resultCode); Log.i("Result action=" + data.getAction() + " code=" + resultCode);
Log.logExtras(data);
switch (resultCode) { switch (resultCode) {
case OpenPgpApi.RESULT_CODE_SUCCESS: case OpenPgpApi.RESULT_CODE_SUCCESS:
if (inline) { if (inline) {
@ -4092,7 +4093,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
if (auto) if (auto)
return null; return null;
FragmentMessages.this.message = id;
return result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); return result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
case OpenPgpApi.RESULT_CODE_ERROR: case OpenPgpApi.RESULT_CODE_ERROR:

Loading…
Cancel
Save