1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 20:15:03 -05:00

Added two new activities to allow for confirming/choosing the detected settings. Also connected them to the next button in the autoconfiguration activity.

This commit is contained in:
dzan 2011-07-20 14:52:42 +02:00 committed by Andrew Chen
parent 2423c45ec2
commit cba9ccd416
6 changed files with 207 additions and 8 deletions

View File

@ -108,6 +108,18 @@
android:configChanges="keyboardHidden|orientation|locale" android:configChanges="keyboardHidden|orientation|locale"
> >
</activity> </activity>
<activity
android:name="com.fsck.k9.activity.setup.AccountSetupConfirmIncoming"
android:label="@string/account_setup_autoconfig_title"
android:configChanges="keyboardHidden|orientation|locale"
>
</activity>
<activity
android:name="com.fsck.k9.activity.setup.AccountSetupConfirmOutgoing"
android:label="@string/account_setup_autoconfig_title"
android:configChanges="keyboardHidden|orientation|locale"
>
</activity>
<activity <activity
android:name="com.fsck.k9.activity.setup.AccountSetupAccountType" android:name="com.fsck.k9.activity.setup.AccountSetupAccountType"
android:label="@string/account_setup_account_type_title" android:label="@string/account_setup_account_type_title"

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Spinner
android:id="@+id/spinner_hostname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:prompt="@string/account_setup_basics_email_hint"
/>
<Spinner
android:id="@+id/spinner_protocol"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:prompt="@string/account_setup_basics_email_hint"
android:layout_below="@id/spinner_hostname"
/>
</RelativeLayout>

View File

@ -369,6 +369,8 @@ http://k9mail.googlecode.com/
<string name="account_setup_check_settings_canceling_msg">Canceling\u2026</string> <string name="account_setup_check_settings_canceling_msg">Canceling\u2026</string>
<string name="account_setup_autoconfig_title">Autoconfiguration attempt</string> <string name="account_setup_autoconfig_title">Autoconfiguration attempt</string>
<string name="account_setup_confirm_incoming_title">Confirm incoming server settings</string>
<string name="account_setup_confirm_outgoing_title">Confirm outgoing server settings</string>
<string name="account_setup_autoconfig_info">Attempting to configure your account...</string> <string name="account_setup_autoconfig_info">Attempting to configure your account...</string>
<string name="account_setup_autoconfig_test_safe_serverside">Looking for safe server-side configuration files...</string> <string name="account_setup_autoconfig_test_safe_serverside">Looking for safe server-side configuration files...</string>
<string name="account_setup_autoconfig_test_unsafe_serverside">Looking for UNSAFE server-side configuration files...</string> <string name="account_setup_autoconfig_test_unsafe_serverside">Looking for UNSAFE server-side configuration files...</string>

View File

