mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 05:02:26 -05:00
Code style
No functional changes
This commit is contained in:
parent
3a02bfb0a9
commit
a9cfa9ae68
@ -383,36 +383,36 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
@Override
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_PROGRESS_ON:
|
||||
setSupportProgressBarIndeterminateVisibility(true);
|
||||
break;
|
||||
case MSG_PROGRESS_OFF:
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
break;
|
||||
case MSG_SKIPPED_ATTACHMENTS:
|
||||
Toast.makeText(
|
||||
MessageCompose.this,
|
||||
getString(R.string.message_compose_attachments_skipped_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case MSG_SAVED_DRAFT:
|
||||
Toast.makeText(
|
||||
MessageCompose.this,
|
||||
getString(R.string.message_saved_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case MSG_DISCARDED_DRAFT:
|
||||
Toast.makeText(
|
||||
MessageCompose.this,
|
||||
getString(R.string.message_discarded_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case MSG_PERFORM_STALLED_ACTION:
|
||||
performStalledAction();
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
break;
|
||||
case MSG_PROGRESS_ON:
|
||||
setSupportProgressBarIndeterminateVisibility(true);
|
||||
break;
|
||||
case MSG_PROGRESS_OFF:
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
break;
|
||||
case MSG_SKIPPED_ATTACHMENTS:
|
||||
Toast.makeText(
|
||||
MessageCompose.this,
|
||||
getString(R.string.message_compose_attachments_skipped_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case MSG_SAVED_DRAFT:
|
||||
Toast.makeText(
|
||||
MessageCompose.this,
|
||||
getString(R.string.message_saved_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case MSG_DISCARDED_DRAFT:
|
||||
Toast.makeText(
|
||||
MessageCompose.this,
|
||||
getString(R.string.message_discarded_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case MSG_PERFORM_STALLED_ACTION:
|
||||
performStalledAction();
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -562,8 +562,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
mMessageReference = intent.getParcelableExtra(EXTRA_MESSAGE_REFERENCE);
|
||||
mSourceMessageBody = intent.getStringExtra(EXTRA_MESSAGE_BODY);
|
||||
|
||||
if (K9.DEBUG && mSourceMessageBody != null)
|
||||
if (K9.DEBUG && mSourceMessageBody != null) {
|
||||
Log.d(K9.LOG_TAG, "Composing message with explicitly specified message body.");
|
||||
}
|
||||
|
||||
final String accountUuid = (mMessageReference != null) ?
|
||||
mMessageReference.accountUuid :
|
||||
@ -1390,16 +1391,14 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
textBodyBuilder.setAppendSignature(true);
|
||||
textBodyBuilder.setSignature(mSignatureView.getCharacters());
|
||||
textBodyBuilder.setSignatureBeforeQuotedText(mAccount.isSignatureBeforeQuotedText());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
textBodyBuilder.setAppendSignature(false);
|
||||
}
|
||||
|
||||
TextBody body;
|
||||
if (messageFormat == SimpleMessageFormat.HTML) {
|
||||
body = textBodyBuilder.buildTextHtml();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
body = textBodyBuilder.buildTextPlain();
|
||||
}
|
||||
return body;
|
||||
@ -1552,8 +1551,8 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
* title*3="isn't it!"
|
||||
*/
|
||||
bp.addHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, String.format(Locale.US,
|
||||
"attachment;\r\n filename=\"%s\";\r\n size=%d",
|
||||
attachment.name, attachment.size));
|
||||
"attachment;\r\n filename=\"%s\";\r\n size=%d",
|
||||
attachment.name, attachment.size));
|
||||
|
||||
mp.addBodyPart(bp);
|
||||
}
|
||||
@ -1686,8 +1685,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
private Map<IdentityField, String> parseIdentityHeader(final String identityString) {
|
||||
Map<IdentityField, String> identity = new HashMap<IdentityField, String>();
|
||||
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "Decoding identity: " + identityString);
|
||||
}
|
||||
|
||||
if (identityString == null || identityString.length() < 1) {
|
||||
return identity;
|
||||
@ -1705,8 +1705,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "Decoded identity: " + identity.toString());
|
||||
}
|
||||
|
||||
// Sanity check our Integers so that recipients of this result don't have to.
|
||||
for (IdentityField key : IdentityField.getIntegerFields()) {
|
||||
@ -1721,8 +1722,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
} else {
|
||||
// Legacy identity
|
||||
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "Got a saved legacy identity: " + identityString);
|
||||
}
|
||||
StringTokenizer tokenizer = new StringTokenizer(identityString, ":", false);
|
||||
|
||||
// First item is the body length. We use this to separate the composed reply from the quoted text.
|
||||
@ -1824,19 +1826,19 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
}
|
||||
emailsArray = emails.toArray(new String[emails.size()]);
|
||||
}
|
||||
if (mEncryptCheckbox.isChecked() && mCryptoSignatureCheckbox.isChecked()) {
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, emailsArray);
|
||||
executeOpenPgpMethod(intent);
|
||||
} else if (mCryptoSignatureCheckbox.isChecked()) {
|
||||
String text = buildText(false).getText();
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN);
|
||||
executeOpenPgpMethod(intent);
|
||||
} else if (mEncryptCheckbox.isChecked()) {
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_ENCRYPT);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, emailsArray);
|
||||
executeOpenPgpMethod(intent);
|
||||
}
|
||||
if (mEncryptCheckbox.isChecked() && mCryptoSignatureCheckbox.isChecked()) {
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, emailsArray);
|
||||
executeOpenPgpMethod(intent);
|
||||
} else if (mCryptoSignatureCheckbox.isChecked()) {
|
||||
String text = buildText(false).getText();
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN);
|
||||
executeOpenPgpMethod(intent);
|
||||
} else if (mEncryptCheckbox.isChecked()) {
|
||||
Intent intent = new Intent(OpenPgpApi.ACTION_ENCRYPT);
|
||||
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, emailsArray);
|
||||
executeOpenPgpMethod(intent);
|
||||
}
|
||||
|
||||
// onSend() is called again in SignEncryptCallback and with
|
||||
// encryptedData set in pgpData!
|
||||
@ -1884,8 +1886,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
sendMessage();
|
||||
|
||||
if (mMessageReference != null && mMessageReference.flag != null) {
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "Setting referenced message (" + mMessageReference.folderName + ", " + mMessageReference.uid + ") flag to " + mMessageReference.flag);
|
||||
}
|
||||
|
||||
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
|
||||
final String folderName = mMessageReference.folderName;
|
||||
@ -1945,8 +1948,8 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
final String output = os.toString("UTF-8");
|
||||
|
||||
if (K9.DEBUG)
|
||||
Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length
|
||||
+ " str=" + output);
|
||||
Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length +
|
||||
" str=" + output);
|
||||
|
||||
mPgpData.setEncryptedData(output);
|
||||
onSend();
|
||||
@ -2278,71 +2281,72 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
return;
|
||||
}
|
||||
|
||||
if (resultCode != RESULT_OK)
|
||||
if (resultCode != RESULT_OK) {
|
||||
return;
|
||||
}
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
switch (requestCode) {
|
||||
case ACTIVITY_REQUEST_PICK_ATTACHMENT:
|
||||
addAttachmentsFromResultIntent(data);
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case CONTACT_PICKER_TO:
|
||||
case CONTACT_PICKER_CC:
|
||||
case CONTACT_PICKER_BCC:
|
||||
ContactItem contact = mContacts.extractInfoFromContactPickerIntent(data);
|
||||
if (contact == null) {
|
||||
Toast.makeText(this, getString(R.string.error_contact_address_not_found), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (contact.emailAddresses.size() > 1) {
|
||||
Intent i = new Intent(this, EmailAddressList.class);
|
||||
i.putExtra(EmailAddressList.EXTRA_CONTACT_ITEM, contact);
|
||||
case ACTIVITY_REQUEST_PICK_ATTACHMENT:
|
||||
addAttachmentsFromResultIntent(data);
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case CONTACT_PICKER_TO:
|
||||
case CONTACT_PICKER_CC:
|
||||
case CONTACT_PICKER_BCC:
|
||||
ContactItem contact = mContacts.extractInfoFromContactPickerIntent(data);
|
||||
if (contact == null) {
|
||||
Toast.makeText(this, getString(R.string.error_contact_address_not_found), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (contact.emailAddresses.size() > 1) {
|
||||
Intent i = new Intent(this, EmailAddressList.class);
|
||||
i.putExtra(EmailAddressList.EXTRA_CONTACT_ITEM, contact);
|
||||
|
||||
if (requestCode == CONTACT_PICKER_TO) {
|
||||
startActivityForResult(i, CONTACT_PICKER_TO2);
|
||||
} else if (requestCode == CONTACT_PICKER_CC) {
|
||||
startActivityForResult(i, CONTACT_PICKER_CC2);
|
||||
} else if (requestCode == CONTACT_PICKER_BCC) {
|
||||
startActivityForResult(i, CONTACT_PICKER_BCC2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (K9.DEBUG) {
|
||||
List<String> emails = contact.emailAddresses;
|
||||
for (int i = 0; i < emails.size(); i++) {
|
||||
Log.v(K9.LOG_TAG, "email[" + i + "]: " + emails.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String email = contact.emailAddresses.get(0);
|
||||
if (requestCode == CONTACT_PICKER_TO) {
|
||||
startActivityForResult(i, CONTACT_PICKER_TO2);
|
||||
addAddress(mToView, new Address(email, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_CC) {
|
||||
startActivityForResult(i, CONTACT_PICKER_CC2);
|
||||
addAddress(mCcView, new Address(email, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_BCC) {
|
||||
startActivityForResult(i, CONTACT_PICKER_BCC2);
|
||||
addAddress(mBccView, new Address(email, ""));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (K9.DEBUG) {
|
||||
List<String> emails = contact.emailAddresses;
|
||||
for (int i = 0; i < emails.size(); i++) {
|
||||
Log.v(K9.LOG_TAG, "email[" + i + "]: " + emails.get(i));
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case CONTACT_PICKER_TO2:
|
||||
case CONTACT_PICKER_CC2:
|
||||
case CONTACT_PICKER_BCC2:
|
||||
String emailAddr = data.getStringExtra(EmailAddressList.EXTRA_EMAIL_ADDRESS);
|
||||
if (requestCode == CONTACT_PICKER_TO2) {
|
||||
addAddress(mToView, new Address(emailAddr, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_CC2) {
|
||||
addAddress(mCcView, new Address(emailAddr, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_BCC2) {
|
||||
addAddress(mBccView, new Address(emailAddr, ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String email = contact.emailAddresses.get(0);
|
||||
if (requestCode == CONTACT_PICKER_TO) {
|
||||
addAddress(mToView, new Address(email, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_CC) {
|
||||
addAddress(mCcView, new Address(email, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_BCC) {
|
||||
addAddress(mBccView, new Address(email, ""));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case CONTACT_PICKER_TO2:
|
||||
case CONTACT_PICKER_CC2:
|
||||
case CONTACT_PICKER_BCC2:
|
||||
String emailAddr = data.getStringExtra(EmailAddressList.EXTRA_EMAIL_ADDRESS);
|
||||
if (requestCode == CONTACT_PICKER_TO2) {
|
||||
addAddress(mToView, new Address(emailAddr, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_CC2) {
|
||||
addAddress(mCcView, new Address(emailAddr, ""));
|
||||
} else if (requestCode == CONTACT_PICKER_BCC2) {
|
||||
addAddress(mBccView, new Address(emailAddr, ""));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2459,39 +2463,39 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.attachment_delete:
|
||||
/*
|
||||
* The view is the delete button, and we have previously set the tag of
|
||||
* the delete button to the view that owns it. We don't use parent because the
|
||||
* view is very complex and could change in the future.
|
||||
*/
|
||||
mAttachments.removeView((View) view.getTag());
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case R.id.quoted_text_show:
|
||||
showOrHideQuotedText(QuotedTextMode.SHOW);
|
||||
updateMessageFormat();
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case R.id.quoted_text_delete:
|
||||
showOrHideQuotedText(QuotedTextMode.HIDE);
|
||||
updateMessageFormat();
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case R.id.quoted_text_edit:
|
||||
mForcePlainText = true;
|
||||
if (mMessageReference != null) { // shouldn't happen...
|
||||
// TODO - Should we check if mSourceMessageBody is already present and bypass the MessagingController call?
|
||||
MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
|
||||
final String folderName = mMessageReference.folderName;
|
||||
final String sourceMessageUid = mMessageReference.uid;
|
||||
MessagingController.getInstance(getApplication()).loadMessageForView(account, folderName, sourceMessageUid, null);
|
||||
}
|
||||
break;
|
||||
case R.id.identity:
|
||||
showDialog(DIALOG_CHOOSE_IDENTITY);
|
||||
break;
|
||||
case R.id.attachment_delete:
|
||||
/*
|
||||
* The view is the delete button, and we have previously set the tag of
|
||||
* the delete button to the view that owns it. We don't use parent because the
|
||||
* view is very complex and could change in the future.
|
||||
*/
|
||||
mAttachments.removeView((View) view.getTag());
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case R.id.quoted_text_show:
|
||||
showOrHideQuotedText(QuotedTextMode.SHOW);
|
||||
updateMessageFormat();
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case R.id.quoted_text_delete:
|
||||
showOrHideQuotedText(QuotedTextMode.HIDE);
|
||||
updateMessageFormat();
|
||||
mDraftNeedsSaving = true;
|
||||
break;
|
||||
case R.id.quoted_text_edit:
|
||||
mForcePlainText = true;
|
||||
if (mMessageReference != null) { // shouldn't happen...
|
||||
// TODO - Should we check if mSourceMessageBody is already present and bypass the MessagingController call?
|
||||
MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||
final Account account = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
|
||||
final String folderName = mMessageReference.folderName;
|
||||
final String sourceMessageUid = mMessageReference.uid;
|
||||
MessagingController.getInstance(getApplication()).loadMessageForView(account, folderName, sourceMessageUid, null);
|
||||
}
|
||||
break;
|
||||
case R.id.identity:
|
||||
showDialog(DIALOG_CHOOSE_IDENTITY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2538,36 +2542,36 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.send:
|
||||
mPgpData.setEncryptionKeys(null);
|
||||
onSend();
|
||||
break;
|
||||
case R.id.save:
|
||||
if (mEncryptCheckbox.isChecked()) {
|
||||
showDialog(DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED);
|
||||
} else {
|
||||
onSave();
|
||||
}
|
||||
break;
|
||||
case R.id.discard:
|
||||
onDiscard();
|
||||
break;
|
||||
case R.id.add_cc_bcc:
|
||||
onAddCcBcc();
|
||||
break;
|
||||
case R.id.add_attachment:
|
||||
onAddAttachment();
|
||||
break;
|
||||
case R.id.add_attachment_image:
|
||||
onAddAttachment2("image/*");
|
||||
break;
|
||||
case R.id.add_attachment_video:
|
||||
onAddAttachment2("video/*");
|
||||
break;
|
||||
case R.id.read_receipt:
|
||||
onReadReceipt();
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
case R.id.send:
|
||||
mPgpData.setEncryptionKeys(null);
|
||||
onSend();
|
||||
break;
|
||||
case R.id.save:
|
||||
if (mEncryptCheckbox.isChecked()) {
|
||||
showDialog(DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED);
|
||||
} else {
|
||||
onSave();
|
||||
}
|
||||
break;
|
||||
case R.id.discard:
|
||||
onDiscard();
|
||||
break;
|
||||
case R.id.add_cc_bcc:
|
||||
onAddCcBcc();
|
||||
break;
|
||||
case R.id.add_attachment:
|
||||
onAddAttachment();
|
||||
break;
|
||||
case R.id.add_attachment_image:
|
||||
onAddAttachment2("image/*");
|
||||
break;
|
||||
case R.id.add_attachment_video:
|
||||
onAddAttachment2("video/*");
|
||||
break;
|
||||
case R.id.read_receipt:
|
||||
onReadReceipt();
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -2665,94 +2669,94 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
@Override
|
||||
public Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
case DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.save_or_discard_draft_message_dlg_title)
|
||||
.setMessage(R.string.save_or_discard_draft_message_instructions_fmt)
|
||||
.setPositiveButton(R.string.save_draft_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
|
||||
onSave();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
|
||||
onDiscard();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.refuse_to_save_draft_marked_encrypted_dlg_title)
|
||||
.setMessage(R.string.refuse_to_save_draft_marked_encrypted_instructions_fmt)
|
||||
.setNeutralButton(R.string.okay_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.continue_without_public_key_dlg_title)
|
||||
.setMessage(R.string.continue_without_public_key_instructions_fmt)
|
||||
.setPositiveButton(R.string.continue_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY);
|
||||
mContinueWithoutPublicKey = true;
|
||||
onSend();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.back_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY);
|
||||
mContinueWithoutPublicKey = false;
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_CONFIRM_DISCARD_ON_BACK:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.confirm_discard_draft_message_title)
|
||||
.setMessage(R.string.confirm_discard_draft_message)
|
||||
.setPositiveButton(R.string.cancel_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
|
||||
Toast.makeText(MessageCompose.this,
|
||||
getString(R.string.message_discarded_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
onDiscard();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_CHOOSE_IDENTITY:
|
||||
Context context = new ContextThemeWrapper(this,
|
||||
(K9.getK9Theme() == K9.Theme.LIGHT) ?
|
||||
R.style.Theme_K9_Dialog_Light :
|
||||
R.style.Theme_K9_Dialog_Dark);
|
||||
Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(R.string.send_as);
|
||||
final IdentityAdapter adapter = new IdentityAdapter(context);
|
||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
IdentityContainer container = (IdentityContainer) adapter.getItem(which);
|
||||
onAccountChosen(container.account, container.identity);
|
||||
}
|
||||
});
|
||||
case DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.save_or_discard_draft_message_dlg_title)
|
||||
.setMessage(R.string.save_or_discard_draft_message_instructions_fmt)
|
||||
.setPositiveButton(R.string.save_draft_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
|
||||
onSave();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
|
||||
onDiscard();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.refuse_to_save_draft_marked_encrypted_dlg_title)
|
||||
.setMessage(R.string.refuse_to_save_draft_marked_encrypted_instructions_fmt)
|
||||
.setNeutralButton(R.string.okay_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.continue_without_public_key_dlg_title)
|
||||
.setMessage(R.string.continue_without_public_key_instructions_fmt)
|
||||
.setPositiveButton(R.string.continue_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY);
|
||||
mContinueWithoutPublicKey = true;
|
||||
onSend();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.back_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY);
|
||||
mContinueWithoutPublicKey = false;
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_CONFIRM_DISCARD_ON_BACK:
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.confirm_discard_draft_message_title)
|
||||
.setMessage(R.string.confirm_discard_draft_message)
|
||||
.setPositiveButton(R.string.cancel_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
|
||||
Toast.makeText(MessageCompose.this,
|
||||
getString(R.string.message_discarded_toast),
|
||||
Toast.LENGTH_LONG).show();
|
||||
onDiscard();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_CHOOSE_IDENTITY:
|
||||
Context context = new ContextThemeWrapper(this,
|
||||
(K9.getK9Theme() == K9.Theme.LIGHT) ?
|
||||
R.style.Theme_K9_Dialog_Light :
|
||||
R.style.Theme_K9_Dialog_Dark);
|
||||
Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(R.string.send_as);
|
||||
final IdentityAdapter adapter = new IdentityAdapter(context);
|
||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
IdentityContainer container = (IdentityContainer) adapter.getItem(which);
|
||||
onAccountChosen(container.account, container.identity);
|
||||
}
|
||||
});
|
||||
|
||||
return builder.create();
|
||||
return builder.create();
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
@ -2889,8 +2893,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
}
|
||||
|
||||
} else {
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "could not get Message-ID.");
|
||||
}
|
||||
}
|
||||
|
||||
// Quote the message and setup the UI.
|
||||
@ -3283,10 +3288,10 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
List<Integer> start = new ArrayList<Integer>();
|
||||
List<Integer> end = new ArrayList<Integer>();
|
||||
|
||||
while(blockquoteStart.find()) {
|
||||
while (blockquoteStart.find()) {
|
||||
start.add(blockquoteStart.start());
|
||||
}
|
||||
while(blockquoteEnd.find()) {
|
||||
while (blockquoteEnd.find()) {
|
||||
end.add(blockquoteEnd.start());
|
||||
}
|
||||
if (start.size() != end.size()) {
|
||||
@ -3301,8 +3306,8 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
} else {
|
||||
for (int i = 0; i < start.size() - 1; i++) {
|
||||
// within blockquotes.
|
||||
if (end.get(i) < start.get(i+1)) {
|
||||
dashSignatureHtml.region(end.get(i), start.get(i+1));
|
||||
if (end.get(i) < start.get(i + 1)) {
|
||||
dashSignatureHtml.region(end.get(i), start.get(i + 1));
|
||||
if (dashSignatureHtml.find()) {
|
||||
content = content.substring(0, dashSignatureHtml.start());
|
||||
break;
|
||||
@ -3389,30 +3394,34 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
// HTML takes precedence, then text.
|
||||
part = MimeUtility.findFirstPartByMimeType(message, "text/html");
|
||||
if (part != null) {
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "getBodyTextFromMessage: HTML requested, HTML found.");
|
||||
}
|
||||
return MimeUtility.getTextFromPart(part);
|
||||
}
|
||||
|
||||
part = MimeUtility.findFirstPartByMimeType(message, "text/plain");
|
||||
if (part != null) {
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "getBodyTextFromMessage: HTML requested, text found.");
|
||||
}
|
||||
return HtmlConverter.textToHtml(MimeUtility.getTextFromPart(part));
|
||||
}
|
||||
} else if (format == SimpleMessageFormat.TEXT) {
|
||||
// Text takes precedence, then html.
|
||||
part = MimeUtility.findFirstPartByMimeType(message, "text/plain");
|
||||
if (part != null) {
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "getBodyTextFromMessage: Text requested, text found.");
|
||||
}
|
||||
return MimeUtility.getTextFromPart(part);
|
||||
}
|
||||
|
||||
part = MimeUtility.findFirstPartByMimeType(message, "text/html");
|
||||
if (part != null) {
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "getBodyTextFromMessage: Text requested, HTML found.");
|
||||
}
|
||||
return HtmlConverter.htmlToText(MimeUtility.getTextFromPart(part));
|
||||
}
|
||||
}
|
||||
@ -3479,8 +3488,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
hasBodyTag = true;
|
||||
}
|
||||
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "Open: hasHtmlTag:" + hasHtmlTag + " hasHeadTag:" + hasHeadTag + " hasBodyTag:" + hasBodyTag);
|
||||
}
|
||||
|
||||
// Given our inspections, let's figure out where to start our content.
|
||||
// This is the ideal case -- there's a BODY tag and we insert ourselves just after it.
|
||||
@ -3531,8 +3541,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
hasBodyEndTag = true;
|
||||
}
|
||||
|
||||
if (K9.DEBUG)
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, "Close: hasHtmlEndTag:" + hasHtmlEndTag + " hasBodyEndTag:" + hasBodyEndTag);
|
||||
}
|
||||
|
||||
// Now figure out where to put our footer.
|
||||
// This is the ideal case -- there's a BODY tag and we insert ourselves just before it.
|
||||
|
@ -76,13 +76,13 @@ public class TextBodyBuilder {
|
||||
*/
|
||||
if (mReplyAfterQuote) {
|
||||
quotedHtmlContent.setInsertionLocation(
|
||||
InsertableHtmlContent.InsertionLocation.AFTER_QUOTE);
|
||||
InsertableHtmlContent.InsertionLocation.AFTER_QUOTE);
|
||||
if (mInsertSeparator) {
|
||||
text = "<br clear=\"all\">" + text;
|
||||
}
|
||||
} else {
|
||||
quotedHtmlContent.setInsertionLocation(
|
||||
InsertableHtmlContent.InsertionLocation.BEFORE_QUOTE);
|
||||
InsertableHtmlContent.InsertionLocation.BEFORE_QUOTE);
|
||||
if (mInsertSeparator) {
|
||||
text += "<br><br>";
|
||||
}
|
||||
|
@ -12,13 +12,13 @@ import com.fsck.k9.activity.InsertableHtmlContent;
|
||||
class TestingTextBodyBuilder extends TextBodyBuilder {
|
||||
|
||||
public TestingTextBodyBuilder(boolean includeQuotedText,
|
||||
boolean isDraft,
|
||||
QuoteStyle quoteStyle,
|
||||
boolean replyAfterQuote,
|
||||
boolean signatureBeforeQuotedText,
|
||||
boolean useSignature,
|
||||
String messageText,
|
||||
String signatureText) {
|
||||
boolean isDraft,
|
||||
QuoteStyle quoteStyle,
|
||||
boolean replyAfterQuote,
|
||||
boolean signatureBeforeQuotedText,
|
||||
boolean useSignature,
|
||||
String messageText,
|
||||
String signatureText) {
|
||||
super(messageText);
|
||||
|
||||
includeQuotedText = (isDraft || includeQuotedText);
|
||||
@ -56,15 +56,15 @@ public class TextBodyBuilderTest {
|
||||
public static boolean[] BOOLEANS = { true, false };
|
||||
|
||||
@DataPoints
|
||||
public static QuoteStyle[] QUOTESTYLES = {QuoteStyle.PREFIX, QuoteStyle.HEADER};
|
||||
public static QuoteStyle[] QUOTESTYLES = { QuoteStyle.PREFIX, QuoteStyle.HEADER };
|
||||
|
||||
@Theory
|
||||
public void testBuildTextPlain(boolean includeQuotedText,
|
||||
QuoteStyle quoteStyle,
|
||||
boolean isReplyAfterQuote,
|
||||
boolean isSignatureUse,
|
||||
boolean isSignatureBeforeQuotedText,
|
||||
boolean isDraft) {
|
||||
QuoteStyle quoteStyle,
|
||||
boolean isReplyAfterQuote,
|
||||
boolean isSignatureUse,
|
||||
boolean isSignatureBeforeQuotedText,
|
||||
boolean isDraft) {
|
||||
|
||||
String expectedText;
|
||||
int expectedMessageLength;
|
||||
@ -130,14 +130,14 @@ public class TextBodyBuilderTest {
|
||||
String signatureText = "signature";
|
||||
|
||||
TestingTextBodyBuilder textBodyBuilder = new TestingTextBodyBuilder(
|
||||
includeQuotedText,
|
||||
isDraft,
|
||||
quoteStyle,
|
||||
isReplyAfterQuote,
|
||||
isSignatureBeforeQuotedText,
|
||||
isSignatureUse,
|
||||
messageText,
|
||||
signatureText
|
||||
includeQuotedText,
|
||||
isDraft,
|
||||
quoteStyle,
|
||||
isReplyAfterQuote,
|
||||
isSignatureBeforeQuotedText,
|
||||
isSignatureUse,
|
||||
messageText,
|
||||
signatureText
|
||||
);
|
||||
textBodyBuilder.setQuotedText(quotedText);
|
||||
TextBody textBody = textBodyBuilder.buildTextPlain();
|
||||
@ -147,7 +147,7 @@ public class TextBodyBuilderTest {
|
||||
assertThat(textBody.getComposedMessageLength(), is(expectedMessageLength));
|
||||
assertThat(textBody.getComposedMessageOffset(), is(expectedMessagePosition));
|
||||
assertThat(textBody.getText().substring(expectedMessagePosition, expectedMessagePosition + expectedMessageLength),
|
||||
is("message content"));
|
||||
is("message content"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,26 +163,27 @@ public class TextBodyBuilderTest {
|
||||
*
|
||||
* @see InsertableHtmlContent#toDebugString()
|
||||
*/
|
||||
public String makeExpectedHtmlContent(String expectedText, String quotedContent, int footerInsertionPoint, boolean isBefore,
|
||||
String userContent, String compiledResult) {
|
||||
public String makeExpectedHtmlContent(String expectedText, String quotedContent,
|
||||
int footerInsertionPoint, boolean isBefore,
|
||||
String userContent, String compiledResult) {
|
||||
String expectedHtmlContent = "InsertableHtmlContent{"
|
||||
+ "headerInsertionPoint=0,"
|
||||
+ " footerInsertionPoint=" + footerInsertionPoint + ","
|
||||
+ " insertionLocation=" + (isBefore ? "BEFORE_QUOTE" : "AFTER_QUOTE") + ","
|
||||
+ " quotedContent=" + quotedContent + ","
|
||||
+ " userContent=" + userContent + ","
|
||||
+ " compiledResult=" + compiledResult
|
||||
+ "}";
|
||||
+ "headerInsertionPoint=0,"
|
||||
+ " footerInsertionPoint=" + footerInsertionPoint + ","
|
||||
+ " insertionLocation=" + (isBefore ? "BEFORE_QUOTE" : "AFTER_QUOTE") + ","
|
||||
+ " quotedContent=" + quotedContent + ","
|
||||
+ " userContent=" + userContent + ","
|
||||
+ " compiledResult=" + compiledResult
|
||||
+ "}";
|
||||
return expectedHtmlContent;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void testBuildTextHtml(boolean includeQuotedText,
|
||||
QuoteStyle quoteStyle,
|
||||
boolean isReplyAfterQuote,
|
||||
boolean isSignatureUse,
|
||||
boolean isSignatureBeforeQuotedText,
|
||||
boolean isDraft) {
|
||||
QuoteStyle quoteStyle,
|
||||
boolean isReplyAfterQuote,
|
||||
boolean isSignatureUse,
|
||||
boolean isSignatureBeforeQuotedText,
|
||||
boolean isDraft) {
|
||||
String expectedText;
|
||||
int expectedMessageLength;
|
||||
int expectedMessagePosition = 0;
|
||||
@ -203,7 +204,7 @@ public class TextBodyBuilderTest {
|
||||
// 3.signature
|
||||
if (quoteStyle == QuoteStyle.PREFIX && isReplyAfterQuote) {
|
||||
expectedText = expectedPrefix
|
||||
+ "<html>message content";
|
||||
+ "<html>message content";
|
||||
if (!isDraft && isSignatureUse) {
|
||||
expectedText += "\r\n" + "signature";
|
||||
}
|
||||
@ -213,17 +214,17 @@ public class TextBodyBuilderTest {
|
||||
|
||||
if (isDraft || includeQuotedText) {
|
||||
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent,
|
||||
0,
|
||||
false,
|
||||
expectedText,
|
||||
expectedText + quotedContent);
|
||||
0,
|
||||
false,
|
||||
expectedText,
|
||||
expectedText + quotedContent);
|
||||
expectedText += quotedContent;
|
||||
} else {
|
||||
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent,
|
||||
0,
|
||||
true,
|
||||
"",
|
||||
quotedContent);
|
||||
0,
|
||||
true,
|
||||
"",
|
||||
quotedContent);
|
||||
// expectedText += quotedContent;
|
||||
}
|
||||
}
|
||||
@ -232,7 +233,7 @@ public class TextBodyBuilderTest {
|
||||
// 3.quoted text
|
||||
else if (isSignatureBeforeQuotedText) {
|
||||
expectedText = expectedPrefix
|
||||
+ "<html>message content";
|
||||
+ "<html>message content";
|
||||
if (!isDraft && isSignatureUse) {
|
||||
expectedText += "\r\n" + "signature";
|
||||
}
|
||||
@ -244,17 +245,17 @@ public class TextBodyBuilderTest {
|
||||
|
||||
if (isDraft || includeQuotedText) {
|
||||
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent,
|
||||
0,
|
||||
true,
|
||||
expectedText,
|
||||
expectedText + quotedContent);
|
||||
0,
|
||||
true,
|
||||
expectedText,
|
||||
expectedText + quotedContent);
|
||||
expectedText += quotedContent;
|
||||
} else {
|
||||
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent,
|
||||
0,
|
||||
true,
|
||||
"",
|
||||
quotedContent);
|
||||
0,
|
||||
true,
|
||||
"",
|
||||
quotedContent);
|
||||
// expectedText += quotedContent;
|
||||
}
|
||||
}
|
||||
@ -265,7 +266,7 @@ public class TextBodyBuilderTest {
|
||||
String expectedSignature = "";
|
||||
|
||||
expectedText = expectedPrefix
|
||||
+ "<html>message content";
|
||||
+ "<html>message content";
|
||||
|
||||
if (!isDraft && isSignatureUse) {
|
||||
if (!includeQuotedText) {
|
||||
@ -282,17 +283,17 @@ public class TextBodyBuilderTest {
|
||||
|
||||
if (isDraft || includeQuotedText) {
|
||||
expectedHtmlContent = makeExpectedHtmlContent(expectedText, expectedSignature + quotedContent,
|
||||
expectedSignature.length(),
|
||||
true,
|
||||
expectedText,
|
||||
expectedText + expectedSignature + quotedContent);
|
||||
expectedSignature.length(),
|
||||
true,
|
||||
expectedText,
|
||||
expectedText + expectedSignature + quotedContent);
|
||||
expectedText += expectedSignature + quotedContent;
|
||||
} else {
|
||||
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent,
|
||||
0,
|
||||
true,
|
||||
"",
|
||||
quotedContent);
|
||||
0,
|
||||
true,
|
||||
"",
|
||||
quotedContent);
|
||||
// expectedText += quotedContent;
|
||||
}
|
||||
}
|
||||
@ -305,14 +306,14 @@ public class TextBodyBuilderTest {
|
||||
String signatureText = "signature";
|
||||
|
||||
TestingTextBodyBuilder textBodyBuilder = new TestingTextBodyBuilder(
|
||||
includeQuotedText,
|
||||
isDraft,
|
||||
quoteStyle,
|
||||
isReplyAfterQuote,
|
||||
isSignatureBeforeQuotedText,
|
||||
isSignatureUse,
|
||||
messageText,
|
||||
signatureText
|
||||
includeQuotedText,
|
||||
isDraft,
|
||||
quoteStyle,
|
||||
isReplyAfterQuote,
|
||||
isSignatureBeforeQuotedText,
|
||||
isSignatureUse,
|
||||
messageText,
|
||||
signatureText
|
||||
);
|
||||
textBodyBuilder.setQuotedTextHtml(insertableHtmlContent);
|
||||
TextBody textBody = textBodyBuilder.buildTextHtml();
|
||||
|
Loading…
Reference in New Issue
Block a user