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

AccountSetupOptions

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

Fields Summary
private static final String
EXTRA_ACCOUNT
private static final String
EXTRA_MAKE_DEFAULT
private android.widget.Spinner
mCheckFrequencyView
private android.widget.CheckBox
mDefaultView
private android.widget.CheckBox
mNotifyView
private com.android.email.Account
mAccount
Constructors Summary
Methods Summary
public static voidactionOptions(android.content.Context context, com.android.email.Account account, boolean makeDefault)


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

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

        super.onCreate(savedInstanceState);
        setContentView(R.layout.account_setup_options);

        mCheckFrequencyView = (Spinner)findViewById(R.id.account_check_frequency);
        mDefaultView = (CheckBox)findViewById(R.id.account_default);
        mNotifyView = (CheckBox)findViewById(R.id.account_notify);

        findViewById(R.id.next).setOnClickListener(this);

        // NOTE: If you change these values, confirm that the new intervals exist in arrays.xml
        // NOTE: It would be cleaner if the numeric values were obtained from  the
        //       account_settings_check_frequency_values, array, so the options could be controlled
        //       entirely via XML.
        SpinnerOption checkFrequencies[] = {
                new SpinnerOption(-1,
                        getString(R.string.account_setup_options_mail_check_frequency_never)),
                new SpinnerOption(5,
                        getString(R.string.account_setup_options_mail_check_frequency_5min)),
                new SpinnerOption(10,
                        getString(R.string.account_setup_options_mail_check_frequency_10min)),
                new SpinnerOption(15,
                        getString(R.string.account_setup_options_mail_check_frequency_15min)),
                new SpinnerOption(30,
                        getString(R.string.account_setup_options_mail_check_frequency_30min)),
                new SpinnerOption(60,
                        getString(R.string.account_setup_options_mail_check_frequency_1hour)),
        };

        ArrayAdapter<SpinnerOption> checkFrequenciesAdapter = new ArrayAdapter<SpinnerOption>(this,
                android.R.layout.simple_spinner_item, checkFrequencies);
        checkFrequenciesAdapter
                .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mCheckFrequencyView.setAdapter(checkFrequenciesAdapter);

        mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT);
        boolean makeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);

        if (mAccount.equals(Preferences.getPreferences(this).getDefaultAccount()) || makeDefault) {
            mDefaultView.setChecked(true);
        }
        mNotifyView.setChecked(mAccount.isNotifyNewMail());
        SpinnerOption.setSpinnerOptionValue(mCheckFrequencyView, mAccount
                .getAutomaticCheckIntervalMinutes());
    
private voidonDone()

        mAccount.setDescription(mAccount.getEmail());
        mAccount.setNotifyNewMail(mNotifyView.isChecked());
        mAccount.setAutomaticCheckIntervalMinutes((Integer)((SpinnerOption)mCheckFrequencyView
                .getSelectedItem()).value);
        mAccount.save(Preferences.getPreferences(this));
        if (mDefaultView.isChecked()) {
            Preferences.getPreferences(this).setDefaultAccount(mAccount);
        }
        Email.setServicesEnabled(this);
        AccountSetupNames.actionSetNames(this, mAccount);
        finish();