merged from trunk as of r213

This commit is contained in:
Jesse Vincent 2008-12-19 00:20:56 +00:00
parent 14e6b87ee7
commit 5a55389835
6 changed files with 118 additions and 30 deletions

View File

@ -17,6 +17,11 @@
android:title="@string/compose_action"
android:icon="@drawable/ic_menu_compose"
/>
<item
android:id="@+id/about"
android:title="@string/about_action"
android:icon="@drawable/ic_menu_preferences"
/>
<!--
<item android:id="@+id/search"
android:title="@string/search_action" />

View File

@ -1,11 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">K-9</string>
<string name="app_name">K-9</string>
<string name="app_authors">Google, The K-9 Krew, and a cast of thousands.</string>
<string name="app_authors_fmt">Authors: <xliff:g id="app_authors">%s</xliff:g></string>
<string name="app_revision_url">http://code.google.com/p/k9mail/wiki/ReleaseNotes</string>
<string name="app_revision_fmt">Revision Information: <xliff:g id="app_revision_url">%s</xliff:g></string>
<string name="app_webpage_url">http://code.google.com/p/k9mail/</string>
<string name="read_attachment_label">read Email attachments</string>
<string name="read_attachment_desc">Allows this application to read your Email attachments.</string>
<string name="accounts_title">Your accounts</string>
<string name="about_title_fmt">About <xliff:g id="app_name">%s</xliff:g></string>
<string name="accounts_title">Your accounts</string>
<string name="compose_title">Compose</string>
<string name="debug_title">Debug</string>
@ -43,7 +49,8 @@
<string name="edit_subject_action">Edit subject</string>
<string name="add_attachment_action">Add attachment</string>
<string name="dump_settings_action">Dump settings</string>
<string name="empty_trash_action">Empty Trash</string>
<string name="empty_trash_action">Empty Trash</string>
<string name="about_action">About</string>
<string name="accounts_context_menu_title">Account options</string>
@ -132,6 +139,9 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
<string name="message_deleted_toast">Message deleted.</string>
<string name="message_discarded_toast">Message discarded.</string>
<string name="message_saved_toast">Message saved as draft.</string>
<string name="about_header">About <xliff:g id="app_name">%s</xliff:g></string>
<string name="about_version">Version: <xliff:g id="version">%s</xliff:g></string>
<string name="account_setup_basics_title">Set up email</string>
<string name="account_setup_basics_instructions">Type your account email address:</string>

View File

