1 package com.android.email.activity.setup; 2 3 import android.app.Activity; 4 import android.content.Context; 5 import android.content.Intent; 6 import android.os.Bundle; 7 import android.view.View; 8 9 import com.android.email.R; 10 import com.android.email.activity.UiUtilities; 11 12 public class AccountCredentials extends Activity 13 implements AccountSetupCredentialsFragment.Callback { 14 15 private static final String EXTRA_EMAIL = "email"; 16 private static final String EXTRA_PROTOCOL = "protocol"; 17 18 private static final String CREDENTIALS_FRAGMENT_TAG = "credentials"; 19 20 public static Intent getAccountCredentialsIntent(final Context context, final String email, 21 final String protocol) { 22 final Intent i = new Intent(context, AccountCredentials.class); 23 i.putExtra(EXTRA_EMAIL, email); 24 i.putExtra(EXTRA_PROTOCOL, protocol); 25 return i; 26 } 27 28 @Override 29 public void onCreate(final Bundle savedInstanceState) { 30 super.onCreate(savedInstanceState); 31 setContentView(R.layout.account_credentials); 32 final String emailAddress = getIntent().getStringExtra(EXTRA_EMAIL); 33 final String protocol = getIntent().getStringExtra(EXTRA_PROTOCOL); 34 35 setFinishOnTouchOutside(false); 36 37 if (savedInstanceState == null) { 38 final AccountSetupCredentialsFragment f = 39 AccountSetupCredentialsFragment.newInstance(emailAddress, protocol, 40 null /* clientCert */, false /* passwordFailed */, 41 true /* standalone */); 42 getFragmentManager().beginTransaction() 43 .add(R.id.account_credentials_fragment_container, f, CREDENTIALS_FRAGMENT_TAG) 44 .commit(); 45 } 46 // Assume canceled until we find out otherwise. 47 setResult(RESULT_CANCELED); 48 } 49 50 @Override 51 public void onCredentialsComplete(Bundle results) { 52 final Intent intent = new Intent(); 53 intent.putExtras(results); 54 setResult(RESULT_OK, intent); 55 finish(); 56 } 57 58 @Override 59 public void onNextButton() { 60 final AccountSetupCredentialsFragment fragment = (AccountSetupCredentialsFragment) 61 getFragmentManager().findFragmentByTag(CREDENTIALS_FRAGMENT_TAG); 62 final Bundle results = fragment.getCredentialResults(); 63 onCredentialsComplete(results); 64 } 65 } 66