@ -14,9 +14,11 @@ import android.widget.TextView;
import com.fsck.k9.K9; import com.fsck.k9.K9;
import com.fsck.k9.R; import com.fsck.k9.R;
import com.fsck.k9.activity.K9Activity; import com.fsck.k9.activity.K9Activity;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
import com.fsck.k9.helper.configxmlparser.ConfigurationXMLHandler; import com.fsck.k9.helper.configxmlparser.ConfigurationXMLHandler;
import com.fsck.k9.mail.store.TrustManagerFactory; import com.fsck.k9.mail.store.TrustManagerFactory;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.Parser;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
@ -85,6 +87,7 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
private String mEmailAddress; private String mEmailAddress;
private String mPassword; private String mPassword;
private String mLastMessage; private String mLastMessage;
private AutoconfigInfo mAutoConfigInfo;
private boolean bForceManual = false; private boolean bForceManual = false;
private boolean bDoneSearching = false; private boolean bDoneSearching = false;
private boolean bFound = false; private boolean bFound = false;
@ -257,10 +260,12 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
Start parsing the xml Start parsing the xml
*/ */
private void parse(String data) throws IOException, SAXException, ParserConfigurationException { private void parse(String data) throws IOException, SAXException, ParserConfigurationException {
ConfigurationXMLHandler parser = new ConfigurationXMLHandler();
XMLReader xr = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); XMLReader xr = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
xr.setContentHandler(new ConfigurationXMLHandler()); xr.setContentHandler(parser);
// TODO: see if this has performance consequences, otherwise change all so we pass around InputSource not string // TODO: see if this has performance consequences, otherwise change all so we pass around InputSource not string
xr.parse(new InputSource(new StringReader(data))); xr.parse(new InputSource(new StringReader(data)));
mAutoConfigInfo = parser.getAutoconfigInfo();
} }
/* /*
@ -367,12 +372,6 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
return retParts; return retParts;
} }
@Override
public void onActivityResult(int reqCode, int resCode, Intent data) {
setResult(resCode);
finish();
}
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.autoconfig_button_cancel: case R.id.autoconfig_button_cancel:
@ -384,7 +383,9 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
// launch confirm activities // launch confirm activities
}else{ }else{
AccountSetupConfirmIncoming.actionConfirmIncoming
(this, mEmailAddress, mPassword, mAutoConfigInfo);
finish();
} }
break; break;
default: return; default: return;
@ -394,6 +395,7 @@ public class AccountSetupAutoConfiguration extends K9Activity implements View.On
/* /*
Ask the user to accept ssl certificates if they are not trusted already. Ask the user to accept ssl certificates if they are not trusted already.
TODO: Rework this so it changes the url counter, not restart intent TODO: Rework this so it changes the url counter, not restart intent
NOTE: It's called but doesn't work right now because for the connection the default sslfactory is yet used
*/ */
private void acceptKeyDialog(final int msgResId, final int urlNumber, final Object... args) { private void acceptKeyDialog(final int msgResId, final int urlNumber, final Object... args) {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {

View File

@ -0,0 +1,87 @@
package com.fsck.k9.activity.setup;
/*
After gathering the necessary information one way or another this activity displays it to the user, eventually warns
him it could be false ( no https ), asks for confirmation, allows selection of protocol,... and then goes on to test
the final settings.
*/
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.fsck.k9.Account;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.activity.K9Activity;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
public class AccountSetupConfirmIncoming extends K9Activity implements View.OnClickListener {
private static final String EXTRA_ACCOUNT = "account";
private static final String EXTRA_CONFIG_INFO = "configInfo";
private static final String EXTRA_EMAIL = "email";
private static final String EXTRA_PASSWORD = "password";
public static void actionConfirmIncoming(Context context, Account account, AutoconfigInfo info) {
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
i.putExtra(EXTRA_CONFIG_INFO, info);
context.startActivity(i);
}
public static void actionConfirmIncoming(Context context, String email, String password, AutoconfigInfo info){
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
i.putExtra(EXTRA_EMAIL, email);
i.putExtra(EXTRA_PASSWORD, password);
i.putExtra(EXTRA_CONFIG_INFO, info);
context.startActivity(i);
}
// data
Account mAccount;
AutoconfigInfo mConfigInfo;
// gui elements
Spinner mProtocolSpinner;
Spinner mHostnameSpinner;
@Override
public void onCreate(Bundle savedInstance){
super.onCreate(savedInstance);
setContentView(R.layout.account_setup_confirm);
// initialise gui elements from inflated layout
mHostnameSpinner = (Spinner) findViewById(R.id.spinner_hostname);
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
// get the data out of our intent
// if no blank account passed make one
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
if(accountUuid != null)
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
else mAccount = Account.getBlankAccount(this,
getIntent().getStringExtra(EXTRA_EMAIL),
getIntent().getStringExtra(EXTRA_PASSWORD));
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
// attach data to gui elements
// TODO: could make it's own layout xml..
ArrayAdapter<ServerType> protocolAdapter =
new ArrayAdapter<ServerType>(this, R.layout.account_setup_index_list_item, mConfigInfo.getAvailableIncomingServerTypes());
mHostnameSpinner.setAdapter(protocolAdapter);
// attach the listeners
}
@Override
public void onClick(View view) {
//To change body of implemented methods use File | Settings | File Templates.
}
}

View File

@ -0,0 +1,72 @@
package com.fsck.k9.activity.setup;
/*
After gathering the necessary information one way or another this activity displays it to the user, eventually warns
him it could be false ( no https ), asks for confirmation, allows selection of protocol,... and then goes on to test
the final settings.
*/
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.fsck.k9.Account;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.activity.K9Activity;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
public class AccountSetupConfirmOutgoing extends K9Activity implements View.OnClickListener{
private static final String EXTRA_ACCOUNT = "account";
private static final String EXTRA_CONFIG_INFO = "configInfo";
private static final String EXTRA_EMAIL = "email";
private static final String EXTRA_PASSWORD = "password";
public static void actionConfirmOutgoing(Context context, Account account, AutoconfigInfo info) {
Intent i = new Intent(context, AccountSetupConfirmOutgoing.class);
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
i.putExtra(EXTRA_CONFIG_INFO, info);
context.startActivity(i);
}
public static void actionConfirmOutgoing(Context context, String email, String password, AutoconfigInfo info){
Intent i = new Intent(context, AccountSetupConfirmOutgoing.class);
i.putExtra(EXTRA_EMAIL, email);
i.putExtra(EXTRA_PASSWORD, password);
i.putExtra(EXTRA_CONFIG_INFO, info);
context.startActivity(i);
}
// data
Account mAccount;
AutoconfigInfo mConfigInfo;
@Override
public void onCreate(Bundle savedInstance){
super.onCreate(savedInstance);
setContentView(R.layout.account_setup_confirm);
// initialise gui elements from inflated layout
// get the data out of our intent
// if no blank account passed make one
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
if(accountUuid != null)
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
else mAccount = Account.getBlankAccount(this,
getIntent().getStringExtra(EXTRA_EMAIL),
getIntent().getStringExtra(EXTRA_PASSWORD));
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
// attach the listeners
}
@Override
public void onClick(View view) {
//To change body of implemented methods use File | Settings | File Templates.
}
}