@ -10,6 +10,7 @@ import java.util.Date;
import com.android.email.codec.binary.Base64;
import android.text.Editable;
import android.widget.EditText;
import android.widget.TextView;
public class Utility {
@ -75,11 +76,28 @@ public class Utility {
public static boolean requiredFieldValid(TextView view) {
return view.getText() != null && view.getText().length() > 0;
}
public static boolean requiredFieldValid(Editable s) {
return s != null && s.length() > 0;
}
public static boolean domainFieldValid(EditText view) {
if (view.getText() != null) {
String s = view.getText().toString();
if (s.matches("^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$")) {
return true;
}
if (s.matches("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")) {
return true;
}
if ((s.equalsIgnoreCase("localhost"))||(s.equalsIgnoreCase("localhost.localdomain"))) {
return true;
}
}
return false;
}
/**
* Ensures that the given string starts and ends with the double quote character. The string is not modified in any way except to add the
* double quote character to start and end if it's not already there.
@ -173,4 +191,5 @@ public class Utility {
// }
// }
}
}

View File

@ -8,6 +8,8 @@ import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.KeyEvent;
@ -15,10 +17,13 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.AdapterContextMenuInfo;
@ -31,6 +36,7 @@ import com.android.email.Preferences;
import com.android.email.R;
import com.android.email.activity.setup.AccountSettings;
import com.android.email.activity.setup.AccountSetupBasics;
import com.android.email.activity.setup.AccountSetupCheckSettings;
import com.android.email.mail.MessagingException;
import com.android.email.mail.Store;
import com.android.email.mail.store.LocalStore;
@ -198,13 +204,58 @@ public class Accounts extends ListActivity implements OnItemClickListener, OnCli
case R.id.compose:
onCompose();
break;
case R.id.about:
onAbout();
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
private void onAbout() {
String appName = getString(R.string.app_name);
WebView wv = new WebView(this);
String html = "<h1>" + String.format(getString(R.string.about_title_fmt).toString(),
"<a href=\"" + getString(R.string.app_webpage_url) + "\">" + appName + "</a>") + "</h1>" +
"<p>" + appName + " " +
String.format(getString(R.string.debug_version_fmt).toString(),
getVersionNumber()) + "</p>" +
"<p>" + String.format(getString(R.string.app_authors_fmt).toString(),
getString(R.string.app_authors)) + "</p>" +
"<p>" + String.format(getString(R.string.app_revision_fmt).toString(),
"<a href=\"" + getString(R.string.app_revision_url) + "\">" +
getString(R.string.app_revision_url) + "</a></p>");
wv.loadData(html, "text/html", "utf-8");
new AlertDialog.Builder(this)
.setView(wv)
.setCancelable(true)
.setPositiveButton(R.string.okay_action, new DialogInterface.OnClickListener () {
public void onClick(DialogInterface d, int c) {
d.dismiss();
}
})
.show();
}
/**
* Get current version number.
*
* @return String version
*/
private String getVersionNumber() {
String version = "?";
try {
PackageInfo pi =
getPackageManager().getPackageInfo(getPackageName(), 0);
version = pi.versionName;
} catch (PackageManager.NameNotFoundException e) {
//Log.e(TAG, "Package name not found", e);
};
return version;
}
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
return true;
}

View File

@ -5,6 +5,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
@ -254,7 +256,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
mNextButton
.setEnabled(Utility.requiredFieldValid(mUsernameView)
&& Utility.requiredFieldValid(mPasswordView)
&& Utility.requiredFieldValid(mServerView)
&& Utility.domainFieldValid(mServerView)
&& Utility.requiredFieldValid(mPortView));
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
}
@ -301,31 +303,32 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
}
private void onNext() {
int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
try {
String path = null;
if (mAccountSchemes[securityType].startsWith("imap")) {
path = "/" + mImapPathPrefixView.getText();
}
URI uri = new URI(
mAccountSchemes[securityType],
mUsernameView.getText() + ":" + mPasswordView.getText(),
mServerView.getText().toString(),
Integer.parseInt(mPortView.getText().toString()),
path, // path
null, // query
null);
mAccount.setStoreUri(uri.toString());
} catch (URISyntaxException use) {
/*
* It's unrecoverable if we cannot create a URI from components that
* we validated to be safe.
*/
throw new Error(use);
}
int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
try {
String path = null;
if (mAccountSchemes[securityType].startsWith("imap")) {
path = "/" + mImapPathPrefixView.getText();
}
URI uri = new URI(
mAccountSchemes[securityType],
mUsernameView.getText() + ":" + mPasswordView.getText(),
mServerView.getText().toString(),
Integer.parseInt(mPortView.getText().toString()),
path, // path
null, // query
null);
mAccount.setStoreUri(uri.toString());
} catch (URISyntaxException use) {
/*
* It's unrecoverable if we cannot create a URI from components that
* we validated to be safe.
*/
throw new Error(use);
}
mAccount.setDeletePolicy((Integer)((SpinnerOption)mDeletePolicyView.getSelectedItem()).value);
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, false);
mAccount.setDeletePolicy((Integer)((SpinnerOption)mDeletePolicyView.getSelectedItem()).value);
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, false);
}
public void onClick(View v) {

View File

@ -222,7 +222,7 @@ public class AccountSetupOutgoing extends Activity implements OnClickListener,
private void validateFields() {
mNextButton
.setEnabled(
Utility.requiredFieldValid(mServerView) &&
Utility.domainFieldValid(mServerView) &&
Utility.requiredFieldValid(mPortView) &&
(!mRequireLoginView.isChecked() ||
(Utility.requiredFieldValid(mUsernameView) &&