AccountSetupOutgoing.java revision fd14496c494a0d38c35c3788c9cc55f1984592e4
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.provider.EmailContent.Account; 21 22import android.app.Activity; 23import android.app.FragmentTransaction; 24import android.content.Intent; 25import android.os.Bundle; 26 27/** 28 * Provides setup flow for SMTP (for IMAP/POP accounts). 29 * 30 * Uses AccountSetupOutgoingFragment for primary UI. Uses AccountCheckSettingsFragment to validate 31 * the settings as entered. If the account is OK, proceeds to AccountSetupOptions. 32 */ 33public class AccountSetupOutgoing extends Activity 34 implements AccountSetupOutgoingFragment.Callback { 35 36 private AccountSetupOutgoingFragment mFragment; 37 /* package */ boolean mNextButtonEnabled; 38 39 public static void actionOutgoingSettings(Activity fromActivity, int mode, Account acct) { 40 SetupData.init(mode, acct); 41 fromActivity.startActivity(new Intent(fromActivity, AccountSetupOutgoing.class)); 42 } 43 44 public static void actionEditOutgoingSettings(Activity fromActivity, int mode, Account acct) { 45 actionOutgoingSettings(fromActivity, mode, acct); 46 } 47 48 @Override 49 public void onCreate(Bundle savedInstanceState) { 50 super.onCreate(savedInstanceState); 51 setContentView(R.layout.account_setup_outgoing); 52 53 mFragment = (AccountSetupOutgoingFragment) 54 getFragmentManager().findFragmentById(R.id.setup_fragment); 55 56 // Configure fragment 57 mFragment.setCallback(this); 58 } 59 60 /** 61 * Implements AccountServerBaseFragment.Callback 62 * 63 * Launches the account checker. Positive results are reported to onCheckSettingsOk(). 64 */ 65 public void onProceedNext(int checkMode, AccountServerBaseFragment target) { 66 AccountCheckSettingsFragment checkerFragment = 67 AccountCheckSettingsFragment.newInstance(checkMode, target); 68 FragmentTransaction transaction = getFragmentManager().openTransaction(); 69 transaction.replace(R.id.setup_fragment, checkerFragment); 70 transaction.addToBackStack("back"); 71 transaction.commit(); 72 } 73 74 /** 75 * Implements AccountServerBaseFragment.Callback 76 */ 77 public void onEnableProceedButtons(boolean enable) { 78 boolean wasEnabled = mNextButtonEnabled; 79 mNextButtonEnabled = enable; 80 81 if (enable != wasEnabled) { 82 invalidateOptionsMenu(); 83 } 84 } 85 86 /** 87 * Implements AccountServerBaseFragment.Callback 88 * 89 * If the checked settings are OK, proceed to options screen 90 */ 91 public void onCheckSettingsOk(int setupMode) { 92 if (SetupData.getFlowMode() != SetupData.FLOW_MODE_EDIT) { 93 AccountSetupOptions.actionOptions(this); 94 } 95 finish(); 96 } 97} 98