mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-11 13:38:06 -05:00
betterly store the information that the intent demands an immediate return, check action equality without verbose null checks
This commit is contained in:
parent
72b899fa79
commit
1d023b0372
@ -58,6 +58,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
|
|
||||||
private Intent mIntent;
|
private Intent mIntent;
|
||||||
|
|
||||||
|
private boolean mReturnResult = false;
|
||||||
private String mReplyTo = null;
|
private String mReplyTo = null;
|
||||||
private String mSubject = null;
|
private String mSubject = null;
|
||||||
private boolean mSignedOnly = false;
|
private boolean mSignedOnly = false;
|
||||||
@ -160,7 +161,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mIntent = getIntent();
|
mIntent = getIntent();
|
||||||
if (mIntent.getAction() != null && mIntent.getAction().equals(Intent.ACTION_VIEW)) {
|
if (Intent.ACTION_VIEW.equals(mIntent.getAction())) {
|
||||||
Uri uri = mIntent.getData();
|
Uri uri = mIntent.getData();
|
||||||
try {
|
try {
|
||||||
InputStream attachment = getContentResolver().openInputStream(uri);
|
InputStream attachment = getContentResolver().openInputStream(uri);
|
||||||
@ -178,7 +179,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// ignore, then
|
// ignore, then
|
||||||
}
|
}
|
||||||
} else if (mIntent.getAction() != null && mIntent.getAction().equals(Intent.ACTION_SEND)) {
|
} else if (Intent.ACTION_SEND.equals(mIntent.getAction())) {
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
extras = new Bundle();
|
extras = new Bundle();
|
||||||
@ -191,7 +192,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
if (mSubject.startsWith("Fwd: ")) {
|
if (mSubject.startsWith("Fwd: ")) {
|
||||||
mSubject = mSubject.substring(5);
|
mSubject = mSubject.substring(5);
|
||||||
}
|
}
|
||||||
} else if (mIntent.getAction() != null && mIntent.getAction().equals(Apg.Intent.DECRYPT)) {
|
} else if (Apg.Intent.DECRYPT.equals(mIntent.getAction())) {
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
extras = new Bundle();
|
extras = new Bundle();
|
||||||
@ -217,13 +218,13 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
mReplyTo = extras.getString(Apg.EXTRA_REPLY_TO);
|
mReplyTo = extras.getString(Apg.EXTRA_REPLY_TO);
|
||||||
mSubject = extras.getString(Apg.EXTRA_SUBJECT);
|
mSubject = extras.getString(Apg.EXTRA_SUBJECT);
|
||||||
} else if (mIntent.getAction() != null && mIntent.getAction().equals(Apg.Intent.DECRYPT_FILE)) {
|
} else if (Apg.Intent.DECRYPT_FILE.equals(mIntent.getAction())) {
|
||||||
mSource.setInAnimation(null);
|
mSource.setInAnimation(null);
|
||||||
mSource.setOutAnimation(null);
|
mSource.setOutAnimation(null);
|
||||||
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
||||||
mSource.showNext();
|
mSource.showNext();
|
||||||
}
|
}
|
||||||
} else if (mIntent.getAction() != null && mIntent.getAction().equals(Apg.Intent.DECRYPT_AND_RETURN)) {
|
} else if (Apg.Intent.DECRYPT_AND_RETURN.equals(mIntent.getAction())) {
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
extras = new Bundle();
|
extras = new Bundle();
|
||||||
@ -249,6 +250,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
mReplyTo = extras.getString(Apg.EXTRA_REPLY_TO);
|
mReplyTo = extras.getString(Apg.EXTRA_REPLY_TO);
|
||||||
mSubject = extras.getString(Apg.EXTRA_SUBJECT);
|
mSubject = extras.getString(Apg.EXTRA_SUBJECT);
|
||||||
|
mReturnResult = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSource.getCurrentView().getId() == R.id.sourceMessage &&
|
if (mSource.getCurrentView().getId() == R.id.sourceMessage &&
|
||||||
@ -588,8 +590,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
mSignatureLayout.setVisibility(View.VISIBLE);
|
mSignatureLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIntent.getAction() != null &&
|
if (mReturnResult) {
|
||||||
mIntent.getAction().equals(Apg.Intent.DECRYPT_AND_RETURN)) {
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtras(data);
|
intent.putExtras(data);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
|
@ -67,6 +67,7 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
|
|
||||||
private long mEncryptionKeyIds[] = null;
|
private long mEncryptionKeyIds[] = null;
|
||||||
|
|
||||||
|
private boolean mReturnResult = false;
|
||||||
private EditText mMessage = null;
|
private EditText mMessage = null;
|
||||||
private Button mSelectKeysButton = null;
|
private Button mSelectKeysButton = null;
|
||||||
private Button mEncryptButton = null;
|
private Button mEncryptButton = null;
|
||||||
@ -266,14 +267,18 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mIntent = getIntent();
|
mIntent = getIntent();
|
||||||
if (mIntent.getAction() != null &&
|
if (Apg.Intent.ENCRYPT.equals(mIntent.getAction()) ||
|
||||||
(mIntent.getAction().equals(Apg.Intent.ENCRYPT) ||
|
Apg.Intent.ENCRYPT_FILE.equals(mIntent.getAction()) ||
|
||||||
mIntent.getAction().equals(Apg.Intent.ENCRYPT_FILE) ||
|
Apg.Intent.ENCRYPT_AND_RETURN.equals(mIntent.getAction())) {
|
||||||
mIntent.getAction().equals(Apg.Intent.ENCRYPT_AND_RETURN))) {
|
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
extras = new Bundle();
|
extras = new Bundle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Apg.Intent.ENCRYPT_AND_RETURN.equals(mIntent.getAction())) {
|
||||||
|
mReturnResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
String data = extras.getString(Apg.EXTRA_DATA);
|
String data = extras.getString(Apg.EXTRA_DATA);
|
||||||
mSendTo = extras.getString(Apg.EXTRA_SEND_TO);
|
mSendTo = extras.getString(Apg.EXTRA_SEND_TO);
|
||||||
mSubject = extras.getString(Apg.EXTRA_SUBJECT);
|
mSubject = extras.getString(Apg.EXTRA_SUBJECT);
|
||||||
@ -319,8 +324,8 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIntent.getAction().equals(Apg.Intent.ENCRYPT) ||
|
if (Apg.Intent.ENCRYPT.equals(mIntent.getAction()) ||
|
||||||
mIntent.getAction().equals(Apg.Intent.ENCRYPT_AND_RETURN)) {
|
Apg.Intent.ENCRYPT_AND_RETURN.equals(mIntent.getAction())) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
mMessage.setText(data);
|
mMessage.setText(data);
|
||||||
}
|
}
|
||||||
@ -329,7 +334,7 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
|
while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
|
||||||
mSource.showNext();
|
mSource.showNext();
|
||||||
}
|
}
|
||||||
} else if (mIntent.getAction().equals(Apg.Intent.ENCRYPT_FILE)) {
|
} else if (Apg.Intent.ENCRYPT_FILE.equals(mIntent.getAction())) {
|
||||||
mSource.setInAnimation(null);
|
mSource.setInAnimation(null);
|
||||||
mSource.setOutAnimation(null);
|
mSource.setOutAnimation(null);
|
||||||
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
||||||
@ -556,9 +561,7 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
} else {
|
} else {
|
||||||
String message = mMessage.getText().toString();
|
String message = mMessage.getText().toString();
|
||||||
|
|
||||||
if (signOnly &&
|
if (signOnly && mReturnResult) {
|
||||||
!(mIntent != null &&
|
|
||||||
mIntent.getAction().equals(Apg.Intent.ENCRYPT_AND_RETURN))) {
|
|
||||||
// fix the message a bit, trailing spaces and newlines break stuff,
|
// fix the message a bit, trailing spaces and newlines break stuff,
|
||||||
// because GMail sends as HTML and such things fuck up the signature,
|
// because GMail sends as HTML and such things fuck up the signature,
|
||||||
// TODO: things like "<" and ">" also fuck up the signature
|
// TODO: things like "<" and ">" also fuck up the signature
|
||||||
@ -751,8 +754,7 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case Id.target.email: {
|
case Id.target.email: {
|
||||||
if (mIntent.getAction() != null &&
|
if (mReturnResult) {
|
||||||
mIntent.getAction().equals(Apg.Intent.ENCRYPT_AND_RETURN)) {
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtras(data);
|
intent.putExtras(data);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
|
Loading…
Reference in New Issue
Block a user