1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 12:05:06 -05:00

Added support for requesting read receipts

This commit is contained in:
Alessandro Russo 2011-08-27 20:42:27 -04:00 committed by Jesse Vincent
parent a779b1e27b
commit f5c679fb95
7 changed files with 68 additions and 0 deletions

View File

@ -36,6 +36,11 @@
android:title="@string/send_as"
android:icon="@drawable/ic_menu_identity"
/>
<item
android:id="@+id/read_receipt"
android:alphabeticShortcut="r"
android:title="@string/read_receipt"
/>
<item
android:id="@+id/add_attachment_image"
android:title="@string/add_attachment_action_image"

View File

@ -110,6 +110,9 @@
<string name="view_hide_details_action">Mostra/nascondi dettagli</string>
<string name="add_cc_bcc_action">Aggiungi Cc/Ccn</string>
<string name="edit_subject_action">Modifica oggetto</string>
<string name="read_receipt">Notifica di lettura</string>
<string name="read_receipt_enabled">Notifica di lettura attiva</string>
<string name="read_receipt_disabled">Notifica di lettura disattiva</string>
<string name="add_attachment_action">Aggiungi allegato</string>
<string name="add_attachment_action_image">Aggiungi allegato (Immagine)</string>
<string name="add_attachment_action_video">Aggiungi allegato (Video)</string>
@ -569,6 +572,9 @@ Benvenuto nella configurazione della posta di K-9. K-9 è un client di posta ope
<string name="account_settings_message_format_text">Plain Text (verranno rimosse immagini e formattazione)</string>
<string name="account_settings_message_format_html">HTML (immagini e formattazione verranno preservate)</string>
<string name="account_settings_message_read_receipt_label">Notifica di lettura</string>
<string name="account_settings_message_read_receipt_summary">Richiedi sempre la notifica di lettura</string>
<string name="account_settings_quote_style_label">Aspetto testo quotato nelle risposte</string>
<string name="account_settings_quote_style_prefix">Prefisso (come Gmail, Pine)</string>
<string name="account_settings_quote_style_header">Intestazione (come Outlook, Yahoo!, Hotmail)</string>

View File

@ -110,6 +110,9 @@
<string name="view_hide_details_action">View/hide details</string>
<string name="add_cc_bcc_action">Add Cc/Bcc</string>
<string name="edit_subject_action">Edit subject</string>
<string name="read_receipt">Read Receipt</string>
<string name="read_receipt_enabled">Read receipt enabled</string>
<string name="read_receipt_disabled">Read receipt disabled</string>
<string name="add_attachment_action">Add attachment</string>
<string name="add_attachment_action_image">Add attachment (Image)</string>
<string name="add_attachment_action_video">Add attachment (Video)</string>
@ -572,6 +575,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="account_settings_message_format_text">Plain Text (images and formatting will be removed)</string>
<string name="account_settings_message_format_html">HTML (images and formatting are preserved)</string>
<string name="account_settings_message_read_receipt_label">Read receipt</string>
<string name="account_settings_message_read_receipt_summary">Always request a read receipt</string>
<string name="account_settings_quote_style_label">Reply quoting style</string>
<string name="account_settings_quote_style_prefix">Prefix (like Gmail, Pine)</string>
<string name="account_settings_quote_style_header">Header (like Outlook, Yahoo!, Hotmail)</string>

View File

@ -232,6 +232,12 @@
android:entries="@array/account_settings_message_format_entries"
android:entryValues="@array/account_settings_message_format_values" />
<CheckBoxPreference
android:persistent="false"
android:key="message_read_receipt"
android:title="@string/account_settings_message_read_receipt_label"
android:summary="@string/account_settings_message_read_receipt_summary" />
<ListPreference
android:persistent="false"
android:key="quote_style"

View File

