am 75e508a7
: Merge "Cleanup account name, user name, and summary" into honeycomb
* commit '75e508a794a61a1f96ff30f8833f00c0e05bd379': Cleanup account name, user name, and summary
This commit is contained in:
commit
eb7913fa28
@ -515,6 +515,8 @@ save attachment.</string>
|
||||
<!-- On "Set up email" screen, label of text field -->
|
||||
<string name="account_setup_names_user_name_label">
|
||||
Your name (displayed on outgoing messages)</string>
|
||||
<!-- On "Set up email" screen, error pop-up when user_name field is empty [CHAR LIMIT=none] -->
|
||||
<string name="account_setup_names_user_name_empty_error">This field cannot be blank</string>
|
||||
|
||||
<!-- Activity Title for the account type selector (IMAP or POP3 or EAS) [CHAR LIMIT=45] -->
|
||||
<string name="account_setup_account_type_title">Account setup</string>
|
||||
|
@ -24,21 +24,24 @@
|
||||
android:order="1"
|
||||
android:title="@string/account_settings_description_label"
|
||||
android:summary=""
|
||||
android:dialogTitle="@string/account_settings_description_label" />
|
||||
android:dialogTitle="@string/account_settings_description_label"
|
||||
android:inputType="textCapWords" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="account_name"
|
||||
android:order="2"
|
||||
android:title="@string/account_settings_name_label"
|
||||
android:summary=""
|
||||
android:dialogTitle="@string/account_settings_name_label" />
|
||||
android:dialogTitle="@string/account_settings_name_label"
|
||||
android:inputType="textPersonName|textCapWords" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="account_signature"
|
||||
android:order="3"
|
||||
android:title="@string/account_settings_signature_label"
|
||||
android:summary=""
|
||||
android:dialogTitle="@string/account_settings_signature_label" />
|
||||
android:summary="@string/account_settings_signature_hint"
|
||||
android:dialogTitle="@string/account_settings_signature_label"
|
||||
android:inputType="textCapSentences" />
|
||||
|
||||
<ListPreference
|
||||
android:key="account_check_frequency"
|
||||
|
@ -49,6 +49,7 @@ import android.preference.PreferenceFragment;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.provider.Calendar;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
@ -363,7 +364,10 @@ public class AccountSettingsFragment extends PreferenceFragment {
|
||||
mAccountDescription.setOnPreferenceChangeListener(
|
||||
new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final String summary = newValue.toString();
|
||||
String summary = newValue.toString().trim();
|
||||
if (TextUtils.isEmpty(summary)) {
|
||||
summary = mAccount.mEmailAddress;
|
||||
}
|
||||
mAccountDescription.setSummary(summary);
|
||||
mAccountDescription.setText(summary);
|
||||
onPreferenceChanged();
|
||||
@ -377,22 +381,27 @@ public class AccountSettingsFragment extends PreferenceFragment {
|
||||
mAccountName.setText(mAccount.getSenderName());
|
||||
mAccountName.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final String summary = newValue.toString();
|
||||
mAccountName.setSummary(summary);
|
||||
mAccountName.setText(summary);
|
||||
onPreferenceChanged();
|
||||
final String summary = newValue.toString().trim();
|
||||
if (!TextUtils.isEmpty(summary)) {
|
||||
mAccountName.setSummary(summary);
|
||||
mAccountName.setText(summary);
|
||||
onPreferenceChanged();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mAccountSignature = (EditTextPreference) findPreference(PREFERENCE_SIGNATURE);
|
||||
mAccountSignature.setSummary(mAccount.getSignature());
|
||||
String signature = mAccount.getSignature();
|
||||
if (!TextUtils.isEmpty(signature)) {
|
||||
mAccountSignature.setSummary(mAccount.getSignature());
|
||||
}
|
||||
mAccountSignature.setText(mAccount.getSignature());
|
||||
mAccountSignature.setOnPreferenceChangeListener(
|
||||
new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String summary = newValue.toString();
|
||||
if (summary == null || summary.length() == 0) {
|
||||
String summary = newValue.toString().trim();
|
||||
if (TextUtils.isEmpty(summary)) {
|
||||
mAccountSignature.setSummary(R.string.account_settings_signature_hint);
|
||||
} else {
|
||||
mAccountSignature.setSummary(summary);
|
||||
@ -601,8 +610,10 @@ public class AccountSettingsFragment extends PreferenceFragment {
|
||||
newFlags |= mAccountBackgroundAttachments.isChecked() ?
|
||||
Account.FLAGS_BACKGROUND_ATTACHMENTS : 0;
|
||||
mAccount.setDefaultAccount(mAccountDefault.isChecked());
|
||||
mAccount.setDisplayName(mAccountDescription.getText());
|
||||
mAccount.setSenderName(mAccountName.getText());
|
||||
// If the display name has been cleared, we'll reset it to the default value (email addr)
|
||||
mAccount.setDisplayName(mAccountDescription.getText().trim());
|
||||
// The sender name must never be empty (this is enforced by the preference editor)
|
||||
mAccount.setSenderName(mAccountName.getText().trim());
|
||||
mAccount.setSignature(mAccountSignature.getText());
|
||||
newFlags |= mAccountNotify.isChecked() ? Account.FLAGS_NOTIFY_NEW_MAIL : 0;
|
||||
mAccount.setSyncInterval(Integer.parseInt(mCheckFrequency.getValue()));
|
||||
|
@ -31,6 +31,7 @@ import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.TextKeyListener;
|
||||
import android.text.method.TextKeyListener.Capitalize;
|
||||
@ -41,8 +42,6 @@ import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* Final screen of setup process. Collect account nickname and/or username.
|
||||
*
|
||||
* TODO: Better processing of account nickname including trimming and prevention of empty string.
|
||||
*/
|
||||
public class AccountSetupNames extends AccountSetupActivity implements OnClickListener {
|
||||
private static final int REQUEST_SECURITY = 0;
|
||||
@ -136,7 +135,15 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
|
||||
* Check input fields for legal values and enable/disable next button
|
||||
*/
|
||||
private void validateFields() {
|
||||
boolean newEnabled = mEasAccount || Utility.isTextViewNotEmpty(mName);
|
||||
boolean newEnabled = true;
|
||||
// Validation is based only on the "user name" field, not shown for EAS accounts
|
||||
if (!mEasAccount) {
|
||||
String userName = mName.getText().toString().trim();
|
||||
newEnabled = !TextUtils.isEmpty(userName);
|
||||
if (!newEnabled) {
|
||||
mName.setError(getString(R.string.account_setup_names_user_name_empty_error));
|
||||
}
|
||||
}
|
||||
mNextButton.setEnabled(newEnabled);
|
||||
}
|
||||
|
||||
@ -173,10 +180,11 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
|
||||
private void onNext() {
|
||||
// Update account object from UI
|
||||
Account account = SetupData.getAccount();
|
||||
if (Utility.isTextViewNotEmpty(mDescription)) {
|
||||
account.setDisplayName(mDescription.getText().toString());
|
||||
String description = mDescription.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(description)) {
|
||||
account.setDisplayName(description);
|
||||
}
|
||||
account.setSenderName(mName.getText().toString());
|
||||
account.setSenderName(mName.getText().toString().trim());
|
||||
|
||||
// Launch async task for final commit work
|
||||
new FinalSetupTask(account).execute();
|
||||
|
Loading…
Reference in New Issue
Block a user