Merge "Provide four default "quick responses" for new accounts"

This commit is contained in:
Marc Blank 2011-10-27 10:41:01 -07:00 committed by Android (Google) Code Review
commit ffe86bb316
3 changed files with 41 additions and 0 deletions

View File

@ -185,6 +185,14 @@
<item>@string/mailbox_name_display_junk</item>
</string-array>
<!-- A small number of default quick responses -->
<string-array name="default_quick_responses">
<item>@string/quick_1</item>
<item>@string/quick_2</item>
<item>@string/quick_3</item>
<item>@string/quick_4</item>
</string-array>
<!-- Arrays "mailbox_display_names" and "mailbox_display_icons" MUST match the order
of the types of mailboxes defined in EmailContent -->
<array name="mailbox_display_icons" translatable="false">

View File

@ -1257,5 +1257,19 @@ as <xliff:g id="filename">%s</xliff:g>.</string>
<!-- A policy requiring a maximum amount of time the device can sit idle before the lock screen
is activated [CHAR LIMIT=40] -->
<string name="policy_screen_timeout">Require an idle device to lock its screen</string>
<!-- The four strings below represent "quick responses" which the user can insert into a
message being composed with just a couple of taps. These four responses MUST be defined,
but need not include a string (i.e. they are optional). Further, the responses can be
customized as necessary by the translator, in case one or more of these is inappropriate in
a particular locale or if there are better options available. -->
<!-- A "quick response", i.e. a quick reply to a received mail [CHAR LIMIT=NONE] -->
<string name="quick_1">Thanks!</string>
<!-- A "quick response", i.e. a quick reply to a received mail [CHAR LIMIT=NONE] -->
<string name="quick_2">Sounds good to me!</string>
<!-- A "quick response", i.e. a quick reply to a received mail [CHAR LIMIT=NONE] -->
<string name="quick_3">I\'ll read this later and get back to you.</string>
<!-- A "quick response", i.e. a quick reply to a received mail [CHAR LIMIT=NONE] -->
<string name="quick_4">Let\'s set up a meeting to discuss this.</string>
</resources>

View File

@ -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);
}