@ -58,6 +58,7 @@ public class Account implements BaseAccount {
private static final String[] networkTypes = { TYPE_WIFI, TYPE_MOBILE, TYPE_OTHER };
private static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML;
private static final boolean DEFAULT_MESSAGE_READ_RECEIPT = false;
private static final QuoteStyle DEFAULT_QUOTE_STYLE = QuoteStyle.PREFIX;
private static final String DEFAULT_QUOTE_PREFIX = ">";
private static final boolean DEFAULT_QUOTED_TEXT_SHOWN = true;
@ -125,6 +126,7 @@ public class Account implements BaseAccount {
// current set of fetched messages
private boolean mRingNotified;
private MessageFormat mMessageFormat;
private boolean mMessageReadReceipt;
private QuoteStyle mQuoteStyle;
private String mQuotePrefix;
private boolean mDefaultQuotedTextShown;
@ -203,6 +205,7 @@ public class Account implements BaseAccount {
maximumPolledMessageAge = -1;
maximumAutoDownloadMessageSize = 32768;
mMessageFormat = DEFAULT_MESSAGE_FORMAT;
mMessageReadReceipt = DEFAULT_MESSAGE_READ_RECEIPT;
mQuoteStyle = DEFAULT_QUOTE_STYLE;
mQuotePrefix = DEFAULT_QUOTE_PREFIX;
mDefaultQuotedTextShown = DEFAULT_QUOTED_TEXT_SHOWN;
@ -277,6 +280,7 @@ public class Account implements BaseAccount {
maximumPolledMessageAge = prefs.getInt(mUuid + ".maximumPolledMessageAge", -1);
maximumAutoDownloadMessageSize = prefs.getInt(mUuid + ".maximumAutoDownloadMessageSize", 32768);
mMessageFormat = MessageFormat.valueOf(prefs.getString(mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT.name()));
mMessageReadReceipt = prefs.getBoolean(mUuid + ".messageReadReceipt", DEFAULT_MESSAGE_READ_RECEIPT);
mQuoteStyle = QuoteStyle.valueOf(prefs.getString(mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE.name()));
mQuotePrefix = prefs.getString(mUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX);
mDefaultQuotedTextShown = prefs.getBoolean(mUuid + ".defaultQuotedTextShown", DEFAULT_QUOTED_TEXT_SHOWN);
@ -529,6 +533,7 @@ public class Account implements BaseAccount {
editor.putInt(mUuid + ".maximumPolledMessageAge", maximumPolledMessageAge);
editor.putInt(mUuid + ".maximumAutoDownloadMessageSize", maximumAutoDownloadMessageSize);
editor.putString(mUuid + ".messageFormat", mMessageFormat.name());
editor.putBoolean(mUuid + ".messageReadReceipt", mMessageReadReceipt);
editor.putString(mUuid + ".quoteStyle", mQuoteStyle.name());
editor.putString(mUuid + ".quotePrefix", mQuotePrefix);
editor.putBoolean(mUuid + ".defaultQuotedTextShown", mDefaultQuotedTextShown);
@ -1284,6 +1289,14 @@ public class Account implements BaseAccount {
this.mMessageFormat = messageFormat;
}
public synchronized boolean isMessageReadReceiptAlways() {
return mMessageReadReceipt;
}
public synchronized void setMessageReadReceipt(boolean messageReadReceipt) {
mMessageReadReceipt = messageReadReceipt;
}
public QuoteStyle getQuoteStyle() {
return mQuoteStyle;
}

View File

@ -105,6 +105,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private static final String STATE_IN_REPLY_TO = "com.fsck.k9.activity.MessageCompose.inReplyTo";
private static final String STATE_REFERENCES = "com.fsck.k9.activity.MessageCompose.references";
private static final String STATE_KEY_MESSAGE_FORMAT = "com.fsck.k9.activity.MessageCompose.messageFormat";
private static final String STATE_KEY_READ_RECEIPT = "com.fsck.k9.activity.MessageCompose.messageReadReceipt";
private static final int MSG_PROGRESS_ON = 1;
private static final int MSG_PROGRESS_OFF = 2;
@ -168,6 +169,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
HIDE
};
private boolean mReadReceipt = false;
private QuotedTextMode mQuotedTextMode = QuotedTextMode.NONE;
private TextView mFromView;
@ -530,6 +533,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
mMessageFormat = mAccount.getMessageFormat();
mReadReceipt = mAccount.isMessageReadReceiptAlways();
if (!mSourceMessageProcessed) {
updateFrom();
@ -820,6 +824,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
outState.putString(STATE_REFERENCES, mReferences);
outState.putSerializable(STATE_KEY_HTML_QUOTE, mQuotedHtmlContent);
outState.putSerializable(STATE_KEY_MESSAGE_FORMAT, mMessageFormat);
outState.putBoolean(STATE_KEY_READ_RECEIPT, mReadReceipt);
}
@Override
@ -834,6 +839,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mMessageFormat = (MessageFormat) savedInstanceState
.getSerializable(STATE_KEY_MESSAGE_FORMAT);
mReadReceipt = savedInstanceState
.getBoolean(STATE_KEY_READ_RECEIPT);
mCcWrapper.setVisibility(savedInstanceState.getBoolean(STATE_KEY_CC_SHOWN) ? View.VISIBLE
: View.GONE);
mBccWrapper.setVisibility(savedInstanceState
@ -1019,6 +1026,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
message.setRecipients(RecipientType.CC, getAddresses(mCcView));
message.setRecipients(RecipientType.BCC, getAddresses(mBccView));
message.setSubject(mSubjectView.getText().toString());
if (mReadReceipt == true) {
message.setHeader("Disposition-Notification-To", from.toEncodedString());
}
message.setHeader("User-Agent", getString(R.string.message_header_mua));
final String replyTo = mIdentity.getReplyTo();
@ -1143,6 +1153,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
LENGTH("l"),
OFFSET("o"),
MESSAGE_FORMAT("f"),
MESSAGE_READ_RECEIPT("r"),
SIGNATURE("s"),
NAME("n"),
EMAIL("e"),
@ -1423,6 +1434,19 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mBccWrapper.setVisibility(View.VISIBLE);
}
private void onReadReceipt() {
CharSequence txt;
if (mReadReceipt == false) {
txt=getString(R.string.read_receipt_enabled);
mReadReceipt = true;
} else {
txt=getString(R.string.read_receipt_disabled);
mReadReceipt = false;
}
Context context = getApplicationContext();
Toast toast = Toast.makeText(context, txt, Toast.LENGTH_SHORT);
toast.show();
}
/**
* Kick off a picker for whatever kind of MIME types we'll accept and let Android take over.
*/
@ -1753,6 +1777,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
case R.id.choose_identity:
onChooseIdentity();
break;
case R.id.read_receipt:
onReadReceipt();
default:
return super.onOptionsItemSelected(item);
}

View File

@ -88,6 +88,7 @@ public class AccountSettings extends K9PreferenceActivity {
private static final String PREFERENCE_MESSAGE_SIZE = "account_autodownload_size";
private static final String PREFERENCE_SAVE_ALL_HEADERS = "account_save_all_headers";
private static final String PREFERENCE_MESSAGE_FORMAT = "message_format";
private static final String PREFERENCE_MESSAGE_READ_RECEIPT = "message_read_receipt";
private static final String PREFERENCE_QUOTE_PREFIX = "account_quote_prefix";
private static final String PREFERENCE_QUOTE_STYLE = "quote_style";
private static final String PREFERENCE_DEFAULT_QUOTED_TEXT_SHOWN = "default_quoted_text_shown";
@ -146,6 +147,7 @@ public class AccountSettings extends K9PreferenceActivity {
private CheckBoxPreference mNotificationOpensUnread;
private CheckBoxPreference mNotificationUnreadCount;
private ListPreference mMessageFormat;
private CheckBoxPreference mMessageReadReceipt;
private ListPreference mQuoteStyle;
private EditTextPreference mAccountQuotePrefix;
private CheckBoxPreference mAccountDefaultQuotedTextShown;
@ -217,6 +219,9 @@ public class AccountSettings extends K9PreferenceActivity {
}
});
mMessageReadReceipt = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGE_READ_RECEIPT);
mMessageReadReceipt.setChecked(mAccount.isMessageReadReceiptAlways());
mAccountQuotePrefix = (EditTextPreference) findPreference(PREFERENCE_QUOTE_PREFIX);
mAccountQuotePrefix.setSummary(mAccount.getQuotePrefix());
mAccountQuotePrefix.setText(mAccount.getQuotePrefix());
@ -716,6 +721,7 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.setSaveAllHeaders(mSaveAllHeaders.isChecked());
mAccount.setSearchableFolders(Account.Searchable.valueOf(mSearchableFolders.getValue()));
mAccount.setMessageFormat(Account.MessageFormat.valueOf(mMessageFormat.getValue()));
mAccount.setMessageReadReceipt(mMessageReadReceipt.isChecked());
mAccount.setQuoteStyle(QuoteStyle.valueOf(mQuoteStyle.getValue()));
mAccount.setQuotePrefix(mAccountQuotePrefix.getText());
mAccount.setDefaultQuotedTextShown(mAccountDefaultQuotedTextShown.isChecked());