From 7efde8632df2a41c5c88c6e7a863e8831cbaa0bc Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 25 Oct 2011 16:29:46 -0700 Subject: [PATCH] Provide four default "quick responses" for new accounts * These are added during account creation; existing accounts are not affected Bug: 5220629 Change-Id: I906e7b886ead9fdb269d9d44a245cc01c1cf260d --- res/values/arrays.xml | 8 ++++++++ res/values/strings.xml | 14 ++++++++++++++ .../activity/setup/AccountSettingsUtils.java | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/res/values/arrays.xml b/res/values/arrays.xml index c881e6eb9..6232e6527 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -185,6 +185,14 @@ @string/mailbox_name_display_junk + + + @string/quick_1 + @string/quick_2 + @string/quick_3 + @string/quick_4 + + diff --git a/res/values/strings.xml b/res/values/strings.xml index e54ea8686..c842c43b0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1257,5 +1257,19 @@ as %s. Require an idle device to lock its screen + + + + Thanks! + + Sounds good to me! + + I\'ll read this later and get back to you. + + Let\'s set up a meeting to discuss this. diff --git a/src/com/android/email/activity/setup/AccountSettingsUtils.java b/src/com/android/email/activity/setup/AccountSettingsUtils.java index 9ff519b6c..8265bf7b3 100644 --- a/src/com/android/email/activity/setup/AccountSettingsUtils.java +++ b/src/com/android/email/activity/setup/AccountSettingsUtils.java @@ -16,10 +16,12 @@ package com.android.email.activity.setup; +import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.res.XmlResourceParser; import android.text.Editable; +import android.text.TextUtils; import android.util.Log; import android.widget.EditText; @@ -29,6 +31,7 @@ import com.android.email.provider.AccountBackupRestore; import com.android.emailcommon.Logging; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.EmailContent.AccountColumns; +import com.android.emailcommon.provider.QuickResponse; import com.google.common.annotations.VisibleForTesting; import java.io.Serializable; @@ -51,10 +54,26 @@ public class AccountSettingsUtils { public static void commitSettings(Context context, Account account) { if (!account.isSaved()) { account.save(context); + + // Set up default quick responses here... + String[] defaultQuickResponses = + context.getResources().getStringArray(R.array.default_quick_responses); + ContentValues cv = new ContentValues(); + cv.put(QuickResponse.ACCOUNT_KEY, account.mId); + ContentResolver resolver = context.getContentResolver(); + for (String quickResponse: defaultQuickResponses) { + // Allow empty entries (some localizations may not want to have the maximum + // number) + if (!TextUtils.isEmpty(quickResponse)) { + cv.put(QuickResponse.TEXT, quickResponse); + resolver.insert(QuickResponse.CONTENT_URI, cv); + } + } } else { ContentValues cv = getAccountContentValues(account); account.update(context, cv); } + // Update the backup (side copy) of the accounts AccountBackupRestore.backup(context); }