mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-11 12:05:06 -05:00
Moved the content of the dialog asking for email/pasw to separate activity as was asked. Support for a 'default account checkbox' is still included but commented out for now. The new AccountSetupGetLogin actvity is a very stripped down version of the old AccountSetupBase activity.
This commit is contained in:
parent
80f46a1305
commit
bb9bb70a94
@ -104,6 +104,12 @@
|
||||
android:configChanges="locale"
|
||||
>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.fsck.k9.activity.setup.AccountSetupGetLogin"
|
||||
android:label="@string/account_setup_basics_title"
|
||||
android:configChanges="locale"
|
||||
>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.fsck.k9.activity.setup.AccountSetupAutoConfiguration"
|
||||
android:label="@string/account_setup_autoconfig_title"
|
||||
|
@ -42,13 +42,13 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:nextFocusDown="@+id/next"
|
||||
/>
|
||||
<CheckBox
|
||||
<!--<CheckBox
|
||||
android:id="@+id/account_default"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:text="@string/account_setup_basics_default_label"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
/>-->
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dip"
|
||||
|
109
src/com/fsck/k9/activity/setup/AccountSetupGetLogin.java
Normal file
109
src/com/fsck/k9/activity/setup/AccountSetupGetLogin.java
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
package com.fsck.k9.activity.setup;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import com.fsck.k9.*;
|
||||
import com.fsck.k9.activity.K9Activity;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
|
||||
|
||||
/**
|
||||
* Prompts the user for the email address and password. Also prompts for
|
||||
* "Use this account as default" if this is the 2nd+ account being set up.
|
||||
*/
|
||||
public class AccountSetupGetLogin extends K9Activity
|
||||
implements OnClickListener, TextWatcher {
|
||||
|
||||
public static void startForResult(Activity act) {
|
||||
act.startActivityForResult(new Intent(act,AccountSetupGetLogin.class), AccountSetupIndex.GET_LOGIN);
|
||||
}
|
||||
|
||||
private EditText mEmailView;
|
||||
private EditText mPasswordView;
|
||||
//private CheckBox mDefaultView;
|
||||
private Button mNextButton;
|
||||
private Button mManualSetupButton;
|
||||
|
||||
private EmailAddressValidator mEmailValidator = new EmailAddressValidator();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.account_setup_basics);
|
||||
|
||||
mEmailView = (EditText)findViewById(R.id.account_email);
|
||||
mPasswordView = (EditText)findViewById(R.id.account_password);
|
||||
//mDefaultView = (CheckBox)findViewById(R.id.account_default);
|
||||
mNextButton = (Button)findViewById(R.id.next);
|
||||
mManualSetupButton = (Button)findViewById(R.id.manual_setup);
|
||||
|
||||
mNextButton.setOnClickListener(this);
|
||||
mManualSetupButton.setOnClickListener(this);
|
||||
|
||||
mEmailView.addTextChangedListener(this);
|
||||
mPasswordView.addTextChangedListener(this);
|
||||
|
||||
/*if (mPrefs.getAccounts().length > 0) {
|
||||
mDefaultView.setVisibility(View.VISIBLE);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
validateFields();
|
||||
}
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
validateFields();
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
private void validateFields() {
|
||||
String email = mEmailView.getText().toString();
|
||||
boolean valid = Utility.requiredFieldValid(mEmailView)
|
||||
&& Utility.requiredFieldValid(mPasswordView)
|
||||
&& mEmailValidator.isValidAddressOnly(email);
|
||||
|
||||
mNextButton.setEnabled(valid);
|
||||
mManualSetupButton.setEnabled(valid);
|
||||
/*
|
||||
* Dim the next button's icon to 50% if the button is disabled.
|
||||
* TODO this can probably be done with a stateful drawable. Check into it.
|
||||
* android:state_enabled
|
||||
*/
|
||||
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra(AccountSetupIndex.DATA_LOGIN, mEmailView.getText().toString());
|
||||
data.putExtra(AccountSetupIndex.DATA_PASSWORD, mPasswordView.getText().toString());
|
||||
//data.putExtra(AccountSetupIndex.DATA_DEFAULT, mDefaultView.isChecked());
|
||||
switch (v.getId()) {
|
||||
case R.id.next:
|
||||
data.putExtra(AccountSetupIndex.DATA_MANUAL, false);
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
break;
|
||||
case R.id.manual_setup:
|
||||
data.putExtra(AccountSetupIndex.DATA_MANUAL, true);
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,20 +6,13 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.*;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import com.fsck.k9.*;
|
||||
import com.fsck.k9.activity.K9ListActivity;
|
||||
import com.fsck.k9.helper.Contacts;
|
||||
import com.fsck.k9.helper.SectionListAdapter;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
@ -36,12 +29,18 @@ public class AccountSetupIndex extends K9ListActivity implements OnItemClickList
|
||||
private static final int DIALOG_BACKUP_ACCOUNT = 2;
|
||||
|
||||
private static final String BUNDLE_TYPE_SUGGESTION = "SUGGESTION";
|
||||
public static final int GET_LOGIN = 1;
|
||||
|
||||
public static final String DATA_LOGIN = "datalogin";
|
||||
public static final String DATA_PASSWORD = "datapassword";
|
||||
public static final String DATA_DEFAULT = "datadefault";
|
||||
public static final String DATA_MANUAL = "datamanual";
|
||||
|
||||
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 bMakeDefault = true;
|
||||
|
||||
private Account mAccount;
|
||||
private Button mNewAccountDialogButton;
|
||||
private Button mPasswordDialogButton;
|
||||
private EmailAddressValidator mEmailValidator = new EmailAddressValidator();
|
||||
@ -100,11 +99,24 @@ public class AccountSetupIndex extends K9ListActivity implements OnItemClickList
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.new_account:
|
||||
showDialog(DIALOG_NEW_ACCOUNT);
|
||||
//showDialog(DIALOG_NEW_ACCOUNT);
|
||||
AccountSetupGetLogin.startForResult(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if( requestCode == GET_LOGIN && resultCode == RESULT_OK){
|
||||
String login = data.getStringExtra(DATA_LOGIN);
|
||||
String pasw = data.getStringExtra(DATA_PASSWORD);
|
||||
boolean defaultAcc = data.getBooleanExtra(DATA_DEFAULT, false);
|
||||
boolean manual = data.getBooleanExtra(DATA_MANUAL, false);
|
||||
|
||||
if( manual ) onManualSetup(login, pasw);
|
||||
else startSettingsDetection(login, pasw);
|
||||
}
|
||||
}
|
||||
/*
|
||||
Dialogues
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user