AccountSetupAccountType.java revision 8978aac1977408b05e386ae846c30920c7faa0a6
1 2package com.android.email.activity.setup; 3 4import java.net.URI; 5import java.net.URISyntaxException; 6 7import android.app.Activity; 8import android.content.Context; 9import android.content.Intent; 10import android.os.Bundle; 11import android.view.View; 12import android.view.View.OnClickListener; 13import android.widget.Button; 14 15import com.android.email.Account; 16import com.android.email.R; 17 18/** 19 * Prompts the user to select an account type. The account type, along with the 20 * passed in email address, password and makeDefault are then passed on to the 21 * AccountSetupIncoming activity. 22 */ 23public class AccountSetupAccountType extends Activity implements OnClickListener { 24 private static final String EXTRA_ACCOUNT = "account"; 25 26 private static final String EXTRA_MAKE_DEFAULT = "makeDefault"; 27 28 private Account mAccount; 29 30 private boolean mMakeDefault; 31 32 public static void actionSelectAccountType(Context context, Account account, boolean makeDefault) { 33 Intent i = new Intent(context, AccountSetupAccountType.class); 34 i.putExtra(EXTRA_ACCOUNT, account); 35 i.putExtra(EXTRA_MAKE_DEFAULT, makeDefault); 36 context.startActivity(i); 37 } 38 39 @Override 40 public void onCreate(Bundle savedInstanceState) { 41 super.onCreate(savedInstanceState); 42 setContentView(R.layout.account_setup_account_type); 43 ((Button)findViewById(R.id.pop)).setOnClickListener(this); 44 ((Button)findViewById(R.id.imap)).setOnClickListener(this); 45 46 mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT); 47 mMakeDefault = (boolean)getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false); 48 } 49 50 private void onPop() { 51 try { 52 URI uri = new URI(mAccount.getStoreUri()); 53 uri = new URI("pop3", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null); 54 mAccount.setStoreUri(uri.toString()); 55 } catch (URISyntaxException use) { 56 /* 57 * This should not happen. 58 */ 59 throw new Error(use); 60 } 61 AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); 62 finish(); 63 } 64 65 private void onImap() { 66 try { 67 URI uri = new URI(mAccount.getStoreUri()); 68 uri = new URI("imap", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null); 69 mAccount.setStoreUri(uri.toString()); 70 } catch (URISyntaxException use) { 71 /* 72 * This should not happen. 73 */ 74 throw new Error(use); 75 } 76 AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); 77 finish(); 78 } 79 80 public void onClick(View v) { 81 switch (v.getId()) { 82 case R.id.pop: 83 onPop(); 84 break; 85 case R.id.imap: 86 onImap(); 87 break; 88 } 89 } 90} 91