FileDocCategorySizeDatePackage
AccountSetupNames.javaAPI DocAndroid 1.5 API4236Wed May 06 22:42:46 BST 2009com.android.email.activity.setup

AccountSetupNames

public class AccountSetupNames extends android.app.Activity implements android.view.View.OnClickListener

Fields Summary
private static final String
EXTRA_ACCOUNT
private android.widget.EditText
mDescription
private android.widget.EditText
mName
private com.android.email.Account
mAccount
private android.widget.Button
mDoneButton
Constructors Summary
Methods Summary
public static voidactionSetNames(android.content.Context context, com.android.email.Account account)


           
        Intent i = new Intent(context, AccountSetupNames.class);
        i.putExtra(EXTRA_ACCOUNT, account);
        context.startActivity(i);
    
public voidonClick(android.view.View v)

        switch (v.getId()) {
            case R.id.done:
                onNext();
                break;
        }
    
public voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);
        setContentView(R.layout.account_setup_names);
        mDescription = (EditText)findViewById(R.id.account_description);
        mName = (EditText)findViewById(R.id.account_name);
        mDoneButton = (Button)findViewById(R.id.done);
        mDoneButton.setOnClickListener(this);

        TextWatcher validationTextWatcher = new TextWatcher() {
            public void afterTextChanged(Editable s) {
                validateFields();
            }

            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }
        };
        mName.addTextChangedListener(validationTextWatcher);
        
        mName.setKeyListener(TextKeyListener.getInstance(false, Capitalize.WORDS));

        mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT);

        /*
         * Since this field is considered optional, we don't set this here. If
         * the user fills in a value we'll reset the current value, otherwise we
         * just leave the saved value alone.
         */
        // mDescription.setText(mAccount.getDescription());
        if (mAccount.getName() != null) {
            mName.setText(mAccount.getName());
        }
        if (!Utility.requiredFieldValid(mName)) {
            mDoneButton.setEnabled(false);
        }
    
private voidonNext()
TODO: Validator should also trim the description string before checking it.

        if (Utility.requiredFieldValid(mDescription)) {
            mAccount.setDescription(mDescription.getText().toString());
        }
        mAccount.setName(mName.getText().toString());
        mAccount.save(Preferences.getPreferences(this));
        FolderMessageList.actionHandleAccount(this, mAccount, Email.INBOX);
        finish();
    
private voidvalidateFields()
TODO: Validator should also trim the name string before checking it.

        mDoneButton.setEnabled(Utility.requiredFieldValid(mName));
        Utility.setCompoundDrawablesAlpha(mDoneButton, mDoneButton.isEnabled() ? 255 : 128);