Permalink
Browse files

Added email signature to email account

  • Loading branch information...
jarrettv committed Apr 14, 2010
1 parent 939d28f commit 8ce3f85d847cb90afa1b2a5f9d859e25df9e1f22
View
@@ -517,6 +517,8 @@
<!-- On Settings screen, setting option name -->
<string name="account_settings_description_label">Account name</string>
<!-- On Settings screen, setting option name -->
<string name="account_settings_signature_label">Signature</string>
<!-- On Settings screen, setting option name -->
<string name="account_settings_name_label">Your name</string>
<!-- On Settings screen, section heading -->
<string name="account_settings_notifications">Notification settings</string>
@@ -49,6 +49,12 @@
android:title="@string/account_settings_default_label"
android:summary="@string/account_settings_default_summary" />
<EditTextPreference
android:order="1"

This comment has been minimized.

Show comment
Hide comment
@jarrettv

jarrettv Apr 14, 2010

Owner

order should be different otherwise it is at the top

@jarrettv

jarrettv Apr 14, 2010

Owner

order should be different otherwise it is at the top

android:key="account_signature"
android:title="@string/account_settings_signature_label"
android:summary=""
android:dialogTitle="@string/account_settings_signature_label" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_notifications">
@@ -61,6 +61,7 @@
String mDescription;
String mName;
String mEmail;
String mSignature;
int mAutomaticCheckIntervalMinutes;
long mLastAutomaticCheckTime;
boolean mNotifyNewMail;
@@ -131,6 +132,7 @@ public void refresh(Preferences preferences) {
mDescription = preferences.mSharedPreferences.getString(mUuid + ".description", null);
mName = preferences.mSharedPreferences.getString(mUuid + ".name", mName);
mEmail = preferences.mSharedPreferences.getString(mUuid + ".email", mEmail);
mSignature = preferences.mSharedPreferences.getString(mUuid + ".signature", mSignature);
mAutomaticCheckIntervalMinutes = preferences.mSharedPreferences.getInt(mUuid
+ ".automaticCheckIntervalMinutes", -1);
mLastAutomaticCheckTime = preferences.mSharedPreferences.getLong(mUuid
@@ -211,6 +213,14 @@ public void setEmail(String email) {
this.mEmail = email;
}
public String getSignature() {
return mSignature;
}
public void setSignature(String signature) {
this.mSignature = signature;
}
public boolean isVibrate() {
return mVibrate;
}
@@ -248,6 +258,7 @@ public void delete(Preferences preferences) {
editor.remove(mUuid + ".description");
editor.remove(mUuid + ".name");
editor.remove(mUuid + ".email");
editor.remove(mUuid + ".signature");
editor.remove(mUuid + ".automaticCheckIntervalMinutes");
editor.remove(mUuid + ".lastAutomaticCheckTime");
editor.remove(mUuid + ".notifyNewMail");
@@ -313,6 +324,7 @@ public void save(Preferences preferences) {
editor.putString(mUuid + ".description", mDescription);
editor.putString(mUuid + ".name", mName);
editor.putString(mUuid + ".email", mEmail);
editor.putString(mUuid + ".signature", mSignature);
editor.putInt(mUuid + ".automaticCheckIntervalMinutes", mAutomaticCheckIntervalMinutes);
editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime);
editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail);
@@ -321,6 +321,12 @@ public void onCreate(Bundle savedInstanceState) {
// But we DO need to set mMessageLoaded to indicate the message can be sent
mMessageLoaded = true;
mSourceMessageProcessed = true;
// Add the signature to the new message
final String sig = mAccount.getSignature();
if (sig != null && sig.length() > 0) {
mMessageContentView.setText("\n\n" + sig);
}
}
}
@@ -47,6 +47,7 @@
private static final String PREFERENCE_TOP_CATEGORY = "account_settings";
private static final String PREFERENCE_DESCRIPTION = "account_description";
private static final String PREFERENCE_NAME = "account_name";
private static final String PREFERENCE_SIGNATURE = "account_signature";
private static final String PREFERENCE_FREQUENCY = "account_check_frequency";
private static final String PREFERENCE_DEFAULT = "account_default";
private static final String PREFERENCE_NOTIFY = "account_notify";
@@ -74,6 +75,7 @@
private ListPreference mCheckFrequency;
private ListPreference mSyncWindow;
private CheckBoxPreference mAccountDefault;
private EditTextPreference mSignature;
private CheckBoxPreference mAccountNotify;
private CheckBoxPreference mAccountVibrate;
private RingtonePreference mAccountRingtone;
@@ -196,7 +198,19 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
mAccountDefault = (CheckBoxPreference) findPreference(PREFERENCE_DEFAULT);
mAccountDefault.setChecked(mAccount.mId == Account.getDefaultAccountId(this));
mSignature = (EditTextPreference) findPreference(PREFERENCE_SIGNATURE);
mSignature.setSummary(mAccount.getSignature());
mSignature.setText(mAccount.getSignature());
mSignature.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String summary = newValue.toString();
mSignature.setSummary(summary);
mSignature.setText(summary);
return false;
}
});
mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY);
mAccountNotify.setChecked(0 != (mAccount.getFlags() & Account.FLAGS_NOTIFY_NEW_MAIL));
@@ -307,6 +321,7 @@ private void saveSettings() {
mAccount.setDefaultAccount(mAccountDefault.isChecked());
mAccount.setDisplayName(mAccountDescription.getText());
mAccount.setSenderName(mAccountName.getText());
mAccount.setSignature(mSignature.getText());
newFlags |= mAccountNotify.isChecked() ? Account.FLAGS_NOTIFY_NEW_MAIL : 0;
mAccount.setSyncInterval(Integer.parseInt(mCheckFrequency.getValue()));
if (mSyncWindow != null) {
@@ -44,6 +44,7 @@ public static void commitSettings(Context context, EmailContent.Account account)
cv.put(AccountColumns.RINGTONE_URI, account.mRingtoneUri);
cv.put(AccountColumns.FLAGS, account.mFlags);
cv.put(AccountColumns.SYNC_LOOKBACK, account.mSyncLookback);
cv.put(AccountColumns.SIGNATURE, account.mSignature);
account.update(context, cv);
}
// Update the backup (side copy) of the accounts
@@ -766,6 +766,8 @@ public void addSaveOps(ArrayList<ContentProviderOperation> ops) {
public static final String PROTOCOL_VERSION = "protocolVersion";
// The number of new messages (reported by the sync/download engines
public static final String NEW_MESSAGE_COUNT = "newMessageCount";
// The signature to append to each email
public static final String SIGNATURE = "signature";
}
public static final class Account extends EmailContent implements AccountColumns, Parcelable {
@@ -803,6 +805,7 @@ public void addSaveOps(ArrayList<ContentProviderOperation> ops) {
public String mRingtoneUri;
public String mProtocolVersion;
public int mNewMessageCount;
public String mSignature;
// Convenience for creating an account
public transient HostAuth mHostAuthRecv;
@@ -823,6 +826,7 @@ public void addSaveOps(ArrayList<ContentProviderOperation> ops) {
public static final int CONTENT_RINGTONE_URI_COLUMN = 12;
public static final int CONTENT_PROTOCOL_VERSION_COLUMN = 13;
public static final int CONTENT_NEW_MESSAGE_COUNT_COLUMN = 14;
public static final int CONTENT_SIGNATURE_COLUMN = 15;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, AccountColumns.DISPLAY_NAME,
@@ -831,7 +835,7 @@ public void addSaveOps(ArrayList<ContentProviderOperation> ops) {
AccountColumns.HOST_AUTH_KEY_SEND, AccountColumns.FLAGS, AccountColumns.IS_DEFAULT,
AccountColumns.COMPATIBILITY_UUID, AccountColumns.SENDER_NAME,
AccountColumns.RINGTONE_URI, AccountColumns.PROTOCOL_VERSION,
AccountColumns.NEW_MESSAGE_COUNT
AccountColumns.NEW_MESSAGE_COUNT, AccountColumns.SIGNATURE
};
public static final int CONTENT_MAILBOX_TYPE_COLUMN = 1;
@@ -922,6 +926,8 @@ public void refresh(Context context) {
mRingtoneUri = cursor.getString(CONTENT_RINGTONE_URI_COLUMN);
mProtocolVersion = cursor.getString(CONTENT_PROTOCOL_VERSION_COLUMN);
mNewMessageCount = cursor.getInt(CONTENT_NEW_MESSAGE_COUNT_COLUMN);
if (cursor.getColumnCount() > CONTENT_SIGNATURE_COLUMN)
mSignature = cursor.getString(CONTENT_SIGNATURE_COLUMN);
return this;
}
@@ -959,6 +965,20 @@ public void setEmailAddress(String emailAddress) {
mEmailAddress = emailAddress;
}
/**
* @return the signature for this account
*/
public String getSignature() {
return mSignature;
}
/**
* Set the signature for this account. Be sure to call save() to commit to database.
* @param signature the signature for this account
*/
public void setSignature(String signature) {
mSignature = signature;
}
/**
* @return the sender's name for this account
*/
@@ -1341,6 +1361,7 @@ public ContentValues toContentValues() {
values.put(AccountColumns.RINGTONE_URI, mRingtoneUri);
values.put(AccountColumns.PROTOCOL_VERSION, mProtocolVersion);
values.put(AccountColumns.NEW_MESSAGE_COUNT, mNewMessageCount);
values.put(AccountColumns.SIGNATURE, mSignature);
return values;
}
@@ -1399,6 +1420,8 @@ public void writeToParcel(Parcel dest, int flags) {
} else {
dest.writeByte((byte)0);
}
dest.writeString(mSignature);
}
/**
@@ -1431,6 +1454,8 @@ public Account(Parcel in) {
if (in.readByte() == 1) {
mHostAuthSend = new EmailContent.HostAuth(in);
}
mSignature = in.readString();
}
/**
@@ -62,7 +62,8 @@
// Version 4: Database wipe required; changing AccountManager interface w/Exchange
// Version 5: Database wipe required; changing AccountManager interface w/Exchange
// Version 6: Adding Message.mServerTimeStamp column
public static final int DATABASE_VERSION = 6;
// Version 7: Adding Account.mSignature column
public static final int DATABASE_VERSION = 7;
// Any changes to the database format *must* include update-in-place code.
// Original version: 2
@@ -384,6 +385,7 @@ static void createAccountTable(SQLiteDatabase db) {
+ AccountColumns.RINGTONE_URI + " text, "
+ AccountColumns.PROTOCOL_VERSION + " text, "
+ AccountColumns.NEW_MESSAGE_COUNT + " integer"
+ AccountColumns.SIGNATURE + " text, "
+ ");";
db.execSQL("create table " + Account.TABLE_NAME + s);
// Deleting an account deletes associated Mailboxes and HostAuth's
@@ -614,6 +616,16 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
oldVersion = 6;
}
if (oldVersion == 6) {
try {
db.execSQL("alter table " + Account.TABLE_NAME
+ " add column " + AccountColumns.SIGNATURE + " text" + ";");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
Log.w(TAG, "Exception upgrading EmailProvider.db from v6 to v7", e);
}
oldVersion = 7;
}
}
@Override

0 comments on commit 8ce3f85

Please sign in to comment.