AccountSetupOutgoing.java revision cd09545b87979fa6b4337f17b5a001f0ef7b5269
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.email.activity.setup; 18 19import com.android.email.R; 20import com.android.email.activity.ActivityHelper; 21import com.android.email.provider.EmailContent.Account; 22 23import android.app.Activity; 24import android.app.FragmentTransaction; 25import android.content.Intent; 26import android.os.Bundle; 27 28/** 29 * Provides setup flow for SMTP (for IMAP/POP accounts). 30 * 31 * Uses AccountSetupOutgoingFragment for primary UI. Uses AccountCheckSettingsFragment to validate 32 * the settings as entered. If the account is OK, proceeds to AccountSetupOptions. 33 */ 34public class AccountSetupOutgoing extends Activity 35 implements AccountSetupOutgoingFragment.Callback { 36 37 /* package */ AccountSetupOutgoingFragment mFragment; 38 /* package */ boolean mNextButtonEnabled; 39 40 public static void actionOutgoingSettings(Activity fromActivity, int mode, Account account) { 41 SetupData.setFlowMode(mode); 42 SetupData.setAccount(account); 43 fromActivity.startActivity(new Intent(fromActivity, AccountSetupOutgoing.class)); 44 } 45 46 @Override 47 public void onCreate(Bundle savedInstanceState) { 48 super.onCreate(savedInstanceState); 49 ActivityHelper.debugSetWindowFlags(this); 50 setContentView(R.layout.account_setup_outgoing); 51 52 mFragment = (AccountSetupOutgoingFragment) 53 getFragmentManager().findFragmentById(R.id.setup_fragment); 54 55 // Configure fragment 56 mFragment.setCallback(this); 57 } 58 59 /** 60 * Implements AccountServerBaseFragment.Callback 61 * 62 * Launches the account checker. Positive results are reported to onCheckSettingsOk(). 63 */ 64 public void onProceedNext(int checkMode, AccountServerBaseFragment target) { 65 AccountCheckSettingsFragment checkerFragment = 66 AccountCheckSettingsFragment.newInstance(checkMode, target); 67 FragmentTransaction transaction = getFragmentManager().openTransaction(); 68 transaction.replace(R.id.setup_fragment, checkerFragment); 69 transaction.addToBackStack("back"); 70 transaction.commit(); 71 } 72 73 /** 74 * Implements AccountServerBaseFragment.Callback 75 */ 76 public void onEnableProceedButtons(boolean enable) { 77 boolean wasEnabled = mNextButtonEnabled; 78 mNextButtonEnabled = enable; 79 80 if (enable != wasEnabled) { 81 invalidateOptionsMenu(); 82 } 83 } 84 85 /** 86 * Implements AccountServerBaseFragment.Callback 87 * 88 * If the checked settings are OK, proceed to options screen 89 */ 90 public void onCheckSettingsComplete(int result, int setupMode) { 91 if (result == AccountCheckSettingsFragment.CHECK_SETTINGS_OK) { 92 AccountSetupOptions.actionOptions(this); 93 finish(); 94 } 95 } 96} 97