mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-11 12:05:06 -05:00
Added support for "Default account" setting in setup.
This commit is contained in:
parent
8459fba206
commit
1c4ebf15b7
@ -39,6 +39,12 @@
|
||||
android:lines="1"
|
||||
android:text="@string/account_setup_basics_manual_setup_action"/>
|
||||
|
||||
<CheckBox android:id="@+id/account_dialog_default_box"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:lines="1"
|
||||
android:text="@string/account_settings_default"/>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -25,6 +25,12 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:text="@string/account_setup_basics_manual_setup_action"/>
|
||||
|
||||
<CheckBox android:id="@+id/account_dialog_default_box"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:lines="1"
|
||||
android:text="@string/account_settings_default"/>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -40,6 +40,7 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
||||
protected static final String EXTRA_CONFIG_INFO = "configInfo";
|
||||
protected static final String EXTRA_EMAIL = "email";
|
||||
protected static final String EXTRA_PASSWORD = "password";
|
||||
protected static final String EXTRA_MAKEDEFAULT = "default";
|
||||
|
||||
private final String LOCALPART_EMAIL = "%EMAILLOCALPART%";
|
||||
private final String WHOLE_EMAIL = "%EMAILADDRESS%";
|
||||
@ -51,6 +52,7 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
||||
protected String mUsername;
|
||||
private boolean mCustomUsername = false;
|
||||
protected String mPassword;
|
||||
protected boolean mMakeDefault;
|
||||
|
||||
// references to current selections ( easier to code with )
|
||||
protected Server mCurrentServer;
|
||||
@ -104,6 +106,7 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
||||
else mAccount = Account.getBlankAccount(this, mEmail, mPassword);
|
||||
|
||||
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
|
||||
mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKEDEFAULT, false);
|
||||
|
||||
// attach data to gui elements
|
||||
ArrayAdapter<ServerType> protocolAdapter = new ArrayAdapter<ServerType>(this,
|
||||
|
@ -42,6 +42,7 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
|
||||
|
||||
private static final String EMAIL_ADDRESS = "account";
|
||||
private static final String PASSWORD = "password";
|
||||
private static final String MAKEDEFAULT = "default";
|
||||
|
||||
// timeout for testing services availability ( in ms )
|
||||
private static final int TIMEOUT = 5000;
|
||||
@ -87,6 +88,7 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
|
||||
private String mEmailAddress;
|
||||
private String mPassword;
|
||||
private String mLastMessage;
|
||||
private boolean mMakeDefault;
|
||||
private AutoconfigInfo mAutoConfigInfo;
|
||||
private boolean bForceManual = false;
|
||||
private boolean bDoneSearching = false;
|
||||
@ -97,10 +99,11 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
|
||||
/*
|
||||
Start the auto-configuration activity
|
||||
*/
|
||||
public static void actionAttemptConfiguration(Activity context, String email, String password) {
|
||||
public static void actionAttemptConfiguration(Activity context, String email, String password, boolean makedefault) {
|
||||
Intent i = new Intent(context, AccountSetupAutoConfiguration.class);
|
||||
i.putExtra(EMAIL_ADDRESS, email);
|
||||
i.putExtra(PASSWORD, password);
|
||||
i.putExtra(MAKEDEFAULT, makedefault);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
@ -129,6 +132,7 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
|
||||
// Getting our data to work with
|
||||
mEmailAddress = getIntent().getStringExtra(EMAIL_ADDRESS);
|
||||
mPassword = getIntent().getStringExtra(PASSWORD);
|
||||
mMakeDefault = getIntent().getBooleanExtra(MAKEDEFAULT, false);
|
||||
|
||||
// The real action, in a separate thread
|
||||
new Thread() {
|
||||
@ -381,12 +385,12 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
|
||||
// autoconfig failed, proceed by manual setup
|
||||
if( bForceManual ){
|
||||
// TODO: get boolean from user
|
||||
AccountSetupAccountType.actionStartManualConfiguration(this, mEmailAddress, mPassword, false);
|
||||
AccountSetupAccountType.actionStartManualConfiguration(this, mEmailAddress, mPassword, mMakeDefault);
|
||||
finish();
|
||||
// launch confirm activities
|
||||
}else{
|
||||
AccountSetupConfirmIncoming.actionConfirmIncoming
|
||||
(this, null, mEmailAddress, mPassword, mAutoConfigInfo);
|
||||
(this, null, mEmailAddress, mPassword, mAutoConfigInfo,mMakeDefault);
|
||||
finish();
|
||||
}
|
||||
break;
|
||||
@ -447,7 +451,7 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
|
||||
e.getMessage() == null ? "" : e.getMessage()), true);
|
||||
}
|
||||
// TODO: rework this so we just retry the last URL, DO NOT RESTART THE WHOLE ACTIVITY!!
|
||||
AccountSetupAutoConfiguration.actionAttemptConfiguration(AccountSetupAutoConfiguration.this, mEmailAddress, mPassword);
|
||||
AccountSetupAutoConfiguration.actionAttemptConfiguration(AccountSetupAutoConfiguration.this, mEmailAddress, mPassword, mMakeDefault);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(
|
||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||
public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity {
|
||||
|
||||
// account is allowed to be null
|
||||
public static void actionConfirmIncoming(Context context, Account account, String email, String password, AutoconfigInfo info) {
|
||||
public static void actionConfirmIncoming(Context context, Account account, String email, String password, AutoconfigInfo info, boolean makedefault) {
|
||||
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
||||
if( account != null )
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
@ -32,6 +32,7 @@ public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity {
|
||||
i.putExtra(EXTRA_EMAIL, email);
|
||||
i.putExtra(EXTRA_PASSWORD, password);
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
i.putExtra(EXTRA_MAKEDEFAULT, makedefault);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
@ -60,7 +61,7 @@ public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity {
|
||||
null,null,null);
|
||||
mAccount.setStoreUri(uri.toString());
|
||||
|
||||
AccountSetupConfirmOutgoing.actionConfirmOutgoing(this, mAccount, mEmail, mPassword, mConfigInfo);
|
||||
AccountSetupConfirmOutgoing.actionConfirmOutgoing(this, mAccount, mEmail, mPassword, mConfigInfo, mMakeDefault);
|
||||
}
|
||||
catch (UnsupportedEncodingException enc) {}
|
||||
catch (URISyntaxException use) {
|
||||
|
@ -24,12 +24,13 @@ import java.util.List;
|
||||
public class AccountSetupConfirmOutgoing extends AbstractSetupConfirmActivity{
|
||||
|
||||
// account is allowed to be null
|
||||
public static void actionConfirmOutgoing(Context context, Account account, String email, String password, AutoconfigInfo info) {
|
||||
public static void actionConfirmOutgoing(Context context, Account account, String email, String password, AutoconfigInfo info, boolean makedefault) {
|
||||
Intent i = new Intent(context, AccountSetupConfirmOutgoing.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_EMAIL, email);
|
||||
i.putExtra(EXTRA_PASSWORD, password);
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
i.putExtra(EXTRA_MAKEDEFAULT, makedefault);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
@ -84,14 +85,13 @@ public class AccountSetupConfirmOutgoing extends AbstractSetupConfirmActivity{
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
||||
// should verify but this normaly shouldn't happen, this activity is only used for initial setup, not edit
|
||||
mAccount.save(Preferences.getPreferences(this));
|
||||
finish();
|
||||
} else {
|
||||
// have to pop up to ask if it should be default account now
|
||||
// hard-coded now for test purposes
|
||||
AccountSetupOptions.actionOptions(this, mAccount, true);
|
||||
AccountSetupOptions.actionOptions(this, mAccount, mMakeDefault);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class AccountSetupIndex extends K9ListActivity implements OnItemClickList
|
||||
public enum SuggestionType { DEVICE, BACKUP, NEW }
|
||||
|
||||
// temp hard coded value ( since we don't ask if it should be default account for now )
|
||||
private boolean bTmpDefaultAccount = true;
|
||||
private boolean bMakeDefault = true;
|
||||
|
||||
private Account mAccount;
|
||||
private Button mNewAccountDialogButton;
|
||||
@ -119,6 +119,7 @@ public class AccountSetupIndex extends K9ListActivity implements OnItemClickList
|
||||
final EditText emailField = ((EditText)dialog.findViewById(R.id.account_dialog_address_field));
|
||||
final EditText passwordField = ((EditText)dialog.findViewById(R.id.account_dialog_password_field));
|
||||
final CheckBox manualCheck = (CheckBox)dialog.findViewById(R.id.account_dialog_manual_box);
|
||||
final CheckBox defaultCheck = (CheckBox)dialog.findViewById(R.id.account_dialog_default_box);
|
||||
|
||||
mNewAccountDialogButton = ((Button)dialog.findViewById(R.id.account_dialog_next));
|
||||
|
||||
@ -160,11 +161,13 @@ public class AccountSetupIndex extends K9ListActivity implements OnItemClickList
|
||||
|
||||
final EditText passwordField = ((EditText) dialog.findViewById(R.id.account_dialog_password_field));
|
||||
final CheckBox manualCheck = (CheckBox)dialog.findViewById(R.id.account_dialog_manual_box);
|
||||
final CheckBox defaultCheck = (CheckBox)dialog.findViewById(R.id.account_dialog_default_box);
|
||||
|
||||
mPasswordDialogButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
String email = args.get(BUNDLE_TYPE_SUGGESTION).toString();
|
||||
String password = passwordField.getText().toString();
|
||||
bMakeDefault = defaultCheck.isChecked();
|
||||
|
||||
// TODO: replace this with a few listeners on the fields that activate/deactive the button on acceptable values
|
||||
if( password.isEmpty() ) return;
|
||||
@ -180,12 +183,12 @@ public class AccountSetupIndex extends K9ListActivity implements OnItemClickList
|
||||
}
|
||||
|
||||
private void onManualSetup(String email, String password) {
|
||||
AccountSetupAccountType.actionStartManualConfiguration(this, email, password, bTmpDefaultAccount);
|
||||
AccountSetupAccountType.actionStartManualConfiguration(this, email, password, bMakeDefault);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void startSettingsDetection(String email, String password) {
|
||||
AccountSetupAutoConfiguration.actionAttemptConfiguration(this, email, password);
|
||||
AccountSetupAutoConfiguration.actionAttemptConfiguration(this, email, password, bMakeDefault);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user