Use real fragments for incoming/outgoing/exchange settings
* From account settings, switch to incoming/outgoing/eas fragments * Show "Next" button in actionbar (may be dup'd in single-pane view) * Common base class for in/out/eas fragments * Depends on PreferenceActivity.startPreferenceFragment(), new API * If the user clicks an account header while editing server settings, present a dialog before discarding the changes that haven't been checked yet. * Confirm working (if a bit ungainly in appearance) on phone screen Change-Id: I03591b9a8ffd11fe26fc6f58a5698740e61d0090
This commit is contained in:
parent
213c52dd64
commit
1a5e1e1593
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- A single "Next" button for the incoming, outgoing, and exchange fragments -->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/next"
|
||||
android:title="@string/next_action"
|
||||
android:showAsAction="always"
|
||||
/>
|
||||
</menu>
|
|
@ -587,6 +587,11 @@
|
|||
|
||||
<!-- "Setup could not finish" dialog action button -->
|
||||
<string name="account_setup_failed_dlg_edit_details_action">Edit details</string>
|
||||
|
||||
<!-- On AccountSettingsXL, dialog text if you try to exit in/out/eas fragment (server settings)
|
||||
without checking/saving [CHAR LIMIT=none]-->
|
||||
<string name="account_settings_exit_server_settings">Discard unsaved changes?</string>
|
||||
|
||||
<!-- On Settings screen, section heading -->
|
||||
<string name="account_settings_title_fmt">General settings</string>
|
||||
<!-- On Settings screen, setting option name -->
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.email.activity.setup;
|
||||
|
||||
import com.android.email.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
/**
|
||||
* Common base class for server settings fragments, so they can be more easily manipulated by
|
||||
* AccountSettingsXL. Provides the following common functionality:
|
||||
*
|
||||
* Activity-provided callbacks
|
||||
* Activity callback during onAttach
|
||||
* Present "Next" button and respond to its clicks
|
||||
*/
|
||||
public abstract class AccountServerBaseFragment extends Fragment {
|
||||
|
||||
protected Context mContext;
|
||||
protected Callback mCallback = EmptyCallback.INSTANCE;
|
||||
protected boolean mNextButtonEnabled;
|
||||
|
||||
/**
|
||||
* Callback interface that owning activities must provide
|
||||
*/
|
||||
public interface Callback {
|
||||
/**
|
||||
* Called each time the user-entered input transitions between valid and invalid
|
||||
* @param enable true to enable proceed/next button, false to disable
|
||||
*/
|
||||
public void onEnableProceedButtons(boolean enable);
|
||||
/**
|
||||
* Called when user clicks "next"
|
||||
* @param checkMode values from {@link SetupData}
|
||||
*/
|
||||
public void onProceedNext(int checkMode);
|
||||
}
|
||||
|
||||
private static class EmptyCallback implements Callback {
|
||||
public static final Callback INSTANCE = new EmptyCallback();
|
||||
@Override public void onEnableProceedButtons(boolean enable) { }
|
||||
@Override public void onProceedNext(int checkMode) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a fragment is first attached to its activity.
|
||||
* {@link #onCreate(Bundle)} will be called after this.
|
||||
*/
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
mContext = activity;
|
||||
|
||||
// Notify the activity that we're here.
|
||||
if (activity instanceof AccountSettingsXL) {
|
||||
((AccountSettingsXL)activity).onAttach(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to do initial creation of a fragment. This is called after
|
||||
* {@link #onAttach(Activity)} and before {@link #onActivityCreated(Bundle)}.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
mNextButtonEnabled = false;
|
||||
}
|
||||
|
||||
// Add a "Next" button when this fragment is displayed
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.account_settings_next_option, menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable "next" button
|
||||
*/
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
MenuItem item = menu.findItem(R.id.next);
|
||||
item.setEnabled(mNextButtonEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to clicks in the "Next" button
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.next:
|
||||
onNext();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activity provides callbacks here.
|
||||
*/
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback;
|
||||
mContext = getActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable the "next" button
|
||||
*/
|
||||
public void enableNextButton(boolean enable) {
|
||||
// We have to set mNextButtonEnabled first, because invalidateOptionsMenu calls
|
||||
// onPrepareOptionsMenu immediately
|
||||
boolean wasEnabled = mNextButtonEnabled;
|
||||
mNextButtonEnabled = enable;
|
||||
|
||||
if (enable != wasEnabled) {
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
// TODO: This supports the legacy activities and will be removed
|
||||
mCallback.onEnableProceedButtons(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings after "OK" result from checker. Concrete classes must implement.
|
||||
*/
|
||||
public abstract void saveSettingsAfterEdit();
|
||||
|
||||
/**
|
||||
* Respond to a click of the "Next" button. Concrete classes must implement.
|
||||
*/
|
||||
public abstract void onNext();
|
||||
}
|
|
@ -16,26 +16,20 @@
|
|||
|
||||
package com.android.email.activity.setup;
|
||||
|
||||
import com.android.email.Controller;
|
||||
import com.android.email.Email;
|
||||
import com.android.email.R;
|
||||
import com.android.email.Utility;
|
||||
import com.android.email.activity.AccountFolderList;
|
||||
import com.android.email.activity.setup.AccountSetupBasicsFragment.NoteDialogFragment;
|
||||
import com.android.email.mail.MessagingException;
|
||||
import com.android.email.mail.Sender;
|
||||
import com.android.email.mail.Store;
|
||||
import com.android.email.provider.EmailContent;
|
||||
import com.android.email.provider.EmailContent.Account;
|
||||
import com.android.email.provider.EmailContent.HostAuth;
|
||||
import com.android.email.service.MailService;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.Fragment;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -133,13 +127,6 @@ public class AccountSettingsFragment extends PreferenceFragment {
|
|||
@Override public void deleteAccount(Account account) { };
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback interface that owning activities must implement
|
||||
*/
|
||||
public interface OnAttachListener {
|
||||
public void onAttach(Fragment f);
|
||||
}
|
||||
|
||||
/**
|
||||
* If launching with an arguments bundle, use this method to build the arguments.
|
||||
* @param accountId The account being modified
|
||||
|
@ -159,9 +146,10 @@ public class AccountSettingsFragment extends PreferenceFragment {
|
|||
|
||||
mContext = activity;
|
||||
|
||||
// Notify the activity that we're here. Single-pane preference activities ignore this;
|
||||
// multi-pane settings uses this as a trigger to attach the account info
|
||||
((OnAttachListener)activity).onAttach(this);
|
||||
// Notify the activity that we're here.
|
||||
if (activity instanceof AccountSettingsXL) {
|
||||
((AccountSettingsXL)activity).onAttach(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,8 +28,12 @@ import com.android.email.provider.EmailContent.AccountColumns;
|
|||
import com.android.email.service.MailService;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -54,8 +58,7 @@ import java.util.List;
|
|||
* sense to use a loader for the accounts list, because it would provide better support for
|
||||
* dealing with accounts being added/deleted and triggering the header reload.
|
||||
*/
|
||||
public class AccountSettingsXL extends PreferenceActivity
|
||||
implements AccountSettingsFragment.OnAttachListener, OnClickListener {
|
||||
public class AccountSettingsXL extends PreferenceActivity implements OnClickListener {
|
||||
|
||||
// Intent extras for our internal activity launch
|
||||
/* package */ static final String EXTRA_ACCOUNT_ID = "AccountSettingsXL.account_id";
|
||||
|
@ -91,14 +94,17 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
private long mDeletingAccountId = -1;
|
||||
private boolean mShowDebugMenu;
|
||||
private Button mAddAccountButton;
|
||||
private List<Header> mGeneratedHeaders;
|
||||
|
||||
// Async Tasks
|
||||
private LoadAccountListTask mLoadAccountListTask;
|
||||
private GetAccountIdFromAccountTask mGetAccountIdFromAccountTask;
|
||||
|
||||
// Specific callbacks used by settings fragments
|
||||
private AccountSettingsFragmentCallback mAccountSettingsFragmentCallback
|
||||
private final AccountSettingsFragmentCallback mAccountSettingsFragmentCallback
|
||||
= new AccountSettingsFragmentCallback();
|
||||
private final AccountServerSettingsFragmentCallback mAccountServerSettingsFragmentCallback
|
||||
= new AccountServerSettingsFragmentCallback();
|
||||
|
||||
/**
|
||||
* Display (and edit) settings for a specific account, or -1 for any/all accounts
|
||||
|
@ -150,6 +156,11 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
updateAccounts();
|
||||
|
||||
// When we're resuming, enable/disable the add account button
|
||||
if (mAddAccountButton != null && hasHeaders()) {
|
||||
mAddAccountButton.setEnabled(shouldShowNewAccount());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,6 +207,23 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* After verifying a new server configuration, we return here and continue. If editing
|
||||
* succeeded, we do "back" to exit the settings screen.
|
||||
*
|
||||
* TODO: This goes away when we move checksettings into a fragment as well
|
||||
*/
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (mCurrentFragment instanceof AccountServerBaseFragment) {
|
||||
AccountServerBaseFragment f = (AccountServerBaseFragment) mCurrentFragment;
|
||||
f.saveSettingsAfterEdit();
|
||||
}
|
||||
onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
private void enableDebugMenu() {
|
||||
mShowDebugMenu = true;
|
||||
invalidateHeaders();
|
||||
|
@ -258,6 +286,7 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
target.add(header);
|
||||
if (header.accountId == mRequestedAccountId) {
|
||||
mRequestedAccountHeader = header;
|
||||
mRequestedAccountId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,6 +304,9 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
debugHeader.fragmentArguments = null;
|
||||
target.add(debugHeader);
|
||||
}
|
||||
|
||||
// Save for later use (see forceSwitch)
|
||||
mGeneratedHeaders = target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -377,6 +409,17 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
*/
|
||||
@Override
|
||||
public void onHeaderClick(Header header, int position) {
|
||||
// special case when exiting the server settings fragments
|
||||
if (mCurrentFragment instanceof AccountServerBaseFragment) {
|
||||
if (position != mCurrentHeaderPosition) {
|
||||
UnsavedChangesDialogFragment dialogFragment =
|
||||
UnsavedChangesDialogFragment.newInstance(position);
|
||||
dialogFragment.show(getFragmentManager(), UnsavedChangesDialogFragment.TAG);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Secret keys: Click 10x to enable debug settings
|
||||
if (position == 0) {
|
||||
mNumGeneralHeaderClicked++;
|
||||
if (mNumGeneralHeaderClicked == 10) {
|
||||
|
@ -385,31 +428,41 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
} else {
|
||||
mNumGeneralHeaderClicked = 0;
|
||||
}
|
||||
if (position != mCurrentHeaderPosition) {
|
||||
// if showing a sub-panel (e.g. server settings) we need to trap & post a dialog
|
||||
}
|
||||
|
||||
// Process header click normally
|
||||
mCurrentHeaderPosition = position;
|
||||
super.onHeaderClick(header, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements AccountSettingsFragment.OnAttachListener
|
||||
* Switch to a specific header without checking for server settings fragments as done
|
||||
* in {@link #onHeaderClick(Header, int)}. Called after we interrupted a header switch
|
||||
* with a dialog, and the user OK'd it.
|
||||
*/
|
||||
private void forceSwitchHeader(int newPosition) {
|
||||
mCurrentHeaderPosition = newPosition;
|
||||
Header header = mGeneratedHeaders.get(newPosition);
|
||||
switchToHeader(header.fragment, header.fragmentArguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by fragments at onAttach time
|
||||
*/
|
||||
@Override
|
||||
public void onAttach(Fragment f) {
|
||||
mCurrentFragment = f;
|
||||
// dispatch per-fragment setup
|
||||
if (f instanceof AccountSettingsFragment) {
|
||||
AccountSettingsFragment asf = (AccountSettingsFragment) f;
|
||||
asf.setCallback(mAccountSettingsFragmentCallback);
|
||||
} else if (f instanceof AccountSetupIncomingFragment) {
|
||||
// TODO
|
||||
} else if (f instanceof AccountSetupOutgoingFragment) {
|
||||
// TODO
|
||||
} else if (f instanceof AccountSetupExchangeFragment) {
|
||||
// TODO
|
||||
} else if (mCurrentFragment instanceof AccountServerBaseFragment) {
|
||||
AccountServerBaseFragment asbf = (AccountServerBaseFragment) mCurrentFragment;
|
||||
asbf.setCallback(mAccountServerSettingsFragmentCallback);
|
||||
}
|
||||
|
||||
// When we're changing fragments, enable/disable the add account button
|
||||
if (mAddAccountButton != null && hasHeaders()) {
|
||||
mAddAccountButton.setEnabled(shouldShowNewAccount());
|
||||
}
|
||||
// Since we're changing fragments, enable/disable the add account button
|
||||
mAddAccountButton.setEnabled(shouldShowNewAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -431,7 +484,26 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
}
|
||||
|
||||
/**
|
||||
* STOPSHIP: non-fragmented dispatch to edit incoming settings. Replace with fragment flip.
|
||||
* Callbacks for AccountServerSettingsFragmentCallback
|
||||
*/
|
||||
private class AccountServerSettingsFragmentCallback
|
||||
implements AccountServerBaseFragment.Callback {
|
||||
@Override
|
||||
public void onEnableProceedButtons(boolean enable) {
|
||||
// This is not used - it's a callback for the legacy activities
|
||||
}
|
||||
@Override
|
||||
public void onProceedNext(int setupMode) {
|
||||
// TODO - this will be a fragment launch, with a fragment target result
|
||||
AccountSetupCheckSettings.actionCheckSettings(AccountSettingsXL.this, setupMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch to edit incoming settings.
|
||||
*
|
||||
* TODO: Cache the store lookup earlier, in an AsyncTask, to avoid this DB access
|
||||
* TODO: Make things less hardwired
|
||||
*/
|
||||
public void onIncomingSettings(Account account) {
|
||||
try {
|
||||
|
@ -439,9 +511,17 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
if (store != null) {
|
||||
Class<? extends android.app.Activity> setting = store.getSettingActivityClass();
|
||||
if (setting != null) {
|
||||
java.lang.reflect.Method m = setting.getMethod("actionEditIncomingSettings",
|
||||
Activity.class, int.class, Account.class);
|
||||
m.invoke(null, this, SetupData.FLOW_MODE_EDIT, account);
|
||||
// java.lang.reflect.Method m = setting.getMethod("actionEditIncomingSettings",
|
||||
// Activity.class, int.class, Account.class);
|
||||
// m.invoke(null, this, SetupData.FLOW_MODE_EDIT, account);
|
||||
SetupData.init(SetupData.FLOW_MODE_EDIT, account);
|
||||
Fragment f = null;
|
||||
if (setting.equals(AccountSetupIncoming.class)) {
|
||||
f = new AccountSetupIncomingFragment();
|
||||
} else if (setting.equals(AccountSetupExchange.class)) {
|
||||
f = new AccountSetupExchangeFragment();
|
||||
}
|
||||
startPreferenceFragment(f, true);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -450,7 +530,10 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
}
|
||||
|
||||
/**
|
||||
* STOPSHIP: non-fragmented dispatch to edit outgoing settings. Replace with fragment flip.
|
||||
* Dispatch to edit outgoing settings.
|
||||
*
|
||||
* TODO: Cache the store lookup earlier, in an AsyncTask, to avoid this DB access
|
||||
* TODO: Make things less hardwired
|
||||
*/
|
||||
public void onOutgoingSettings(Account account) {
|
||||
try {
|
||||
|
@ -458,9 +541,15 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
if (sender != null) {
|
||||
Class<? extends android.app.Activity> setting = sender.getSettingActivityClass();
|
||||
if (setting != null) {
|
||||
java.lang.reflect.Method m = setting.getMethod("actionEditOutgoingSettings",
|
||||
Activity.class, int.class, Account.class);
|
||||
m.invoke(null, this, SetupData.FLOW_MODE_EDIT, account);
|
||||
// java.lang.reflect.Method m = setting.getMethod("actionEditOutgoingSettings",
|
||||
// Activity.class, int.class, Account.class);
|
||||
// m.invoke(null, this, SetupData.FLOW_MODE_EDIT, account);
|
||||
SetupData.init(SetupData.FLOW_MODE_EDIT, account);
|
||||
Fragment f = null;
|
||||
if (setting.equals(AccountSetupOutgoing.class)) {
|
||||
f = new AccountSetupOutgoingFragment();
|
||||
}
|
||||
startPreferenceFragment(f, true);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -539,4 +628,49 @@ public class AccountSettingsXL extends PreferenceActivity
|
|||
addPreferencesFromResource(R.xml.general_preferences);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog fragment to show "exit with unsaved changes?" dialog
|
||||
*/
|
||||
public static class UnsavedChangesDialogFragment extends DialogFragment {
|
||||
private final static String TAG = "UnsavedChangesDialogFragment";
|
||||
|
||||
// Argument bundle keys
|
||||
private final static String BUNDLE_KEY_NEW_HEADER = "UnsavedChangesDialogFragment.Header";
|
||||
|
||||
/**
|
||||
* Create the dialog with parameters
|
||||
*/
|
||||
public static UnsavedChangesDialogFragment newInstance(int newPosition) {
|
||||
UnsavedChangesDialogFragment f = new UnsavedChangesDialogFragment();
|
||||
Bundle b = new Bundle();
|
||||
b.putInt(BUNDLE_KEY_NEW_HEADER, newPosition);
|
||||
f.setArguments(b);
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final AccountSettingsXL activity = (AccountSettingsXL) getActivity();
|
||||
final int newPosition = getArguments().getInt(BUNDLE_KEY_NEW_HEADER);
|
||||
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setTitle(android.R.string.dialog_alert_title)
|
||||
.setMessage(R.string.account_settings_exit_server_settings)
|
||||
.setPositiveButton(
|
||||
R.string.okay_action,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
activity.forceSwitchHeader(newPosition);
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(
|
||||
activity.getString(R.string.cancel_action),
|
||||
null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -217,14 +217,14 @@ public class AccountSetupExchange extends AccountSetupActivity
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements AccountSetupIncomingFragment.Listener
|
||||
* Implements AccountServerBaseFragment.Callback
|
||||
*/
|
||||
public void onProceedNext() {
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, SetupData.CHECK_INCOMING);
|
||||
public void onProceedNext(int checkMode) {
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, checkMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements AccountSetupIncomingFragment.Listener
|
||||
* Implements AccountServerBaseFragment.Callback
|
||||
*/
|
||||
public void onEnableProceedButtons(boolean enabled) {
|
||||
mNextButton.setEnabled(enabled);
|
||||
|
|
|
@ -26,7 +26,6 @@ import com.android.email.provider.EmailContent.HostAuth;
|
|||
import com.android.exchange.ExchangeService;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
|
@ -38,9 +37,9 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -54,7 +53,8 @@ import java.net.URISyntaxException;
|
|||
* Do not attempt to define orientation-specific resources, they won't be loaded.
|
||||
* What we really need here is a more "sticky" way to prevent that problem.
|
||||
*/
|
||||
public class AccountSetupExchangeFragment extends Fragment implements OnCheckedChangeListener {
|
||||
public class AccountSetupExchangeFragment extends AccountServerBaseFragment
|
||||
implements OnCheckedChangeListener {
|
||||
|
||||
private final static String STATE_KEY_CREDENTIAL =
|
||||
"AccountSetupExchangeFragment.loginCredential";
|
||||
|
@ -66,26 +66,10 @@ public class AccountSetupExchangeFragment extends Fragment implements OnCheckedC
|
|||
private CheckBox mTrustCertificatesView;
|
||||
|
||||
// Support for lifecycle
|
||||
private Context mContext;
|
||||
private Callback mCallback = EmptyCallback.INSTANCE;
|
||||
private boolean mStarted;
|
||||
private boolean mLoaded;
|
||||
private String mCacheLoginCredential;
|
||||
|
||||
/**
|
||||
* Callback interface that owning activities must implement
|
||||
*/
|
||||
public interface Callback {
|
||||
public void onEnableProceedButtons(boolean enable);
|
||||
public void onProceedNext();
|
||||
}
|
||||
|
||||
private static class EmptyCallback implements Callback {
|
||||
public static final Callback INSTANCE = new EmptyCallback();
|
||||
@Override public void onProceedNext() { }
|
||||
@Override public void onEnableProceedButtons(boolean enable) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to do initial creation of a fragment. This is called after
|
||||
* {@link #onAttach(Activity)} and before {@link #onActivityCreated(Bundle)}.
|
||||
|
@ -224,9 +208,9 @@ public class AccountSetupExchangeFragment extends Fragment implements OnCheckedC
|
|||
/**
|
||||
* Activity provides callbacks here. This also triggers loading and setting up the UX
|
||||
*/
|
||||
@Override
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback;
|
||||
mContext = getActivity();
|
||||
super.setCallback(callback);
|
||||
if (mStarted && !mLoaded) {
|
||||
loadSettings(SetupData.getAccount());
|
||||
}
|
||||
|
@ -292,7 +276,7 @@ public class AccountSetupExchangeFragment extends Fragment implements OnCheckedC
|
|||
enabled = false;
|
||||
}
|
||||
}
|
||||
mCallback.onEnableProceedButtons(enabled);
|
||||
enableNextButton(enabled);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
@ -306,6 +290,7 @@ public class AccountSetupExchangeFragment extends Fragment implements OnCheckedC
|
|||
*
|
||||
* TODO: Was the !isSaved() logic ever actually used?
|
||||
*/
|
||||
@Override
|
||||
public void saveSettingsAfterEdit() {
|
||||
Account account = SetupData.getAccount();
|
||||
if (account.isSaved()) {
|
||||
|
@ -376,6 +361,7 @@ public class AccountSetupExchangeFragment extends Fragment implements OnCheckedC
|
|||
/**
|
||||
* Entry point from Activity, when "next" button is clicked
|
||||
*/
|
||||
@Override
|
||||
public void onNext() {
|
||||
try {
|
||||
URI uri = getUri();
|
||||
|
@ -401,6 +387,6 @@ public class AccountSetupExchangeFragment extends Fragment implements OnCheckedC
|
|||
throw new Error(use);
|
||||
}
|
||||
|
||||
mCallback.onProceedNext();
|
||||
mCallback.onProceedNext(SetupData.CHECK_INCOMING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,14 +88,14 @@ public class AccountSetupIncoming extends AccountSetupActivity
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements AccountSetupIncomingFragment.Listener
|
||||
* Implements AccountServerBaseFragment.Callback
|
||||
*/
|
||||
public void onProceedNext() {
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, SetupData.CHECK_INCOMING);
|
||||
public void onProceedNext(int checkMode) {
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, checkMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements AccountSetupIncomingFragment.Listener
|
||||
* Implements AccountServerBaseFragment.Callback
|
||||
*/
|
||||
public void onEnableProceedButtons(boolean enabled) {
|
||||
mNextButton.setEnabled(enabled);
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.android.email.provider.EmailContent;
|
|||
import com.android.email.provider.EmailContent.Account;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
|
@ -43,7 +42,7 @@ import android.widget.TextView;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class AccountSetupIncomingFragment extends Fragment {
|
||||
public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
|
||||
|
||||
private final static String STATE_KEY_CREDENTIAL =
|
||||
"AccountSetupIncomingFragment.loginCredential";
|
||||
|
@ -75,26 +74,10 @@ public class AccountSetupIncomingFragment extends Fragment {
|
|||
private EditText mImapPathPrefixView;
|
||||
|
||||
// Support for lifecycle
|
||||
private Context mContext;
|
||||
private Callback mCallback = EmptyCallback.INSTANCE;
|
||||
private boolean mStarted;
|
||||
private boolean mLoaded;
|
||||
private String mCacheLoginCredential;
|
||||
|
||||
/**
|
||||
* Callback interface that owning activities must implement
|
||||
*/
|
||||
public interface Callback {
|
||||
public void onEnableProceedButtons(boolean enable);
|
||||
public void onProceedNext();
|
||||
}
|
||||
|
||||
private static class EmptyCallback implements Callback {
|
||||
public static final Callback INSTANCE = new EmptyCallback();
|
||||
@Override public void onProceedNext() { }
|
||||
@Override public void onEnableProceedButtons(boolean enable) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to do initial creation of a fragment. This is called after
|
||||
* {@link #onAttach(Activity)} and before {@link #onActivityCreated(Bundle)}.
|
||||
|
@ -274,9 +257,9 @@ public class AccountSetupIncomingFragment extends Fragment {
|
|||
/**
|
||||
* Activity provides callbacks here. This also triggers loading and setting up the UX
|
||||
*/
|
||||
@Override
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback;
|
||||
mContext = getActivity();
|
||||
super.setCallback(callback);
|
||||
if (mStarted && !mLoaded) {
|
||||
loadSettings();
|
||||
}
|
||||
|
@ -370,7 +353,7 @@ public class AccountSetupIncomingFragment extends Fragment {
|
|||
enabled = false;
|
||||
}
|
||||
}
|
||||
mCallback.onEnableProceedButtons(enabled);
|
||||
enableNextButton(enabled);
|
||||
}
|
||||
|
||||
private void updatePortFromSecurityType() {
|
||||
|
@ -381,6 +364,7 @@ public class AccountSetupIncomingFragment extends Fragment {
|
|||
/**
|
||||
* Entry point from Activity after editing settings and verifying them. Must be FLOW_MODE_EDIT.
|
||||
*/
|
||||
@Override
|
||||
public void saveSettingsAfterEdit() {
|
||||
EmailContent.Account account = SetupData.getAccount();
|
||||
if (account.isSaved()) {
|
||||
|
@ -446,6 +430,7 @@ public class AccountSetupIncomingFragment extends Fragment {
|
|||
/**
|
||||
* Entry point from Activity, when "next" button is clicked
|
||||
*/
|
||||
@Override
|
||||
public void onNext() {
|
||||
EmailContent.Account setupAccount = SetupData.getAccount();
|
||||
try {
|
||||
|
@ -473,6 +458,6 @@ public class AccountSetupIncomingFragment extends Fragment {
|
|||
setupAccount.setDeletePolicy(
|
||||
(Integer)((SpinnerOption)mDeletePolicyView.getSelectedItem()).value);
|
||||
|
||||
mCallback.onProceedNext();
|
||||
mCallback.onProceedNext(SetupData.CHECK_INCOMING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,14 +86,14 @@ public class AccountSetupOutgoing extends Activity
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements AccountSetupIncomingFragment.Listener
|
||||
* Implements AccountServerBaseFragment.Callback
|
||||
*/
|
||||
public void onProceedNext() {
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, SetupData.CHECK_OUTGOING);
|
||||
public void onProceedNext(int checkMode) {
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, checkMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements AccountSetupIncomingFragment.Listener
|
||||
* Implements AccountServerBaseFragment.Callback
|
||||
*/
|
||||
public void onEnableProceedButtons(boolean enabled) {
|
||||
mNextButton.setEnabled(enabled);
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.android.email.Utility;
|
|||
import com.android.email.provider.EmailContent;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
|
@ -44,7 +43,8 @@ import android.widget.Spinner;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class AccountSetupOutgoingFragment extends Fragment implements OnCheckedChangeListener {
|
||||
public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
|
||||
implements OnCheckedChangeListener {
|
||||
private static final int SMTP_PORTS[] = {
|
||||
587, 465, 465, 587, 587
|
||||
};
|
||||
|
@ -62,25 +62,9 @@ public class AccountSetupOutgoingFragment extends Fragment implements OnCheckedC
|
|||
private Spinner mSecurityTypeView;
|
||||
|
||||
// Support for lifecycle
|
||||
private Context mContext;
|
||||
private Callback mCallback = EmptyCallback.INSTANCE;
|
||||
private boolean mStarted;
|
||||
private boolean mLoaded;
|
||||
|
||||
/**
|
||||
* Callback interface that owning activities must implement
|
||||
*/
|
||||
public interface Callback {
|
||||
public void onEnableProceedButtons(boolean enable);
|
||||
public void onProceedNext();
|
||||
}
|
||||
|
||||
private static class EmptyCallback implements Callback {
|
||||
public static final Callback INSTANCE = new EmptyCallback();
|
||||
@Override public void onProceedNext() { }
|
||||
@Override public void onEnableProceedButtons(boolean enable) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to do initial creation of a fragment. This is called after
|
||||
* {@link #onAttach(Activity)} and before {@link #onActivityCreated(Bundle)}.
|
||||
|
@ -239,9 +223,9 @@ public class AccountSetupOutgoingFragment extends Fragment implements OnCheckedC
|
|||
/**
|
||||
* Activity provides callbacks here. This also triggers loading and setting up the UX
|
||||
*/
|
||||
@Override
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback;
|
||||
mContext = getActivity();
|
||||
super.setCallback(callback);
|
||||
if (mStarted && !mLoaded) {
|
||||
loadSettings();
|
||||
}
|
||||
|
@ -317,7 +301,7 @@ public class AccountSetupOutgoingFragment extends Fragment implements OnCheckedC
|
|||
enabled = false;
|
||||
}
|
||||
}
|
||||
mCallback.onEnableProceedButtons(enabled);
|
||||
enableNextButton(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,6 +321,7 @@ public class AccountSetupOutgoingFragment extends Fragment implements OnCheckedC
|
|||
/**
|
||||
* Entry point from Activity after editing settings and verifying them. Must be FLOW_MODE_EDIT.
|
||||
*/
|
||||
@Override
|
||||
public void saveSettingsAfterEdit() {
|
||||
EmailContent.Account account = SetupData.getAccount();
|
||||
if (account.isSaved()) {
|
||||
|
@ -373,6 +358,7 @@ public class AccountSetupOutgoingFragment extends Fragment implements OnCheckedC
|
|||
/**
|
||||
* Entry point from Activity, when "next" button is clicked
|
||||
*/
|
||||
@Override
|
||||
public void onNext() {
|
||||
EmailContent.Account account = SetupData.getAccount();
|
||||
try {
|
||||
|
@ -386,6 +372,6 @@ public class AccountSetupOutgoingFragment extends Fragment implements OnCheckedC
|
|||
*/
|
||||
throw new Error(use);
|
||||
}
|
||||
mCallback.onProceedNext();
|
||||
mCallback.onProceedNext(SetupData.CHECK_OUTGOING);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue