mirror of
https://github.com/moparisthebest/k-9
synced 2025-03-03 01:51:49 -05:00
tidied activity code: astyle --style=java -s4 --brackets=attach --convert-tabs
This commit is contained in:
parent
094215ebe0
commit
c6b15012e0
@ -55,193 +55,172 @@ import com.android.email.mail.store.LocalStore.LocalFolder;
|
||||
public class Accounts extends K9ListActivity implements OnItemClickListener, OnClickListener {
|
||||
private static final int DIALOG_REMOVE_ACCOUNT = 1;
|
||||
private ConcurrentHashMap<String, Integer> unreadMessageCounts = new ConcurrentHashMap<String, Integer>();
|
||||
|
||||
|
||||
private ConcurrentHashMap<Account, String> pendingWork = new ConcurrentHashMap<Account, String>();
|
||||
|
||||
|
||||
private Account mSelectedContextAccount;
|
||||
|
||||
|
||||
private AccountsHandler mHandler = new AccountsHandler();
|
||||
private AccountsAdapter mAdapter;
|
||||
|
||||
|
||||
private class AccountSizeChangedHolder {
|
||||
Account account;
|
||||
long oldSize;
|
||||
long newSize;
|
||||
Account account;
|
||||
long oldSize;
|
||||
long newSize;
|
||||
}
|
||||
|
||||
class AccountsHandler extends Handler
|
||||
{
|
||||
private static final int DATA_CHANGED = 1;
|
||||
private static final int MSG_ACCOUNT_SIZE_CHANGED = 2;
|
||||
private static final int MSG_WORKING_ACCOUNT = 3;
|
||||
private static final int MSG_PROGRESS = 4;
|
||||
private static final int MSG_FOLDER_SYNCING = 5;
|
||||
private static final int MSG_DEFINITE_PROGRESS = 6;
|
||||
|
||||
public void handleMessage(android.os.Message msg)
|
||||
{
|
||||
switch (msg.what)
|
||||
{
|
||||
case DATA_CHANGED:
|
||||
if (mAdapter != null)
|
||||
{
|
||||
mAdapter.notifyDataSetChanged();
|
||||
class AccountsHandler extends Handler {
|
||||
private static final int DATA_CHANGED = 1;
|
||||
private static final int MSG_ACCOUNT_SIZE_CHANGED = 2;
|
||||
private static final int MSG_WORKING_ACCOUNT = 3;
|
||||
private static final int MSG_PROGRESS = 4;
|
||||
private static final int MSG_FOLDER_SYNCING = 5;
|
||||
private static final int MSG_DEFINITE_PROGRESS = 6;
|
||||
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
switch (msg.what) {
|
||||
case DATA_CHANGED:
|
||||
if (mAdapter != null) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
break;
|
||||
case MSG_WORKING_ACCOUNT: {
|
||||
Account account = (Account)msg.obj;
|
||||
int res = msg.arg1;
|
||||
String toastText = getString(res, account.getDescription());
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MSG_WORKING_ACCOUNT:
|
||||
{
|
||||
Account account = (Account)msg.obj;
|
||||
int res = msg.arg1;
|
||||
String toastText = getString(res, account.getDescription());
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
break;
|
||||
}
|
||||
case MSG_ACCOUNT_SIZE_CHANGED:
|
||||
{
|
||||
AccountSizeChangedHolder holder = (AccountSizeChangedHolder)msg.obj;
|
||||
Account account = holder.account;
|
||||
Long oldSize = holder.oldSize;
|
||||
Long newSize = holder.newSize;
|
||||
String toastText = getString(R.string.account_size_changed, account.getDescription(),
|
||||
SizeFormatter.formatSize(getApplication(), oldSize), SizeFormatter.formatSize(getApplication(), newSize));;
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
break;
|
||||
}
|
||||
case MSG_FOLDER_SYNCING:
|
||||
{
|
||||
String folderName = (String) ((Object[]) msg.obj)[0];
|
||||
String dispString;
|
||||
dispString = getString(R.string.accounts_title);
|
||||
if (folderName != null)
|
||||
{
|
||||
dispString += " (" + getString(R.string.status_loading)
|
||||
+ folderName + ")";
|
||||
case MSG_ACCOUNT_SIZE_CHANGED: {
|
||||
AccountSizeChangedHolder holder = (AccountSizeChangedHolder)msg.obj;
|
||||
Account account = holder.account;
|
||||
Long oldSize = holder.oldSize;
|
||||
Long newSize = holder.newSize;
|
||||
String toastText = getString(R.string.account_size_changed, account.getDescription(),
|
||||
SizeFormatter.formatSize(getApplication(), oldSize), SizeFormatter.formatSize(getApplication(), newSize));;
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
break;
|
||||
}
|
||||
case MSG_FOLDER_SYNCING: {
|
||||
String folderName = (String) ((Object[]) msg.obj)[0];
|
||||
String dispString;
|
||||
dispString = getString(R.string.accounts_title);
|
||||
if (folderName != null) {
|
||||
dispString += " (" + getString(R.string.status_loading)
|
||||
+ folderName + ")";
|
||||
}
|
||||
setTitle(dispString);
|
||||
break;
|
||||
}
|
||||
case MSG_PROGRESS:
|
||||
setProgressBarIndeterminateVisibility(msg.arg1 != 0);
|
||||
//setProgressBarVisibility(msg.arg1 != 0);
|
||||
break;
|
||||
case MSG_DEFINITE_PROGRESS:
|
||||
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, msg.arg1);
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
setTitle(dispString);
|
||||
break;
|
||||
}
|
||||
case MSG_PROGRESS:
|
||||
setProgressBarIndeterminateVisibility(msg.arg1 != 0);
|
||||
//setProgressBarVisibility(msg.arg1 != 0);
|
||||
break;
|
||||
case MSG_DEFINITE_PROGRESS:
|
||||
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, msg.arg1);
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void dataChanged()
|
||||
{
|
||||
sendEmptyMessage(DATA_CHANGED);
|
||||
}
|
||||
|
||||
public void workingAccount(Account account, int res)
|
||||
{
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_WORKING_ACCOUNT;
|
||||
msg.obj = account;
|
||||
msg.arg1 = res;
|
||||
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void accountSizeChanged(Account account, long oldSize, long newSize)
|
||||
{
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_ACCOUNT_SIZE_CHANGED;
|
||||
AccountSizeChangedHolder holder = new AccountSizeChangedHolder();
|
||||
holder.account = account;
|
||||
holder.oldSize = oldSize;
|
||||
holder.newSize = newSize;
|
||||
msg.obj = holder;
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void progress(boolean progress)
|
||||
{
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_PROGRESS;
|
||||
msg.arg1 = progress ? 1 : 0;
|
||||
sendMessage(msg);
|
||||
}
|
||||
public void progress(int progress)
|
||||
{
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_DEFINITE_PROGRESS;
|
||||
msg.arg1 = progress ;
|
||||
sendMessage(msg);
|
||||
}
|
||||
public void folderSyncing(String folder)
|
||||
{
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_FOLDER_SYNCING;
|
||||
msg.obj = new String[]
|
||||
{ folder };
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void dataChanged() {
|
||||
sendEmptyMessage(DATA_CHANGED);
|
||||
}
|
||||
|
||||
public void workingAccount(Account account, int res) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_WORKING_ACCOUNT;
|
||||
msg.obj = account;
|
||||
msg.arg1 = res;
|
||||
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void accountSizeChanged(Account account, long oldSize, long newSize) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_ACCOUNT_SIZE_CHANGED;
|
||||
AccountSizeChangedHolder holder = new AccountSizeChangedHolder();
|
||||
holder.account = account;
|
||||
holder.oldSize = oldSize;
|
||||
holder.newSize = newSize;
|
||||
msg.obj = holder;
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void progress(boolean progress) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_PROGRESS;
|
||||
msg.arg1 = progress ? 1 : 0;
|
||||
sendMessage(msg);
|
||||
}
|
||||
public void progress(int progress) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_DEFINITE_PROGRESS;
|
||||
msg.arg1 = progress ;
|
||||
sendMessage(msg);
|
||||
}
|
||||
public void folderSyncing(String folder) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_FOLDER_SYNCING;
|
||||
msg.obj = new String[] { folder };
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
MessagingListener mListener = new MessagingListener() {
|
||||
@Override
|
||||
public void accountStatusChanged(Account account, int unreadMessageCount)
|
||||
{
|
||||
unreadMessageCounts.put(account.getUuid(), unreadMessageCount);
|
||||
mHandler.dataChanged();
|
||||
pendingWork.remove(account);
|
||||
|
||||
@Override
|
||||
public void accountStatusChanged(Account account, int unreadMessageCount) {
|
||||
unreadMessageCounts.put(account.getUuid(), unreadMessageCount);
|
||||
mHandler.dataChanged();
|
||||
pendingWork.remove(account);
|
||||
|
||||
if (pendingWork.isEmpty())
|
||||
{
|
||||
mHandler.progress(Window.PROGRESS_END);
|
||||
|
||||
if (pendingWork.isEmpty()) {
|
||||
mHandler.progress(Window.PROGRESS_END);
|
||||
} else {
|
||||
int level = (Window.PROGRESS_END / mAdapter.getCount()) * (mAdapter.getCount() - pendingWork.size()) ;
|
||||
mHandler.progress(level);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int level = (Window.PROGRESS_END / mAdapter.getCount()) * (mAdapter.getCount() - pendingWork.size()) ;
|
||||
mHandler.progress(level);
|
||||
|
||||
@Override
|
||||
public void accountSizeChanged(Account account, long oldSize, long newSize) {
|
||||
|
||||
mHandler.accountSizeChanged(account, oldSize, newSize);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accountSizeChanged(Account account, long oldSize, long newSize)
|
||||
{
|
||||
|
||||
mHandler.accountSizeChanged(account, oldSize, newSize);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxFinished(
|
||||
Account account,
|
||||
String folder,
|
||||
int totalMessagesInMailbox,
|
||||
int numNewMessages) {
|
||||
MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener);
|
||||
@Override
|
||||
public void synchronizeMailboxFinished(
|
||||
Account account,
|
||||
String folder,
|
||||
int totalMessagesInMailbox,
|
||||
int numNewMessages) {
|
||||
MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener);
|
||||
|
||||
mHandler.progress(false);
|
||||
mHandler.folderSyncing(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxStarted(Account account, String folder)
|
||||
{
|
||||
mHandler.progress(true);
|
||||
mHandler.folderSyncing(account.getDescription()
|
||||
+ getString(R.string.notification_bg_title_separator) + folder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxFailed(Account account, String folder,
|
||||
String message)
|
||||
{
|
||||
mHandler.progress(false);
|
||||
mHandler.folderSyncing(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxStarted(Account account, String folder) {
|
||||
mHandler.progress(true);
|
||||
mHandler.folderSyncing(account.getDescription()
|
||||
+ getString(R.string.notification_bg_title_separator) + folder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void synchronizeMailboxFailed(Account account, String folder,
|
||||
String message) {
|
||||
mHandler.progress(false);
|
||||
mHandler.folderSyncing(null);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -256,7 +235,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
intent.putExtra(EXTRA_STARTUP, true);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
public static void listAccounts(Context context) {
|
||||
Intent intent = new Intent(context, Accounts.class);
|
||||
intent.putExtra(EXTRA_STARTUP, false);
|
||||
@ -274,8 +253,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
if (startup && accounts.length == 1) {
|
||||
FolderList.actionHandleAccount(this, accounts[0], accounts[0].getAutoExpandFolderName());
|
||||
finish();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||
|
||||
@ -316,11 +294,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
refresh();
|
||||
MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MessagingController.getInstance(getApplication()).removeListener(mListener);
|
||||
super.onPause();
|
||||
MessagingController.getInstance(getApplication()).removeListener(mListener);
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
@ -328,15 +306,15 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
mAdapter = new AccountsAdapter(accounts);
|
||||
getListView().setAdapter(mAdapter);
|
||||
if (accounts.length > 0) {
|
||||
mHandler.progress(Window.PROGRESS_START);
|
||||
mHandler.progress(Window.PROGRESS_START);
|
||||
}
|
||||
pendingWork.clear();
|
||||
for (Account account : accounts) {
|
||||
pendingWork.put(account, "true");
|
||||
MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener);
|
||||
|
||||
pendingWork.put(account, "true");
|
||||
MessagingController.getInstance(getApplication()).getAccountUnreadCount(Accounts.this, account, mListener);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void onAddNewAccount() {
|
||||
@ -355,28 +333,27 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
private void onCheckMail(Account account) {
|
||||
MessagingController.getInstance(getApplication()).checkMail(this, account, true, true, null);
|
||||
}
|
||||
|
||||
|
||||
private void onClearCommands(Account account) {
|
||||
MessagingController.getInstance(getApplication()).clearAllPending(account);
|
||||
MessagingController.getInstance(getApplication()).clearAllPending(account);
|
||||
}
|
||||
|
||||
|
||||
private void onEmptyTrash(Account account) {
|
||||
MessagingController.getInstance(getApplication()).emptyTrash(account, null);
|
||||
}
|
||||
MessagingController.getInstance(getApplication()).emptyTrash(account, null);
|
||||
}
|
||||
|
||||
|
||||
private void onCompose() {
|
||||
Account defaultAccount = Preferences.getPreferences(this).getDefaultAccount();
|
||||
if (defaultAccount != null) {
|
||||
MessageCompose.actionCompose(this, defaultAccount);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
onAddNewAccount();
|
||||
}
|
||||
}
|
||||
|
||||
private void onOpenAccount(Account account) {
|
||||
FolderList.actionHandleAccount(this, account, true);
|
||||
FolderList.actionHandleAccount(this, account, true);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
@ -393,19 +370,19 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
@Override
|
||||
public Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
case DIALOG_REMOVE_ACCOUNT:
|
||||
return createRemoveAccountDialog();
|
||||
case DIALOG_REMOVE_ACCOUNT:
|
||||
return createRemoveAccountDialog();
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
|
||||
public void onPrepareDialog(int id, Dialog d) {
|
||||
switch (id) {
|
||||
case DIALOG_REMOVE_ACCOUNT:
|
||||
AlertDialog alert = (AlertDialog) d;
|
||||
alert.setMessage(getString(R.string.account_delete_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
case DIALOG_REMOVE_ACCOUNT:
|
||||
AlertDialog alert = (AlertDialog) d;
|
||||
alert.setMessage(getString(R.string.account_delete_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
}
|
||||
|
||||
super.onPrepareDialog(id, d);
|
||||
@ -414,72 +391,72 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
|
||||
private Dialog createRemoveAccountDialog() {
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.account_delete_dlg_title)
|
||||
.setMessage(getString(R.string.account_delete_dlg_instructions_fmt, mSelectedContextAccount.getDescription()))
|
||||
.setPositiveButton(R.string.okay_action, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_REMOVE_ACCOUNT);
|
||||
try {
|
||||
((LocalStore)Store.getInstance( mSelectedContextAccount.getLocalStoreUri(), getApplication())).delete();
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
mSelectedContextAccount.delete(Preferences.getPreferences(Accounts.this));
|
||||
Email.setServicesEnabled(Accounts.this);
|
||||
refresh();
|
||||
.setTitle(R.string.account_delete_dlg_title)
|
||||
.setMessage(getString(R.string.account_delete_dlg_instructions_fmt, mSelectedContextAccount.getDescription()))
|
||||
.setPositiveButton(R.string.okay_action, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_REMOVE_ACCOUNT);
|
||||
try {
|
||||
((LocalStore)Store.getInstance( mSelectedContextAccount.getLocalStoreUri(), getApplication())).delete();
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel_action, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_REMOVE_ACCOUNT);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
mSelectedContextAccount.delete(Preferences.getPreferences(Accounts.this));
|
||||
Email.setServicesEnabled(Accounts.this);
|
||||
refresh();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel_action, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dismissDialog(DIALOG_REMOVE_ACCOUNT);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
}
|
||||
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)item.getMenuInfo();
|
||||
Account account = (Account)getListView().getItemAtPosition(menuInfo.position);
|
||||
switch (item.getItemId()) {
|
||||
case R.id.edit_prefs:
|
||||
onEditPrefs();
|
||||
break;
|
||||
case R.id.delete_account:
|
||||
onDeleteAccount(account);
|
||||
break;
|
||||
case R.id.edit_account:
|
||||
onEditAccount(account);
|
||||
break;
|
||||
case R.id.open:
|
||||
onOpenAccount(account);
|
||||
break;
|
||||
case R.id.check_mail:
|
||||
onCheckMail(account);
|
||||
break;
|
||||
case R.id.clear_pending:
|
||||
onClearCommands(account);
|
||||
break;
|
||||
case R.id.empty_trash:
|
||||
onEmptyTrash(account);
|
||||
break;
|
||||
case R.id.compact:
|
||||
onCompact(account);
|
||||
break;
|
||||
case R.id.clear:
|
||||
onClear(account);
|
||||
break;
|
||||
case R.id.edit_prefs:
|
||||
onEditPrefs();
|
||||
break;
|
||||
case R.id.delete_account:
|
||||
onDeleteAccount(account);
|
||||
break;
|
||||
case R.id.edit_account:
|
||||
onEditAccount(account);
|
||||
break;
|
||||
case R.id.open:
|
||||
onOpenAccount(account);
|
||||
break;
|
||||
case R.id.check_mail:
|
||||
onCheckMail(account);
|
||||
break;
|
||||
case R.id.clear_pending:
|
||||
onClearCommands(account);
|
||||
break;
|
||||
case R.id.empty_trash:
|
||||
onEmptyTrash(account);
|
||||
break;
|
||||
case R.id.compact:
|
||||
onCompact(account);
|
||||
break;
|
||||
case R.id.clear:
|
||||
onClear(account);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void onCompact(Account account) {
|
||||
mHandler.workingAccount(account, R.string.compacting_account);
|
||||
MessagingController.getInstance(getApplication()).compact(account, null);
|
||||
mHandler.workingAccount(account, R.string.compacting_account);
|
||||
MessagingController.getInstance(getApplication()).compact(account, null);
|
||||
}
|
||||
|
||||
|
||||
private void onClear(Account account) {
|
||||
mHandler.workingAccount(account, R.string.clearing_account);
|
||||
MessagingController.getInstance(getApplication()).clear(account, null);
|
||||
mHandler.workingAccount(account, R.string.clearing_account);
|
||||
MessagingController.getInstance(getApplication()).clear(account, null);
|
||||
}
|
||||
|
||||
|
||||
@ -491,48 +468,48 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.add_new_account:
|
||||
onAddNewAccount();
|
||||
break;
|
||||
case R.id.edit_prefs:
|
||||
onEditPrefs();
|
||||
break;
|
||||
case R.id.check_mail:
|
||||
onCheckMail(null);
|
||||
break;
|
||||
case R.id.compose:
|
||||
onCompose();
|
||||
break;
|
||||
case R.id.about:
|
||||
onAbout();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
case R.id.add_new_account:
|
||||
onAddNewAccount();
|
||||
break;
|
||||
case R.id.edit_prefs:
|
||||
onEditPrefs();
|
||||
break;
|
||||
case R.id.check_mail:
|
||||
onCheckMail(null);
|
||||
break;
|
||||
case R.id.compose:
|
||||
onCompose();
|
||||
break;
|
||||
case R.id.about:
|
||||
onAbout();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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)
|
||||
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();
|
||||
}
|
||||
public void onClick(DialogInterface d, int c) {
|
||||
d.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
@ -543,17 +520,17 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
* @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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -575,21 +552,20 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class AccountsAdapter extends ArrayAdapter<Account> {
|
||||
public AccountsAdapter(Account[] accounts) {
|
||||
super(Accounts.this, 0, accounts);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Account account = getItem(position);
|
||||
View view;
|
||||
if (convertView != null) {
|
||||
view = convertView;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
view = getLayoutInflater().inflate(R.layout.accounts_item, parent, false);
|
||||
}
|
||||
AccountViewHolder holder = (AccountViewHolder) view.getTag();
|
||||
@ -608,14 +584,13 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
|
||||
Integer unreadMessageCount = unreadMessageCounts.get(account.getUuid());
|
||||
if (unreadMessageCount != null) {
|
||||
holder.newMessageCount.setText(Integer.toString(unreadMessageCount));
|
||||
holder.newMessageCount.setVisibility(unreadMessageCount > 0 ? View.VISIBLE : View.GONE);
|
||||
holder.newMessageCount.setText(Integer.toString(unreadMessageCount));
|
||||
holder.newMessageCount.setVisibility(unreadMessageCount > 0 ? View.VISIBLE : View.GONE);
|
||||
} else {
|
||||
//holder.newMessageCount.setText("-");
|
||||
holder.newMessageCount.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
//holder.newMessageCount.setText("-");
|
||||
holder.newMessageCount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -27,261 +27,225 @@ import com.android.email.R;
|
||||
import com.android.email.mail.Folder;
|
||||
import com.android.email.mail.MessagingException;
|
||||
|
||||
public class ChooseFolder extends K9ListActivity
|
||||
{
|
||||
String mFolder;
|
||||
Account mAccount;
|
||||
String mUID;
|
||||
ArrayAdapter<String> adapter;
|
||||
private ChooseFolderHandler mHandler = new ChooseFolderHandler();
|
||||
String heldInbox = null;
|
||||
boolean hideCurrentFolder = true;
|
||||
boolean showOptionNone = false;
|
||||
boolean showDisplayableOnly = false;
|
||||
public class ChooseFolder extends K9ListActivity {
|
||||
String mFolder;
|
||||
Account mAccount;
|
||||
String mUID;
|
||||
ArrayAdapter<String> adapter;
|
||||
private ChooseFolderHandler mHandler = new ChooseFolderHandler();
|
||||
String heldInbox = null;
|
||||
boolean hideCurrentFolder = true;
|
||||
boolean showOptionNone = false;
|
||||
boolean showDisplayableOnly = false;
|
||||
|
||||
public static final String EXTRA_ACCOUNT = "com.android.email.ChooseFolder_account";
|
||||
public static final String EXTRA_CUR_FOLDER = "com.android.email.ChooseFolder_curfolder";
|
||||
public static final String EXTRA_NEW_FOLDER = "com.android.email.ChooseFolder_newfolder";
|
||||
public static final String EXTRA_MESSAGE_UID = "com.android.email.ChooseFolder_messageuid";
|
||||
public static final String EXTRA_SHOW_CURRENT = "com.android.email.ChooseFolder_showcurrent";
|
||||
public static final String EXTRA_SHOW_FOLDER_NONE = "com.android.email.ChooseFolder_showOptionNone";
|
||||
public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = "com.android.email.ChooseFolder_showDisplayableOnly";
|
||||
public static final String EXTRA_ACCOUNT = "com.android.email.ChooseFolder_account";
|
||||
public static final String EXTRA_CUR_FOLDER = "com.android.email.ChooseFolder_curfolder";
|
||||
public static final String EXTRA_NEW_FOLDER = "com.android.email.ChooseFolder_newfolder";
|
||||
public static final String EXTRA_MESSAGE_UID = "com.android.email.ChooseFolder_messageuid";
|
||||
public static final String EXTRA_SHOW_CURRENT = "com.android.email.ChooseFolder_showcurrent";
|
||||
public static final String EXTRA_SHOW_FOLDER_NONE = "com.android.email.ChooseFolder_showOptionNone";
|
||||
public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = "com.android.email.ChooseFolder_showDisplayableOnly";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
getListView().setFastScrollEnabled(true);
|
||||
getListView().setTextFilterEnabled(true);
|
||||
getListView().setItemsCanFocus(false);
|
||||
getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
Intent intent = getIntent();
|
||||
mAccount = (Account) intent.getSerializableExtra(EXTRA_ACCOUNT);
|
||||
mUID = intent.getStringExtra(EXTRA_MESSAGE_UID);
|
||||
mFolder = intent.getStringExtra(EXTRA_CUR_FOLDER);
|
||||
if (intent.getStringExtra(EXTRA_SHOW_CURRENT) != null) {
|
||||
hideCurrentFolder = false;
|
||||
}
|
||||
if (intent.getStringExtra(EXTRA_SHOW_FOLDER_NONE) != null) {
|
||||
showOptionNone = true;
|
||||
}
|
||||
if (intent.getStringExtra(EXTRA_SHOW_DISPLAYABLE_ONLY) != null) {
|
||||
showDisplayableOnly = true;
|
||||
}
|
||||
if(mFolder == null)
|
||||
mFolder = "";
|
||||
|
||||
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
|
||||
|
||||
setListAdapter(adapter);
|
||||
|
||||
|
||||
MessagingController.getInstance(getApplication()).listFolders(mAccount,
|
||||
false, mListener);
|
||||
|
||||
|
||||
this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView adapterview, View view, int i, long l)
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_CUR_FOLDER, mFolder);
|
||||
String destFolderName = (String)((TextView)view).getText();
|
||||
if (heldInbox != null && getString(R.string.special_mailbox_name_inbox).equals(destFolderName))
|
||||
{
|
||||
destFolderName = heldInbox;
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
getListView().setFastScrollEnabled(true);
|
||||
getListView().setTextFilterEnabled(true);
|
||||
getListView().setItemsCanFocus(false);
|
||||
getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
Intent intent = getIntent();
|
||||
mAccount = (Account) intent.getSerializableExtra(EXTRA_ACCOUNT);
|
||||
mUID = intent.getStringExtra(EXTRA_MESSAGE_UID);
|
||||
mFolder = intent.getStringExtra(EXTRA_CUR_FOLDER);
|
||||
if (intent.getStringExtra(EXTRA_SHOW_CURRENT) != null) {
|
||||
hideCurrentFolder = false;
|
||||
}
|
||||
intent.putExtra(EXTRA_NEW_FOLDER, destFolderName);
|
||||
intent.putExtra(EXTRA_MESSAGE_UID, mUID);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
if (intent.getStringExtra(EXTRA_SHOW_FOLDER_NONE) != null) {
|
||||
showOptionNone = true;
|
||||
}
|
||||
if (intent.getStringExtra(EXTRA_SHOW_DISPLAYABLE_ONLY) != null) {
|
||||
showDisplayableOnly = true;
|
||||
}
|
||||
if (mFolder == null)
|
||||
mFolder = "";
|
||||
|
||||
}
|
||||
|
||||
class ChooseFolderHandler extends Handler
|
||||
{
|
||||
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
|
||||
|
||||
private static final int MSG_PROGRESS = 2;
|
||||
setListAdapter(adapter);
|
||||
|
||||
private static final int MSG_DATA_CHANGED = 3;
|
||||
private static final int MSG_SET_SELECTED_FOLDER = 4;
|
||||
|
||||
public void handleMessage(android.os.Message msg)
|
||||
{
|
||||
switch (msg.what)
|
||||
{
|
||||
case MSG_PROGRESS:
|
||||
setProgressBarIndeterminateVisibility(msg.arg1 != 0);
|
||||
break;
|
||||
case MSG_DATA_CHANGED:
|
||||
adapter.notifyDataSetChanged();
|
||||
break;
|
||||
case MSG_SET_SELECTED_FOLDER:
|
||||
// TODO: I want this to highlight the chosen folder, but this doesn't work.
|
||||
MessagingController.getInstance(getApplication()).listFolders(mAccount,
|
||||
false, mListener);
|
||||
|
||||
|
||||
this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView adapterview, View view, int i, long l) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_CUR_FOLDER, mFolder);
|
||||
String destFolderName = (String)((TextView)view).getText();
|
||||
if (heldInbox != null && getString(R.string.special_mailbox_name_inbox).equals(destFolderName)) {
|
||||
destFolderName = heldInbox;
|
||||
}
|
||||
intent.putExtra(EXTRA_NEW_FOLDER, destFolderName);
|
||||
intent.putExtra(EXTRA_MESSAGE_UID, mUID);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
class ChooseFolderHandler extends Handler {
|
||||
|
||||
private static final int MSG_PROGRESS = 2;
|
||||
|
||||
private static final int MSG_DATA_CHANGED = 3;
|
||||
private static final int MSG_SET_SELECTED_FOLDER = 4;
|
||||
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_PROGRESS:
|
||||
setProgressBarIndeterminateVisibility(msg.arg1 != 0);
|
||||
break;
|
||||
case MSG_DATA_CHANGED:
|
||||
adapter.notifyDataSetChanged();
|
||||
break;
|
||||
case MSG_SET_SELECTED_FOLDER:
|
||||
// TODO: I want this to highlight the chosen folder, but this doesn't work.
|
||||
// getListView().setSelection(msg.arg1);
|
||||
// getListView().setItemChecked(msg.arg1, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void progress(boolean progress)
|
||||
{
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_PROGRESS;
|
||||
msg.arg1 = progress ? 1 : 0;
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void setSelectedFolder(int position)
|
||||
{
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_SET_SELECTED_FOLDER;
|
||||
msg.arg1 = position;
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void dataChanged()
|
||||
{
|
||||
sendEmptyMessage(MSG_DATA_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
private MessagingListener mListener = new MessagingListener()
|
||||
{
|
||||
public void listFoldersStarted(Account account)
|
||||
{
|
||||
if (!account.equals(mAccount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
mHandler.progress(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listFoldersFailed(Account account, String message)
|
||||
{
|
||||
if (!account.equals(mAccount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
mHandler.progress(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listFoldersFinished(Account account)
|
||||
{
|
||||
if (!account.equals(mAccount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
mHandler.progress(false);
|
||||
}
|
||||
@Override
|
||||
public void listFolders(Account account, Folder[] folders)
|
||||
{
|
||||
if (!account.equals(mAccount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Account.FolderMode aMode = Account.FolderMode.ALL;
|
||||
if (showDisplayableOnly)
|
||||
{
|
||||
aMode = account.getFolderDisplayMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
aMode = account.getFolderTargetMode();
|
||||
}
|
||||
Preferences prefs = Preferences.getPreferences(getApplication().getApplicationContext());
|
||||
ArrayList<String> localFolders = new ArrayList<String>();
|
||||
|
||||
for (Folder folder : folders)
|
||||
{
|
||||
String name = folder.getName();
|
||||
|
||||
// Inbox needs to be compared case-insensitively
|
||||
if(hideCurrentFolder && (name.equals(mFolder) || (Email.INBOX.equalsIgnoreCase(mFolder) && Email.INBOX.equalsIgnoreCase(name)))) {
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
folder.refresh(prefs);
|
||||
Folder.FolderClass fMode = folder.getDisplayClass();
|
||||
|
||||
if ((aMode == Account.FolderMode.FIRST_CLASS && fMode != Folder.FolderClass.FIRST_CLASS)
|
||||
|| (aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS &&
|
||||
fMode != Folder.FolderClass.FIRST_CLASS &&
|
||||
fMode != Folder.FolderClass.SECOND_CLASS)
|
||||
|| (aMode == Account.FolderMode.NOT_SECOND_CLASS && fMode == Folder.FolderClass.SECOND_CLASS))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
public void progress(boolean progress) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_PROGRESS;
|
||||
msg.arg1 = progress ? 1 : 0;
|
||||
sendMessage(msg);
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
Log.e(Email.LOG_TAG, "Couldn't get prefs to check for displayability of folder " + folder.getName(), me);
|
||||
}
|
||||
|
||||
localFolders.add(folder.getName());
|
||||
|
||||
}
|
||||
|
||||
if (showOptionNone)
|
||||
{
|
||||
localFolders.add(Email.FOLDER_NONE);
|
||||
}
|
||||
|
||||
Collections.sort(localFolders, new Comparator<String>() {
|
||||
public int compare(String aName, String bName)
|
||||
{
|
||||
if (Email.FOLDER_NONE.equalsIgnoreCase(aName))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (Email.FOLDER_NONE.equalsIgnoreCase(bName))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (Email.INBOX.equalsIgnoreCase(aName))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (Email.INBOX.equalsIgnoreCase(bName))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return aName.compareToIgnoreCase(bName);
|
||||
public void setSelectedFolder(int position) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_SET_SELECTED_FOLDER;
|
||||
msg.arg1 = position;
|
||||
sendMessage(msg);
|
||||
}
|
||||
});
|
||||
adapter.setNotifyOnChange(false);
|
||||
adapter.clear();
|
||||
int selectedFolder = -1;
|
||||
int position = 0;
|
||||
for (String name : localFolders) {
|
||||
if (Email.INBOX.equalsIgnoreCase(name))
|
||||
{
|
||||
adapter.add(getString(R.string.special_mailbox_name_inbox));
|
||||
heldInbox = name;
|
||||
|
||||
public void dataChanged() {
|
||||
sendEmptyMessage(MSG_DATA_CHANGED);
|
||||
}
|
||||
else {
|
||||
adapter.add(name);
|
||||
}
|
||||
|
||||
if((name.equals(mFolder) || (Email.INBOX.equalsIgnoreCase(mFolder) && Email.INBOX.equalsIgnoreCase(name)))) {
|
||||
selectedFolder = position;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
if (selectedFolder != -1)
|
||||
{
|
||||
mHandler.setSelectedFolder(selectedFolder);
|
||||
}
|
||||
mHandler.dataChanged();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private MessagingListener mListener = new MessagingListener() {
|
||||
public void listFoldersStarted(Account account) {
|
||||
if (!account.equals(mAccount)) {
|
||||
return;
|
||||
}
|
||||
mHandler.progress(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listFoldersFailed(Account account, String message) {
|
||||
if (!account.equals(mAccount)) {
|
||||
return;
|
||||
}
|
||||
mHandler.progress(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listFoldersFinished(Account account) {
|
||||
if (!account.equals(mAccount)) {
|
||||
return;
|
||||
}
|
||||
mHandler.progress(false);
|
||||
}
|
||||
@Override
|
||||
public void listFolders(Account account, Folder[] folders) {
|
||||
if (!account.equals(mAccount)) {
|
||||
return;
|
||||
}
|
||||
Account.FolderMode aMode = Account.FolderMode.ALL;
|
||||
if (showDisplayableOnly) {
|
||||
aMode = account.getFolderDisplayMode();
|
||||
} else {
|
||||
aMode = account.getFolderTargetMode();
|
||||
}
|
||||
Preferences prefs = Preferences.getPreferences(getApplication().getApplicationContext());
|
||||
ArrayList<String> localFolders = new ArrayList<String>();
|
||||
|
||||
for (Folder folder : folders) {
|
||||
String name = folder.getName();
|
||||
|
||||
// Inbox needs to be compared case-insensitively
|
||||
if (hideCurrentFolder && (name.equals(mFolder) || (Email.INBOX.equalsIgnoreCase(mFolder) && Email.INBOX.equalsIgnoreCase(name)))) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
folder.refresh(prefs);
|
||||
Folder.FolderClass fMode = folder.getDisplayClass();
|
||||
|
||||
if ((aMode == Account.FolderMode.FIRST_CLASS && fMode != Folder.FolderClass.FIRST_CLASS)
|
||||
|| (aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS &&
|
||||
fMode != Folder.FolderClass.FIRST_CLASS &&
|
||||
fMode != Folder.FolderClass.SECOND_CLASS)
|
||||
|| (aMode == Account.FolderMode.NOT_SECOND_CLASS && fMode == Folder.FolderClass.SECOND_CLASS)) {
|
||||
continue;
|
||||
}
|
||||
} catch (MessagingException me) {
|
||||
Log.e(Email.LOG_TAG, "Couldn't get prefs to check for displayability of folder " + folder.getName(), me);
|
||||
}
|
||||
|
||||
localFolders.add(folder.getName());
|
||||
|
||||
}
|
||||
|
||||
if (showOptionNone) {
|
||||
localFolders.add(Email.FOLDER_NONE);
|
||||
}
|
||||
|
||||
Collections.sort(localFolders, new Comparator<String>() {
|
||||
public int compare(String aName, String bName) {
|
||||
if (Email.FOLDER_NONE.equalsIgnoreCase(aName)) {
|
||||
return -1;
|
||||
}
|
||||
if (Email.FOLDER_NONE.equalsIgnoreCase(bName)) {
|
||||
return 1;
|
||||
}
|
||||
if (Email.INBOX.equalsIgnoreCase(aName)) {
|
||||
return -1;
|
||||
}
|
||||
if (Email.INBOX.equalsIgnoreCase(bName)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return aName.compareToIgnoreCase(bName);
|
||||
}
|
||||
});
|
||||
adapter.setNotifyOnChange(false);
|
||||
adapter.clear();
|
||||
int selectedFolder = -1;
|
||||
int position = 0;
|
||||
for (String name : localFolders) {
|
||||
if (Email.INBOX.equalsIgnoreCase(name)) {
|
||||
adapter.add(getString(R.string.special_mailbox_name_inbox));
|
||||
heldInbox = name;
|
||||
} else {
|
||||
adapter.add(name);
|
||||
}
|
||||
|
||||
if ((name.equals(mFolder) || (Email.INBOX.equalsIgnoreCase(mFolder) && Email.INBOX.equalsIgnoreCase(name)))) {
|
||||
selectedFolder = position;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
if (selectedFolder != -1) {
|
||||
mHandler.setSelectedFolder(selectedFolder);
|
||||
}
|
||||
mHandler.dataChanged();
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -19,10 +19,9 @@ import com.android.email.K9ListActivity;
|
||||
import com.android.email.Preferences;
|
||||
import com.android.email.R;
|
||||
|
||||
public class ChooseIdentity extends K9ListActivity
|
||||
{
|
||||
public class ChooseIdentity extends K9ListActivity {
|
||||
Account mAccount;
|
||||
String mUID;
|
||||
String mUID;
|
||||
ArrayAdapter<String> adapter;
|
||||
private ChooseIdentityHandler mHandler = new ChooseIdentityHandler();
|
||||
|
||||
@ -32,8 +31,7 @@ public class ChooseIdentity extends K9ListActivity
|
||||
protected List<Account.Identity> identities = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
@ -52,86 +50,71 @@ public class ChooseIdentity extends K9ListActivity
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
refreshView();
|
||||
}
|
||||
|
||||
|
||||
protected void refreshView()
|
||||
{
|
||||
protected void refreshView() {
|
||||
adapter.clear();
|
||||
|
||||
identities = mAccount.getIdentities();
|
||||
for (Account.Identity identity : identities)
|
||||
{
|
||||
for (Account.Identity identity : identities) {
|
||||
String email = identity.getEmail();
|
||||
String description = identity.getDescription();
|
||||
if (description == null || description.trim().length() == 0)
|
||||
{
|
||||
description = getString(R.string.message_view_from_format, identity.getName(), identity.getEmail());
|
||||
if (description == null || description.trim().length() == 0) {
|
||||
description = getString(R.string.message_view_from_format, identity.getName(), identity.getEmail());
|
||||
}
|
||||
adapter.add(description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void setupClickListeners()
|
||||
{
|
||||
this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener()
|
||||
{
|
||||
public void onItemClick(AdapterView adapterview, View view, int i, long l)
|
||||
{
|
||||
protected void setupClickListeners() {
|
||||
this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView adapterview, View view, int i, long l) {
|
||||
Account.Identity identity = mAccount.getIdentity(i);
|
||||
String email = identity.getEmail();
|
||||
if (email != null && email.trim().equals("") == false)
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
|
||||
intent.putExtra(EXTRA_IDENTITY, mAccount.getIdentity(i));
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (email != null && email.trim().equals("") == false) {
|
||||
Intent intent = new Intent();
|
||||
|
||||
intent.putExtra(EXTRA_IDENTITY, mAccount.getIdentity(i));
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(ChooseIdentity.this, getString(R.string.identity_has_no_email),
|
||||
Toast.LENGTH_LONG).show();
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
class ChooseIdentityHandler extends Handler
|
||||
{
|
||||
class ChooseIdentityHandler extends Handler {
|
||||
|
||||
private static final int MSG_PROGRESS = 2;
|
||||
private static final int MSG_DATA_CHANGED = 3;
|
||||
|
||||
public void handleMessage(android.os.Message msg)
|
||||
{
|
||||
switch (msg.what)
|
||||
{
|
||||
case MSG_PROGRESS:
|
||||
setProgressBarIndeterminateVisibility(msg.arg1 != 0);
|
||||
break;
|
||||
case MSG_DATA_CHANGED:
|
||||
adapter.notifyDataSetChanged();
|
||||
break;
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_PROGRESS:
|
||||
setProgressBarIndeterminateVisibility(msg.arg1 != 0);
|
||||
break;
|
||||
case MSG_DATA_CHANGED:
|
||||
adapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void progress(boolean progress)
|
||||
{
|
||||
public void progress(boolean progress) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = MSG_PROGRESS;
|
||||
msg.arg1 = progress ? 1 : 0;
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void dataChanged()
|
||||
{
|
||||
public void dataChanged() {
|
||||
sendEmptyMessage(MSG_DATA_CHANGED);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class EditIdentity extends K9Activity
|
||||
{
|
||||
public class EditIdentity extends K9Activity {
|
||||
|
||||
public static final String EXTRA_IDENTITY = "com.android.email.EditIdentity_identity";
|
||||
public static final String EXTRA_IDENTITY_INDEX = "com.android.email.EditIdentity_identity_index";
|
||||
@ -30,16 +29,14 @@ public class EditIdentity extends K9Activity
|
||||
private EditText mNameView;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mIdentity = (Account.Identity)getIntent().getSerializableExtra(EXTRA_IDENTITY);
|
||||
mIdentityIndex = getIntent().getIntExtra(EXTRA_IDENTITY_INDEX, -1);
|
||||
mAccount = (Account) getIntent().getSerializableExtra(EXTRA_ACCOUNT);
|
||||
|
||||
if (mIdentityIndex == -1)
|
||||
{
|
||||
if (mIdentityIndex == -1) {
|
||||
mIdentity = mAccount.new Identity();
|
||||
}
|
||||
|
||||
@ -49,8 +46,7 @@ public class EditIdentity extends K9Activity
|
||||
* If we're being reloaded we override the original account with the one
|
||||
* we saved
|
||||
*/
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_IDENTITY))
|
||||
{
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_IDENTITY)) {
|
||||
mIdentity = (Account.Identity)savedInstanceState.getSerializable(EXTRA_IDENTITY);
|
||||
}
|
||||
|
||||
@ -71,13 +67,11 @@ public class EditIdentity extends K9Activity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
private void saveIdentity()
|
||||
{
|
||||
private void saveIdentity() {
|
||||
|
||||
mIdentity.setDescription(mDescriptionView.getText().toString());
|
||||
mIdentity.setEmail(mEmailView.getText().toString());
|
||||
@ -86,12 +80,9 @@ public class EditIdentity extends K9Activity
|
||||
mIdentity.setSignature(mSignatureView.getText().toString());
|
||||
|
||||
List<Account.Identity> identities = mAccount.getIdentities();
|
||||
if (mIdentityIndex == -1)
|
||||
{
|
||||
if (mIdentityIndex == -1) {
|
||||
identities.add(mIdentity);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
identities.remove(mIdentityIndex);
|
||||
identities.add(mIdentityIndex, mIdentity);
|
||||
}
|
||||
@ -102,10 +93,8 @@ public class EditIdentity extends K9Activity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK)
|
||||
{
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
saveIdentity();
|
||||
return true;
|
||||
}
|
||||
@ -113,8 +102,7 @@ public class EditIdentity extends K9Activity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState)
|
||||
{
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putSerializable(EXTRA_IDENTITY, mIdentity);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,18 +16,14 @@ import com.android.email.Account;
|
||||
import com.android.email.Preferences;
|
||||
import com.android.email.R;
|
||||
|
||||
public class ManageIdentities extends ChooseIdentity
|
||||
{
|
||||
public class ManageIdentities extends ChooseIdentity {
|
||||
private boolean mIdentitiesChanged = false;
|
||||
public static final String EXTRA_IDENTITIES = "com.android.email.EditIdentity_identities";
|
||||
|
||||
private static final int ACTIVITY_EDIT_IDENTITY = 1;
|
||||
protected void setupClickListeners()
|
||||
{
|
||||
this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener()
|
||||
{
|
||||
public void onItemClick(AdapterView adapterview, View view, int i, long l)
|
||||
{
|
||||
protected void setupClickListeners() {
|
||||
this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView adapterview, View view, int i, long l) {
|
||||
editItem(i);
|
||||
}
|
||||
});
|
||||
@ -36,8 +32,7 @@ public class ManageIdentities extends ChooseIdentity
|
||||
registerForContextMenu(listView);
|
||||
}
|
||||
|
||||
private void editItem(int i)
|
||||
{
|
||||
private void editItem(int i) {
|
||||
Intent intent = new Intent(ManageIdentities.this, EditIdentity.class);
|
||||
|
||||
intent.putExtra(EditIdentity.EXTRA_ACCOUNT, mAccount);
|
||||
@ -47,92 +42,80 @@ public class ManageIdentities extends ChooseIdentity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
getMenuInflater().inflate(R.menu.manage_identities_option, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
switch (item.getItemId())
|
||||
{
|
||||
case R.id.new_identity:
|
||||
Intent intent = new Intent(ManageIdentities.this, EditIdentity.class);
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.new_identity:
|
||||
Intent intent = new Intent(ManageIdentities.this, EditIdentity.class);
|
||||
|
||||
intent.putExtra(EditIdentity.EXTRA_ACCOUNT, mAccount);
|
||||
startActivityForResult(intent, ACTIVITY_EDIT_IDENTITY);
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
intent.putExtra(EditIdentity.EXTRA_ACCOUNT, mAccount);
|
||||
startActivityForResult(intent, ACTIVITY_EDIT_IDENTITY);
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
|
||||
{
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
menu.setHeaderTitle(R.string.manage_identities_context_menu_title);
|
||||
getMenuInflater().inflate(R.menu.manage_identities_context, menu);
|
||||
}
|
||||
|
||||
public boolean onContextItemSelected(MenuItem item)
|
||||
{
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)item.getMenuInfo();
|
||||
switch (item.getItemId())
|
||||
{
|
||||
case R.id.edit:
|
||||
editItem(menuInfo.position);
|
||||
break;
|
||||
case R.id.up:
|
||||
if (menuInfo.position > 0)
|
||||
{
|
||||
Account.Identity identity = identities.remove(menuInfo.position);
|
||||
identities.add(menuInfo.position - 1, identity);
|
||||
mIdentitiesChanged = true;
|
||||
refreshView();
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.down:
|
||||
if (menuInfo.position < identities.size() - 1)
|
||||
{
|
||||
Account.Identity identity = identities.remove(menuInfo.position);
|
||||
identities.add(menuInfo.position + 1, identity);
|
||||
mIdentitiesChanged = true;
|
||||
refreshView();
|
||||
}
|
||||
break;
|
||||
case R.id.top:
|
||||
switch (item.getItemId()) {
|
||||
case R.id.edit:
|
||||
editItem(menuInfo.position);
|
||||
break;
|
||||
case R.id.up:
|
||||
if (menuInfo.position > 0) {
|
||||
Account.Identity identity = identities.remove(menuInfo.position);
|
||||
identities.add(0, identity);
|
||||
identities.add(menuInfo.position - 1, identity);
|
||||
mIdentitiesChanged = true;
|
||||
refreshView();
|
||||
break;
|
||||
case R.id.remove:
|
||||
if (identities.size() > 1)
|
||||
{
|
||||
identities.remove(menuInfo.position);
|
||||
mIdentitiesChanged = true;
|
||||
refreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(this, getString(R.string.no_removable_identity),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.down:
|
||||
if (menuInfo.position < identities.size() - 1) {
|
||||
Account.Identity identity = identities.remove(menuInfo.position);
|
||||
identities.add(menuInfo.position + 1, identity);
|
||||
mIdentitiesChanged = true;
|
||||
refreshView();
|
||||
}
|
||||
break;
|
||||
case R.id.top:
|
||||
Account.Identity identity = identities.remove(menuInfo.position);
|
||||
identities.add(0, identity);
|
||||
mIdentitiesChanged = true;
|
||||
refreshView();
|
||||
break;
|
||||
case R.id.remove:
|
||||
if (identities.size() > 1) {
|
||||
identities.remove(menuInfo.position);
|
||||
mIdentitiesChanged = true;
|
||||
refreshView();
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.no_removable_identity),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mAccount.refresh(Preferences.getPreferences(getApplication().getApplicationContext()));
|
||||
refreshView();
|
||||
@ -140,19 +123,15 @@ public class ManageIdentities extends ChooseIdentity
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK)
|
||||
{
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
saveIdentities();
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private void saveIdentities()
|
||||
{
|
||||
if (mIdentitiesChanged)
|
||||
{
|
||||
private void saveIdentities() {
|
||||
if (mIdentitiesChanged) {
|
||||
mAccount.setIdentities(identities);
|
||||
mAccount.save(Preferences.getPreferences(getApplication().getApplicationContext()));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@ public interface ProgressListener {
|
||||
* @param indeterminate
|
||||
*/
|
||||
void showProgress(Context context, String title, String message, long currentProgress,
|
||||
long maxProgress, boolean indeterminate);
|
||||
long maxProgress, boolean indeterminate);
|
||||
|
||||
/**
|
||||
* @param context
|
||||
@ -27,7 +27,7 @@ public interface ProgressListener {
|
||||
* @param indeterminate
|
||||
*/
|
||||
void updateProgress(Context context, String title, String message, long currentProgress,
|
||||
long maxProgress, boolean indeterminate);
|
||||
long maxProgress, boolean indeterminate);
|
||||
|
||||
/**
|
||||
* @param context
|
||||
|
@ -4,23 +4,18 @@ import android.content.Context;
|
||||
|
||||
import com.android.email.R;
|
||||
|
||||
public class SizeFormatter
|
||||
{
|
||||
public static String formatSize(Context context, long size)
|
||||
{
|
||||
if (size > 1024000000)
|
||||
{
|
||||
return ((float)(size / 102400000) / 10) + context.getString(R.string.abbrev_gigabytes);
|
||||
public class SizeFormatter {
|
||||
public static String formatSize(Context context, long size) {
|
||||
if (size > 1024000000) {
|
||||
return ((float)(size / 102400000) / 10) + context.getString(R.string.abbrev_gigabytes);
|
||||
}
|
||||
if (size > 1024000) {
|
||||
return ((float)(size / 102400) / 10) + context.getString(R.string.abbrev_megabytes);
|
||||
}
|
||||
if (size > 1024) {
|
||||
return ((float)(size / 102) / 10) + context.getString(R.string.abbrev_kilobytes);
|
||||
}
|
||||
return size + context.getString(R.string.abbrev_bytes);
|
||||
}
|
||||
if (size > 1024000)
|
||||
{
|
||||
return ((float)(size / 102400) / 10) + context.getString(R.string.abbrev_megabytes);
|
||||
}
|
||||
if (size > 1024)
|
||||
{
|
||||
return ((float)(size / 102) / 10) + context.getString(R.string.abbrev_kilobytes);
|
||||
}
|
||||
return size + context.getString(R.string.abbrev_bytes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import com.android.email.mail.Store;
|
||||
|
||||
public class AccountSettings extends K9PreferenceActivity {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
|
||||
|
||||
private static final int SELECT_AUTO_EXPAND_FOLDER = 1;
|
||||
|
||||
private static final int ACTIVITY_MANAGE_IDENTITIES = 2;
|
||||
@ -88,16 +88,13 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
|
||||
boolean isPushCapable = false;
|
||||
Store store = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
store = Store.getInstance(mAccount.getStoreUri(), getApplication());
|
||||
isPushCapable = store.isPushCapable();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
Log.e(Email.LOG_TAG, "Could not get remote store", e);
|
||||
}
|
||||
|
||||
|
||||
addPreferencesFromResource(R.xml.account_settings_preferences);
|
||||
|
||||
Preference category = findPreference(PREFERENCE_TOP_CATERGORY);
|
||||
@ -128,7 +125,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mDisplayMode = (ListPreference) findPreference(PREFERENCE_DISPLAY_MODE);
|
||||
mDisplayMode.setValue(mAccount.getFolderDisplayMode().name());
|
||||
mDisplayMode.setSummary(mDisplayMode.getEntry());
|
||||
@ -141,7 +138,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mSyncMode = (ListPreference) findPreference(PREFERENCE_SYNC_MODE);
|
||||
mSyncMode.setValue(mAccount.getFolderSyncMode().name());
|
||||
mSyncMode.setSummary(mSyncMode.getEntry());
|
||||
@ -154,7 +151,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mPushMode = (ListPreference) findPreference(PREFERENCE_PUSH_MODE);
|
||||
mPushMode.setEnabled(isPushCapable);
|
||||
mPushMode.setValue(mAccount.getFolderPushMode().name());
|
||||
@ -168,7 +165,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mTargetMode = (ListPreference) findPreference(PREFERENCE_TARGET_MODE);
|
||||
mTargetMode.setValue(mAccount.getFolderTargetMode().name());
|
||||
mTargetMode.setSummary(mTargetMode.getEntry());
|
||||
@ -181,7 +178,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mDeletePolicy = (ListPreference) findPreference(PREFERENCE_DELETE_POLICY);
|
||||
mDeletePolicy.setValue("" + mAccount.getDeletePolicy());
|
||||
mDeletePolicy.setSummary(mDeletePolicy.getEntry());
|
||||
@ -207,10 +204,10 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mAccountDefault = (CheckBoxPreference) findPreference(PREFERENCE_DEFAULT);
|
||||
mAccountDefault.setChecked(
|
||||
mAccount.equals(Preferences.getPreferences(this).getDefaultAccount()));
|
||||
mAccount.equals(Preferences.getPreferences(this).getDefaultAccount()));
|
||||
|
||||
mAccountHideButtons = (ListPreference) findPreference(PREFERENCE_HIDE_BUTTONS);
|
||||
mAccountHideButtons.setValue("" + mAccount.getHideMessageViewButtons());
|
||||
@ -224,7 +221,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY);
|
||||
mAccountNotify.setChecked(mAccount.isNotifyNewMail());
|
||||
|
||||
@ -244,46 +241,46 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
mAutoExpandFolder = (Preference)findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
|
||||
|
||||
mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName()));
|
||||
|
||||
|
||||
mAutoExpandFolder.setOnPreferenceClickListener(
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onChooseAutoExpandFolder();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
findPreference(PREFERENCE_COMPOSITION).setOnPreferenceClickListener(
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onCompositionSettings();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onCompositionSettings();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findPreference(PREFERENCE_MANAGE_IDENTITIES).setOnPreferenceClickListener(
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onManageIdentities();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onManageIdentities();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findPreference(PREFERENCE_INCOMING).setOnPreferenceClickListener(
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onIncomingSettings();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onIncomingSettings();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findPreference(PREFERENCE_OUTGOING).setOnPreferenceClickListener(
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onOutgoingSettings();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
onOutgoingSettings();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -315,15 +312,15 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
Email.setServicesEnabled(this);
|
||||
// TODO: refresh folder list here
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
switch (requestCode) {
|
||||
case SELECT_AUTO_EXPAND_FOLDER:
|
||||
mAutoExpandFolder.setSummary(translateFolder(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER)));
|
||||
break;
|
||||
}
|
||||
switch (requestCode) {
|
||||
case SELECT_AUTO_EXPAND_FOLDER:
|
||||
mAutoExpandFolder.setSummary(translateFolder(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
@ -341,10 +338,10 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
}
|
||||
|
||||
private void onManageIdentities() {
|
||||
Intent intent = new Intent(this, ManageIdentities.class);
|
||||
intent.putExtra(ChooseIdentity.EXTRA_ACCOUNT, mAccount);
|
||||
startActivityForResult(intent, ACTIVITY_MANAGE_IDENTITIES);
|
||||
}
|
||||
Intent intent = new Intent(this, ManageIdentities.class);
|
||||
intent.putExtra(ChooseIdentity.EXTRA_ACCOUNT, mAccount);
|
||||
startActivityForResult(intent, ACTIVITY_MANAGE_IDENTITIES);
|
||||
}
|
||||
|
||||
private void onIncomingSettings() {
|
||||
AccountSetupIncoming.actionEditIncomingSettings(this, mAccount);
|
||||
@ -354,8 +351,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
AccountSetupOutgoing.actionEditOutgoingSettings(this, mAccount);
|
||||
}
|
||||
|
||||
public void onChooseAutoExpandFolder()
|
||||
{
|
||||
public void onChooseAutoExpandFolder() {
|
||||
Intent selectIntent = new Intent(this, ChooseFolder.class);
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount);
|
||||
|
||||
@ -363,34 +359,26 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_CURRENT, "yes");
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_FOLDER_NONE, "yes");
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_DISPLAYABLE_ONLY, "yes");
|
||||
startActivityForResult(selectIntent, SELECT_AUTO_EXPAND_FOLDER);
|
||||
|
||||
}
|
||||
|
||||
private String translateFolder(String in)
|
||||
{
|
||||
startActivityForResult(selectIntent, SELECT_AUTO_EXPAND_FOLDER);
|
||||
|
||||
if (Email.INBOX.equalsIgnoreCase(in))
|
||||
{
|
||||
return getString(R.string.special_mailbox_name_inbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
return in;
|
||||
}
|
||||
}
|
||||
|
||||
private String reverseTranslateFolder(String in)
|
||||
{
|
||||
|
||||
if (getString(R.string.special_mailbox_name_inbox).equals(in))
|
||||
{
|
||||
return Email.INBOX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return in;
|
||||
}
|
||||
private String translateFolder(String in) {
|
||||
|
||||
if (Email.INBOX.equalsIgnoreCase(in)) {
|
||||
return getString(R.string.special_mailbox_name_inbox);
|
||||
} else {
|
||||
return in;
|
||||
}
|
||||
}
|
||||
|
||||
private String reverseTranslateFolder(String in) {
|
||||
|
||||
if (getString(R.string.special_mailbox_name_inbox).equals(in)) {
|
||||
return Email.INBOX;
|
||||
} else {
|
||||
return in;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen
|
||||
} catch (Exception use) {
|
||||
failure(use);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void onImap() {
|
||||
@ -75,7 +75,7 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen
|
||||
} catch (Exception use) {
|
||||
failure(use);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void onWebDav() {
|
||||
@ -88,27 +88,26 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen
|
||||
} catch (Exception use) {
|
||||
failure(use);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.pop:
|
||||
onPop();
|
||||
break;
|
||||
case R.id.imap:
|
||||
onImap();
|
||||
break;
|
||||
case R.id.webdav:
|
||||
onWebDav();
|
||||
break;
|
||||
case R.id.pop:
|
||||
onPop();
|
||||
break;
|
||||
case R.id.imap:
|
||||
onImap();
|
||||
break;
|
||||
case R.id.webdav:
|
||||
onWebDav();
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void failure(Exception use)
|
||||
{
|
||||
private void failure(Exception use) {
|
||||
Log.e(Email.LOG_TAG, "Failure", use);
|
||||
String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
|
||||
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ import com.android.email.Utility;
|
||||
* AccountSetupAccountType activity.
|
||||
*/
|
||||
public class AccountSetupBasics extends K9Activity
|
||||
implements OnClickListener, TextWatcher {
|
||||
implements OnClickListener, TextWatcher {
|
||||
private final static String EXTRA_ACCOUNT = "com.android.email.AccountSetupBasics.account";
|
||||
private final static int DIALOG_NOTE = 1;
|
||||
private final static String STATE_KEY_PROVIDER =
|
||||
@ -122,9 +122,9 @@ public class AccountSetupBasics extends K9Activity
|
||||
private void validateFields() {
|
||||
String email = mEmailView.getText().toString();
|
||||
boolean valid = Utility.requiredFieldValid(mEmailView)
|
||||
&& Utility.requiredFieldValid(mPasswordView)
|
||||
&& mEmailValidator.isValid(email);
|
||||
/*&& email.contains("@"); */ // Not sure if this is a good idea or not
|
||||
&& Utility.requiredFieldValid(mPasswordView)
|
||||
&& mEmailValidator.isValid(email);
|
||||
/*&& email.contains("@"); */ // Not sure if this is a good idea or not
|
||||
mNextButton.setEnabled(valid);
|
||||
mManualSetupButton.setEnabled(valid);
|
||||
/*
|
||||
@ -137,32 +137,26 @@ public class AccountSetupBasics extends K9Activity
|
||||
|
||||
private String getOwnerName() {
|
||||
String name = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
String projection[] = {
|
||||
ContactMethods.NAME
|
||||
};
|
||||
Cursor c = getContentResolver().query(
|
||||
// TODO: For Android 2.0, needs to change to ContactsContract.People...
|
||||
Uri.withAppendedPath(Contacts.People.CONTENT_URI, "owner"), projection, null, null,
|
||||
null);
|
||||
// TODO: For Android 2.0, needs to change to ContactsContract.People...
|
||||
Uri.withAppendedPath(Contacts.People.CONTENT_URI, "owner"), projection, null, null,
|
||||
null);
|
||||
if (c.getCount() > 0) {
|
||||
c.moveToFirst();
|
||||
name = c.getString(0);
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
Log.e(Email.LOG_TAG, "Could not get owner name, using default account name", e);
|
||||
}
|
||||
if (name == null || name.length() == 0) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
name = getDefaultAccountName();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
Log.e(Email.LOG_TAG, "Could not get default account name", e);
|
||||
}
|
||||
}
|
||||
@ -171,9 +165,8 @@ public class AccountSetupBasics extends K9Activity
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private String getDefaultAccountName()
|
||||
{
|
||||
|
||||
private String getDefaultAccountName() {
|
||||
String name = null;
|
||||
Account account = Preferences.getPreferences(this).getDefaultAccount();
|
||||
if (account != null) {
|
||||
@ -187,18 +180,18 @@ public class AccountSetupBasics extends K9Activity
|
||||
if (id == DIALOG_NOTE) {
|
||||
if (mProvider != null && mProvider.note != null) {
|
||||
return new AlertDialog.Builder(this)
|
||||
.setMessage(mProvider.note)
|
||||
.setPositiveButton(
|
||||
getString(R.string.okay_action),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finishAutoSetup();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(
|
||||
getString(R.string.cancel_action),
|
||||
null)
|
||||
.create();
|
||||
.setMessage(mProvider.note)
|
||||
.setPositiveButton(
|
||||
getString(R.string.okay_action),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finishAutoSetup();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(
|
||||
getString(R.string.cancel_action),
|
||||
null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -220,8 +213,8 @@ public class AccountSetupBasics extends K9Activity
|
||||
|
||||
URI incomingUriTemplate = mProvider.incomingUriTemplate;
|
||||
incomingUri = new URI(incomingUriTemplate.getScheme(), incomingUsername + ":"
|
||||
+ password, incomingUriTemplate.getHost(), incomingUriTemplate.getPort(), null,
|
||||
null, null);
|
||||
+ password, incomingUriTemplate.getHost(), incomingUriTemplate.getPort(), null,
|
||||
null, null);
|
||||
|
||||
String outgoingUsername = mProvider.outgoingUsernameTemplate;
|
||||
outgoingUsername = outgoingUsername.replaceAll("\\$email", email);
|
||||
@ -230,8 +223,8 @@ public class AccountSetupBasics extends K9Activity
|
||||
|
||||
URI outgoingUriTemplate = mProvider.outgoingUriTemplate;
|
||||
outgoingUri = new URI(outgoingUriTemplate.getScheme(), outgoingUsername + ":"
|
||||
+ password, outgoingUriTemplate.getHost(), outgoingUriTemplate.getPort(), null,
|
||||
null, null);
|
||||
+ password, outgoingUriTemplate.getHost(), outgoingUriTemplate.getPort(), null,
|
||||
null, null);
|
||||
} catch (URISyntaxException use) {
|
||||
/*
|
||||
* If there is some problem with the URI we give up and go on to
|
||||
@ -271,8 +264,7 @@ public class AccountSetupBasics extends K9Activity
|
||||
|
||||
if (mProvider.note != null) {
|
||||
showDialog(DIALOG_NOTE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
finishAutoSetup();
|
||||
}
|
||||
}
|
||||
@ -303,7 +295,7 @@ public class AccountSetupBasics extends K9Activity
|
||||
mAccount.setEmail(email);
|
||||
try {
|
||||
URI uri = new URI("placeholder", user + ":" + password, "mail." + domain, -1, null,
|
||||
null, null);
|
||||
null, null);
|
||||
mAccount.setStoreUri(uri.toString());
|
||||
mAccount.setTransportUri(uri.toString());
|
||||
} catch (URISyntaxException use) {
|
||||
@ -323,12 +315,12 @@ public class AccountSetupBasics extends K9Activity
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.next:
|
||||
onNext();
|
||||
break;
|
||||
case R.id.manual_setup:
|
||||
onManualSetup();
|
||||
break;
|
||||
case R.id.next:
|
||||
onNext();
|
||||
break;
|
||||
case R.id.manual_setup:
|
||||
onManualSetup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,8 +335,7 @@ public class AccountSetupBasics extends K9Activity
|
||||
int resId = xml.getAttributeResourceValue(null, name, 0);
|
||||
if (resId == 0) {
|
||||
return xml.getAttributeValue(null, name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return getString(resId);
|
||||
}
|
||||
}
|
||||
@ -363,34 +354,29 @@ public class AccountSetupBasics extends K9Activity
|
||||
provider.label = getXmlAttribute(xml, "label");
|
||||
provider.domain = getXmlAttribute(xml, "domain");
|
||||
provider.note = getXmlAttribute(xml, "note");
|
||||
}
|
||||
else if (xmlEventType == XmlResourceParser.START_TAG
|
||||
&& "incoming".equals(xml.getName())
|
||||
&& provider != null) {
|
||||
} else if (xmlEventType == XmlResourceParser.START_TAG
|
||||
&& "incoming".equals(xml.getName())
|
||||
&& provider != null) {
|
||||
provider.incomingUriTemplate = new URI(getXmlAttribute(xml, "uri"));
|
||||
provider.incomingUsernameTemplate = getXmlAttribute(xml, "username");
|
||||
}
|
||||
else if (xmlEventType == XmlResourceParser.START_TAG
|
||||
&& "outgoing".equals(xml.getName())
|
||||
&& provider != null) {
|
||||
} else if (xmlEventType == XmlResourceParser.START_TAG
|
||||
&& "outgoing".equals(xml.getName())
|
||||
&& provider != null) {
|
||||
provider.outgoingUriTemplate = new URI(getXmlAttribute(xml, "uri"));
|
||||
provider.outgoingUsernameTemplate = getXmlAttribute(xml, "username");
|
||||
}
|
||||
else if (xmlEventType == XmlResourceParser.END_TAG
|
||||
&& "provider".equals(xml.getName())
|
||||
&& provider != null) {
|
||||
} else if (xmlEventType == XmlResourceParser.END_TAG
|
||||
&& "provider".equals(xml.getName())
|
||||
&& provider != null) {
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
Log.e(Email.LOG_TAG, "Error while trying to load provider settings.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String[] splitEmail(String email)
|
||||
{
|
||||
|
||||
private String[] splitEmail(String email) {
|
||||
String[] retParts = new String[2];
|
||||
String[] emailParts = email.split("@");
|
||||
retParts[0] = (emailParts.length > 0 ) ? emailParts[0] : "";
|
||||
|
@ -39,9 +39,9 @@ import com.android.email.mail.store.TrustManagerFactory;
|
||||
* it doesn't correctly deal with restarting while its thread is running.
|
||||
*/
|
||||
public class AccountSetupCheckSettings extends K9Activity implements OnClickListener {
|
||||
|
||||
public static final int ACTIVITY_REQUEST_CODE = 1;
|
||||
|
||||
|
||||
public static final int ACTIVITY_REQUEST_CODE = 1;
|
||||
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
|
||||
private static final String EXTRA_CHECK_INCOMING = "checkIncoming";
|
||||
@ -65,7 +65,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
private boolean mDestroyed;
|
||||
|
||||
public static void actionCheckSettings(Activity context, Account account,
|
||||
boolean checkIncoming, boolean checkOutgoing) {
|
||||
boolean checkIncoming, boolean checkOutgoing) {
|
||||
Intent i = new Intent(context, AccountSetupCheckSettings.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account);
|
||||
i.putExtra(EXTRA_CHECK_INCOMING, checkIncoming);
|
||||
@ -90,7 +90,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
|
||||
new Thread() {
|
||||
public void run() {
|
||||
Store store = null;
|
||||
Store store = null;
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
||||
try {
|
||||
if (mDestroyed) {
|
||||
@ -101,13 +101,13 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
return;
|
||||
}
|
||||
if (mCheckIncoming) {
|
||||
setMessage(R.string.account_setup_check_settings_check_incoming_msg);
|
||||
store = Store.getInstance(mAccount.getStoreUri(), getApplication());
|
||||
store.checkSettings();
|
||||
|
||||
MessagingController.getInstance(getApplication()).listFolders(mAccount, true, null);
|
||||
setMessage(R.string.account_setup_check_settings_check_incoming_msg);
|
||||
store = Store.getInstance(mAccount.getStoreUri(), getApplication());
|
||||
store.checkSettings();
|
||||
|
||||
MessagingController.getInstance(getApplication()).listFolders(mAccount, true, null);
|
||||
MessagingController.getInstance(getApplication()).synchronizeMailbox( mAccount, Email.INBOX , null);
|
||||
|
||||
|
||||
}
|
||||
if (mDestroyed) {
|
||||
return;
|
||||
@ -133,25 +133,26 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
} catch (final AuthenticationFailedException afe) {
|
||||
Log.e(Email.LOG_TAG, "Error while testing settings", afe);
|
||||
Log.e(Email.LOG_TAG, "Error while testing settings", afe);
|
||||
showErrorDialog(
|
||||
R.string.account_setup_failed_dlg_auth_message_fmt,
|
||||
afe.getMessage() == null ? "" : afe.getMessage());
|
||||
R.string.account_setup_failed_dlg_auth_message_fmt,
|
||||
afe.getMessage() == null ? "" : afe.getMessage());
|
||||
} catch (final CertificateValidationException cve) {
|
||||
Log.e(Email.LOG_TAG, "Error while testing settings", cve);
|
||||
acceptKeyDialog(
|
||||
R.string.account_setup_failed_dlg_certificate_message_fmt,
|
||||
cve);
|
||||
Log.e(Email.LOG_TAG, "Error while testing settings", cve);
|
||||
acceptKeyDialog(
|
||||
R.string.account_setup_failed_dlg_certificate_message_fmt,
|
||||
cve);
|
||||
} catch (final Throwable t) {
|
||||
Log.e(Email.LOG_TAG, "Error while testing settings", t);
|
||||
Log.e(Email.LOG_TAG, "Error while testing settings", t);
|
||||
showErrorDialog(
|
||||
R.string.account_setup_failed_dlg_server_message_fmt,
|
||||
(t.getMessage() == null ? "" : t.getMessage()));
|
||||
|
||||
R.string.account_setup_failed_dlg_server_message_fmt,
|
||||
(t.getMessage() == null ? "" : t.getMessage()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}.start();
|
||||
}
|
||||
.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -180,27 +181,27 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
}
|
||||
mProgressBar.setIndeterminate(false);
|
||||
new AlertDialog.Builder(AccountSetupCheckSettings.this)
|
||||
.setTitle(getString(R.string.account_setup_failed_dlg_title))
|
||||
.setMessage(getString(msgResId, args))
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(
|
||||
getString(R.string.account_setup_failed_dlg_continue_action),
|
||||
.setTitle(getString(R.string.account_setup_failed_dlg_title))
|
||||
.setMessage(getString(msgResId, args))
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(
|
||||
getString(R.string.account_setup_failed_dlg_continue_action),
|
||||
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mCanceled=false;
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(
|
||||
getString(R.string.account_setup_failed_dlg_edit_details_action),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mCanceled=false;
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(
|
||||
getString(R.string.account_setup_failed_dlg_edit_details_action),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -212,78 +213,77 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
}
|
||||
final X509Certificate[] chain = TrustManagerFactory.getLastCertChain();
|
||||
String exMessage = "Unknown Error";
|
||||
|
||||
|
||||
Exception ex = ((Exception)args[0]);
|
||||
if (ex != null) {
|
||||
if (ex.getCause() != null) {
|
||||
if (ex.getCause().getCause() != null) {
|
||||
exMessage = ex.getCause().getCause().getMessage();
|
||||
|
||||
} else {
|
||||
exMessage = ex.getCause().getMessage();
|
||||
}
|
||||
} else {
|
||||
exMessage = ex.getMessage();
|
||||
}
|
||||
if (ex.getCause() != null) {
|
||||
if (ex.getCause().getCause() != null) {
|
||||
exMessage = ex.getCause().getCause().getMessage();
|
||||
|
||||
} else {
|
||||
exMessage = ex.getCause().getMessage();
|
||||
}
|
||||
} else {
|
||||
exMessage = ex.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mProgressBar.setIndeterminate(false);
|
||||
StringBuffer chainInfo = new StringBuffer(100);
|
||||
for (int i = 0; i < chain.length; i++)
|
||||
{
|
||||
// display certificate chain information
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
// display certificate chain information
|
||||
chainInfo.append("Certificate chain[" + i + "]:\n");
|
||||
chainInfo.append("Subject: " + chain[i].getSubjectDN().toString() + "\n");
|
||||
chainInfo.append("Issuer: " + chain[i].getIssuerDN().toString() + "\n");
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(AccountSetupCheckSettings.this)
|
||||
.setTitle(getString(R.string.account_setup_failed_dlg_invalid_certificate_title))
|
||||
//.setMessage(getString(R.string.account_setup_failed_dlg_invalid_certificate)
|
||||
.setMessage(getString(msgResId,exMessage)
|
||||
+ " " + chainInfo.toString()
|
||||
)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(
|
||||
getString(R.string.account_setup_failed_dlg_invalid_certificate_accept),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
String alias = mAccount.getUuid();
|
||||
if (mCheckIncoming) {
|
||||
alias = alias + ".incoming";
|
||||
}
|
||||
if (mCheckOutgoing) {
|
||||
alias = alias + ".outgoing";
|
||||
}
|
||||
TrustManagerFactory.addCertificateChain(alias, chain);
|
||||
} catch (CertificateException e) {
|
||||
showErrorDialog(
|
||||
R.string.account_setup_failed_dlg_certificate_message_fmt,
|
||||
e.getMessage() == null ? "" : e.getMessage());
|
||||
}
|
||||
AccountSetupCheckSettings.actionCheckSettings(AccountSetupCheckSettings.this, mAccount,
|
||||
mCheckIncoming, mCheckOutgoing);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(
|
||||
getString(R.string.account_setup_failed_dlg_invalid_certificate_reject),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
.setTitle(getString(R.string.account_setup_failed_dlg_invalid_certificate_title))
|
||||
//.setMessage(getString(R.string.account_setup_failed_dlg_invalid_certificate)
|
||||
.setMessage(getString(msgResId,exMessage)
|
||||
+ " " + chainInfo.toString()
|
||||
)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(
|
||||
getString(R.string.account_setup_failed_dlg_invalid_certificate_accept),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
String alias = mAccount.getUuid();
|
||||
if (mCheckIncoming) {
|
||||
alias = alias + ".incoming";
|
||||
}
|
||||
if (mCheckOutgoing) {
|
||||
alias = alias + ".outgoing";
|
||||
}
|
||||
TrustManagerFactory.addCertificateChain(alias, chain);
|
||||
} catch (CertificateException e) {
|
||||
showErrorDialog(
|
||||
R.string.account_setup_failed_dlg_certificate_message_fmt,
|
||||
e.getMessage() == null ? "" : e.getMessage());
|
||||
}
|
||||
AccountSetupCheckSettings.actionCheckSettings(AccountSetupCheckSettings.this, mAccount,
|
||||
mCheckIncoming, mCheckOutgoing);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(
|
||||
getString(R.string.account_setup_failed_dlg_invalid_certificate_reject),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onActivityResult(int reqCode, int resCode, Intent data) {
|
||||
setResult(resCode);
|
||||
finish();
|
||||
setResult(resCode);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void onCancel() {
|
||||
mCanceled = true;
|
||||
setMessage(R.string.account_setup_check_settings_canceling_msg);
|
||||
@ -291,9 +291,9 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.cancel:
|
||||
onCancel();
|
||||
break;
|
||||
case R.id.cancel:
|
||||
onCancel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class AccountSetupComposition extends K9Activity {
|
||||
private EditText mAccountName;
|
||||
private RadioButton mAccountSignatureBeforeLocation;
|
||||
private RadioButton mAccountSignatureAfterLocation;
|
||||
|
||||
|
||||
|
||||
public static void actionEditCompositionSettings(Activity context, Account account) {
|
||||
Intent i = new Intent(context, AccountSetupComposition.class);
|
||||
@ -53,7 +53,7 @@ public class AccountSetupComposition extends K9Activity {
|
||||
|
||||
mAccountName = (EditText)findViewById(R.id.account_name);
|
||||
mAccountName.setText(mAccount.getName());
|
||||
|
||||
|
||||
mAccountEmail = (EditText)findViewById(R.id.account_email);
|
||||
mAccountEmail.setText(mAccount.getEmail());
|
||||
|
||||
@ -78,7 +78,7 @@ public class AccountSetupComposition extends K9Activity {
|
||||
|
||||
private void saveSettings() {
|
||||
mAccount.setEmail(mAccountEmail.getText().toString());
|
||||
mAccount.setAlwaysBcc(mAccountAlwaysBcc.getText().toString());
|
||||
mAccount.setAlwaysBcc(mAccountAlwaysBcc.getText().toString());
|
||||
mAccount.setName(mAccountName.getText().toString());
|
||||
mAccount.setSignature(mAccountSignature.getText().toString());
|
||||
boolean isSignatureBeforeQuotedText = mAccountSignatureBeforeLocation.isChecked();
|
||||
@ -103,7 +103,7 @@ public class AccountSetupComposition extends K9Activity {
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
mAccount.save(Preferences.getPreferences(this));
|
||||
finish();
|
||||
mAccount.save(Preferences.getPreferences(this));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -33,26 +33,26 @@ import com.android.email.activity.ChooseFolder;
|
||||
public class AccountSetupIncoming extends K9Activity implements OnClickListener {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
|
||||
|
||||
|
||||
private static final int SELECT_DRAFT_FOLDER = 100;
|
||||
private static final int SELECT_SENT_FOLDER = 101;
|
||||
private static final int SELECT_TRASH_FOLDER = 102;
|
||||
private static final int SELECT_OUTBOX_FOLDER = 103;
|
||||
|
||||
private static final int popPorts[] = {
|
||||
110, 995, 995, 110, 110
|
||||
110, 995, 995, 110, 110
|
||||
};
|
||||
private static final String popSchemes[] = {
|
||||
"pop3", "pop3+ssl", "pop3+ssl+", "pop3+tls", "pop3+tls+"
|
||||
"pop3", "pop3+ssl", "pop3+ssl+", "pop3+tls", "pop3+tls+"
|
||||
};
|
||||
private static final int imapPorts[] = {
|
||||
143, 993, 993, 143, 143
|
||||
143, 993, 993, 143, 143
|
||||
};
|
||||
private static final String imapSchemes[] = {
|
||||
"imap", "imap+ssl", "imap+ssl+", "imap+tls", "imap+tls+"
|
||||
"imap", "imap+ssl", "imap+ssl+", "imap+tls", "imap+tls+"
|
||||
};
|
||||
private static final int webdavPorts[] = {
|
||||
80, 443, 443, 443, 443
|
||||
80, 443, 443, 443, 443
|
||||
};
|
||||
private static final String webdavSchemes[] = {
|
||||
"webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
|
||||
@ -119,13 +119,13 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
mNextButton.setOnClickListener(this);
|
||||
|
||||
SpinnerOption securityTypes[] = {
|
||||
new SpinnerOption(0, getString(R.string.account_setup_incoming_security_none_label)),
|
||||
new SpinnerOption(1,
|
||||
getString(R.string.account_setup_incoming_security_ssl_optional_label)),
|
||||
new SpinnerOption(2, getString(R.string.account_setup_incoming_security_ssl_label)),
|
||||
new SpinnerOption(3,
|
||||
getString(R.string.account_setup_incoming_security_tls_optional_label)),
|
||||
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
||||
new SpinnerOption(0, getString(R.string.account_setup_incoming_security_none_label)),
|
||||
new SpinnerOption(1,
|
||||
getString(R.string.account_setup_incoming_security_ssl_optional_label)),
|
||||
new SpinnerOption(2, getString(R.string.account_setup_incoming_security_ssl_label)),
|
||||
new SpinnerOption(3,
|
||||
getString(R.string.account_setup_incoming_security_tls_optional_label)),
|
||||
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
||||
};
|
||||
|
||||
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||
@ -201,7 +201,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
if (password != null) {
|
||||
mPasswordView.setText(password);
|
||||
}
|
||||
|
||||
|
||||
mImapFolderDrafts.setText(mAccount.getDraftsFolderName());
|
||||
mImapFolderSent.setText(mAccount.getSentFolderName());
|
||||
mImapFolderTrash.setText(mAccount.getTrashFolderName());
|
||||
@ -217,8 +217,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE);
|
||||
findViewById(R.id.webdav_path_debug_section).setVisibility(View.GONE);
|
||||
mAccount.setDeletePolicy(Account.DELETE_POLICY_NEVER);
|
||||
|
||||
|
||||
|
||||
|
||||
} else if (uri.getScheme().startsWith("imap")) {
|
||||
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
|
||||
mAccountPorts = imapPorts;
|
||||
@ -249,17 +249,17 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
for (int i = 0, count = pathParts.length; i < count; i++) {
|
||||
if (i == 0) {
|
||||
if (pathParts[0] != null &&
|
||||
pathParts[0].length() > 1) {
|
||||
pathParts[0].length() > 1) {
|
||||
mWebdavPathPrefixView.setText(pathParts[0].substring(1));
|
||||
}
|
||||
} else if (i == 1) {
|
||||
if (pathParts[1] != null &&
|
||||
pathParts[1].length() > 1) {
|
||||
pathParts[1].length() > 1) {
|
||||
mWebdavAuthPathView.setText(pathParts[1]);
|
||||
}
|
||||
} else if (i == 2) {
|
||||
if (pathParts[2] != null &&
|
||||
pathParts[2].length() > 1) {
|
||||
pathParts[2].length() > 1) {
|
||||
mWebdavMailboxPathView.setText(pathParts[2]);
|
||||
}
|
||||
}
|
||||
@ -301,16 +301,15 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
|
||||
private void validateFields() {
|
||||
mNextButton
|
||||
.setEnabled(Utility.requiredFieldValid(mUsernameView)
|
||||
&& Utility.requiredFieldValid(mPasswordView)
|
||||
&& Utility.domainFieldValid(mServerView)
|
||||
&& Utility.requiredFieldValid(mPortView));
|
||||
.setEnabled(Utility.requiredFieldValid(mUsernameView)
|
||||
&& Utility.requiredFieldValid(mPasswordView)
|
||||
&& Utility.domainFieldValid(mServerView)
|
||||
&& Utility.requiredFieldValid(mPortView));
|
||||
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
||||
}
|
||||
|
||||
private void updatePortFromSecurityType() {
|
||||
if (mAccountPorts != null)
|
||||
{
|
||||
if (mAccountPorts != null) {
|
||||
int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
|
||||
mPortView.setText(Integer.toString(mAccountPorts[securityType]));
|
||||
}
|
||||
@ -319,20 +318,20 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
switch (requestCode) {
|
||||
case SELECT_DRAFT_FOLDER:
|
||||
mImapFolderDrafts.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
case SELECT_SENT_FOLDER:
|
||||
mImapFolderSent.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
case SELECT_TRASH_FOLDER:
|
||||
mImapFolderTrash.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
case SELECT_OUTBOX_FOLDER:
|
||||
mImapFolderOutbox.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
}
|
||||
switch (requestCode) {
|
||||
case SELECT_DRAFT_FOLDER:
|
||||
mImapFolderDrafts.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
case SELECT_SENT_FOLDER:
|
||||
mImapFolderSent.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
case SELECT_TRASH_FOLDER:
|
||||
mImapFolderTrash.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
case SELECT_OUTBOX_FOLDER:
|
||||
mImapFolderOutbox.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
||||
return;
|
||||
}
|
||||
if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
||||
mAccount.save(Preferences.getPreferences(this));
|
||||
finish();
|
||||
@ -344,13 +343,13 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
try {
|
||||
URI oldUri = new URI(mAccount.getTransportUri());
|
||||
URI uri = new URI(
|
||||
oldUri.getScheme(),
|
||||
mUsernameView.getText() + ":" + mPasswordView.getText(),
|
||||
oldUri.getHost(),
|
||||
oldUri.getPort(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
oldUri.getScheme(),
|
||||
mUsernameView.getText() + ":" + mPasswordView.getText(),
|
||||
oldUri.getHost(),
|
||||
oldUri.getPort(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
mAccount.setTransportUri(uri.toString());
|
||||
} catch (URISyntaxException use) {
|
||||
/*
|
||||
@ -379,15 +378,15 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
}
|
||||
|
||||
URI uri = new URI(
|
||||
mAccountSchemes[securityType],
|
||||
mUsernameView.getText() + ":" + mPasswordView.getText(),
|
||||
mServerView.getText().toString(),
|
||||
Integer.parseInt(mPortView.getText().toString()),
|
||||
path, // path
|
||||
null, // query
|
||||
null);
|
||||
mAccountSchemes[securityType],
|
||||
mUsernameView.getText() + ":" + mPasswordView.getText(),
|
||||
mServerView.getText().toString(),
|
||||
Integer.parseInt(mPortView.getText().toString()),
|
||||
path, // path
|
||||
null, // query
|
||||
null);
|
||||
mAccount.setStoreUri(uri.toString());
|
||||
|
||||
|
||||
|
||||
mAccount.setDraftsFolderName(mImapFolderDrafts.getText().toString());
|
||||
mAccount.setSentFolderName(mImapFolderSent.getText().toString());
|
||||
@ -401,64 +400,60 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
switch (v.getId()) {
|
||||
case R.id.next:
|
||||
onNext();
|
||||
break;
|
||||
case R.id.account_imap_folder_drafts:
|
||||
selectImapFolder(SELECT_DRAFT_FOLDER);
|
||||
break;
|
||||
case R.id.account_imap_folder_sent:
|
||||
selectImapFolder(SELECT_SENT_FOLDER);
|
||||
break;
|
||||
case R.id.account_imap_folder_trash:
|
||||
selectImapFolder(SELECT_TRASH_FOLDER);
|
||||
break;
|
||||
case R.id.account_imap_folder_outbox:
|
||||
selectImapFolder(SELECT_OUTBOX_FOLDER);
|
||||
break;
|
||||
case R.id.next:
|
||||
onNext();
|
||||
break;
|
||||
case R.id.account_imap_folder_drafts:
|
||||
selectImapFolder(SELECT_DRAFT_FOLDER);
|
||||
break;
|
||||
case R.id.account_imap_folder_sent:
|
||||
selectImapFolder(SELECT_SENT_FOLDER);
|
||||
break;
|
||||
case R.id.account_imap_folder_trash:
|
||||
selectImapFolder(SELECT_TRASH_FOLDER);
|
||||
break;
|
||||
case R.id.account_imap_folder_outbox:
|
||||
selectImapFolder(SELECT_OUTBOX_FOLDER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
failure(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void selectImapFolder(int activityCode) {
|
||||
String curFolder = null;
|
||||
switch (activityCode) {
|
||||
case SELECT_DRAFT_FOLDER:
|
||||
curFolder = mImapFolderDrafts.getText().toString();
|
||||
break;
|
||||
case SELECT_SENT_FOLDER:
|
||||
curFolder = mImapFolderSent.getText().toString();
|
||||
break;
|
||||
case SELECT_TRASH_FOLDER:
|
||||
curFolder = mImapFolderTrash.getText().toString();
|
||||
break;
|
||||
case SELECT_OUTBOX_FOLDER:
|
||||
curFolder = mImapFolderOutbox.getText().toString();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot select folder for: " + activityCode);
|
||||
}
|
||||
|
||||
Intent selectIntent = new Intent(this, ChooseFolder.class);
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount);
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, curFolder);
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_CURRENT, "yes");
|
||||
startActivityForResult(selectIntent, activityCode);
|
||||
}
|
||||
|
||||
private void failure(Exception use)
|
||||
{
|
||||
Log.e(Email.LOG_TAG, "Failure", use);
|
||||
private void selectImapFolder(int activityCode) {
|
||||
String curFolder = null;
|
||||
switch (activityCode) {
|
||||
case SELECT_DRAFT_FOLDER:
|
||||
curFolder = mImapFolderDrafts.getText().toString();
|
||||
break;
|
||||
case SELECT_SENT_FOLDER:
|
||||
curFolder = mImapFolderSent.getText().toString();
|
||||
break;
|
||||
case SELECT_TRASH_FOLDER:
|
||||
curFolder = mImapFolderTrash.getText().toString();
|
||||
break;
|
||||
case SELECT_OUTBOX_FOLDER:
|
||||
curFolder = mImapFolderOutbox.getText().toString();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot select folder for: " + activityCode);
|
||||
}
|
||||
|
||||
Intent selectIntent = new Intent(this, ChooseFolder.class);
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount);
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, curFolder);
|
||||
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_CURRENT, "yes");
|
||||
startActivityForResult(selectIntent, activityCode);
|
||||
}
|
||||
|
||||
private void failure(Exception use) {
|
||||
Log.e(Email.LOG_TAG, "Failure", use);
|
||||
String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
|
||||
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class AccountSetupNames extends K9Activity implements OnClickListener {
|
||||
}
|
||||
};
|
||||
mName.addTextChangedListener(validationTextWatcher);
|
||||
|
||||
|
||||
mName.setKeyListener(TextKeyListener.getInstance(false, Capitalize.WORDS));
|
||||
|
||||
mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT);
|
||||
@ -95,9 +95,9 @@ public class AccountSetupNames extends K9Activity implements OnClickListener {
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.done:
|
||||
onNext();
|
||||
break;
|
||||
case R.id.done:
|
||||
onNext();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
||||
private Spinner mCheckFrequencyView;
|
||||
|
||||
private Spinner mDisplayCountView;
|
||||
|
||||
|
||||
|
||||
private CheckBox mNotifyView;
|
||||
private CheckBox mNotifySyncView;
|
||||
@ -55,82 +55,79 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
||||
findViewById(R.id.next).setOnClickListener(this);
|
||||
|
||||
SpinnerOption checkFrequencies[] = {
|
||||
new SpinnerOption(-1,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_never)),
|
||||
new SpinnerOption(1,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_1min)),
|
||||
new SpinnerOption(5,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_5min)),
|
||||
new SpinnerOption(10,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_10min)),
|
||||
new SpinnerOption(15,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_15min)),
|
||||
new SpinnerOption(30,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_30min)),
|
||||
new SpinnerOption(60,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_1hour)),
|
||||
new SpinnerOption(120,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_2hour)),
|
||||
new SpinnerOption(180,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_3hour)),
|
||||
new SpinnerOption(360,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_6hour)),
|
||||
new SpinnerOption(720,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_12hour)),
|
||||
new SpinnerOption(1440,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_24hour)),
|
||||
|
||||
};
|
||||
new SpinnerOption(-1,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_never)),
|
||||
new SpinnerOption(1,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_1min)),
|
||||
new SpinnerOption(5,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_5min)),
|
||||
new SpinnerOption(10,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_10min)),
|
||||
new SpinnerOption(15,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_15min)),
|
||||
new SpinnerOption(30,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_30min)),
|
||||
new SpinnerOption(60,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_1hour)),
|
||||
new SpinnerOption(120,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_2hour)),
|
||||
new SpinnerOption(180,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_3hour)),
|
||||
new SpinnerOption(360,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_6hour)),
|
||||
new SpinnerOption(720,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_12hour)),
|
||||
new SpinnerOption(1440,
|
||||
getString(R.string.account_setup_options_mail_check_frequency_24hour)),
|
||||
|
||||
};
|
||||
|
||||
ArrayAdapter<SpinnerOption> checkFrequenciesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||
android.R.layout.simple_spinner_item, checkFrequencies);
|
||||
checkFrequenciesAdapter
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mCheckFrequencyView.setAdapter(checkFrequenciesAdapter);
|
||||
|
||||
SpinnerOption displayCounts[] = {
|
||||
new SpinnerOption(10,
|
||||
getString(R.string.account_setup_options_mail_display_count_10)),
|
||||
getString(R.string.account_setup_options_mail_display_count_10)),
|
||||
new SpinnerOption(25,
|
||||
getString(R.string.account_setup_options_mail_display_count_25)),
|
||||
getString(R.string.account_setup_options_mail_display_count_25)),
|
||||
new SpinnerOption(50,
|
||||
getString(R.string.account_setup_options_mail_display_count_50)),
|
||||
getString(R.string.account_setup_options_mail_display_count_50)),
|
||||
new SpinnerOption(100,
|
||||
getString(R.string.account_setup_options_mail_display_count_100)),
|
||||
getString(R.string.account_setup_options_mail_display_count_100)),
|
||||
};
|
||||
|
||||
ArrayAdapter<SpinnerOption> displayCountsAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||
android.R.layout.simple_spinner_item, displayCounts);
|
||||
displayCountsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mDisplayCountView.setAdapter(displayCountsAdapter);
|
||||
|
||||
|
||||
mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT);
|
||||
|
||||
mNotifyView.setChecked(mAccount.isNotifyNewMail());
|
||||
mNotifySyncView.setChecked(mAccount.isShowOngoing());
|
||||
SpinnerOption.setSpinnerOptionValue(mCheckFrequencyView, mAccount
|
||||
.getAutomaticCheckIntervalMinutes());
|
||||
.getAutomaticCheckIntervalMinutes());
|
||||
SpinnerOption.setSpinnerOptionValue(mDisplayCountView, mAccount
|
||||
.getDisplayCount());
|
||||
.getDisplayCount());
|
||||
|
||||
|
||||
boolean isPushCapable = false;
|
||||
try
|
||||
{
|
||||
Store store = Store.getInstance(mAccount.getStoreUri(), getApplication());
|
||||
try {
|
||||
Store store = Store.getInstance(mAccount.getStoreUri(), getApplication());
|
||||
isPushCapable = store.isPushCapable();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
Log.e(Email.LOG_TAG, "Could not get remote store", e);
|
||||
}
|
||||
|
||||
|
||||
if(!isPushCapable) {
|
||||
mPushEnable.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (!isPushCapable) {
|
||||
mPushEnable.setVisibility(View.GONE);
|
||||
} else {
|
||||
mPushEnable.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -142,17 +139,17 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
||||
mAccount.setAutomaticCheckIntervalMinutes((Integer)((SpinnerOption)mCheckFrequencyView
|
||||
.getSelectedItem()).value);
|
||||
mAccount.setDisplayCount((Integer)((SpinnerOption)mDisplayCountView
|
||||
.getSelectedItem()).value);
|
||||
.getSelectedItem()).value);
|
||||
|
||||
if (mPushEnable.isChecked()) {
|
||||
mAccount.setFolderPushMode(Account.FolderMode.FIRST_CLASS);
|
||||
} else {
|
||||
mAccount.setFolderPushMode(Account.FolderMode.NONE);
|
||||
if (mPushEnable.isChecked()) {
|
||||
mAccount.setFolderPushMode(Account.FolderMode.FIRST_CLASS);
|
||||
} else {
|
||||
mAccount.setFolderPushMode(Account.FolderMode.NONE);
|
||||
}
|
||||
|
||||
mAccount.save(Preferences.getPreferences(this));
|
||||
if (mAccount.equals(Preferences.getPreferences(this).getDefaultAccount()) ||
|
||||
getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false) ) {
|
||||
getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false) ) {
|
||||
Preferences.getPreferences(this).setDefaultAccount(mAccount);
|
||||
}
|
||||
Email.setServicesEnabled(this);
|
||||
@ -162,9 +159,9 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.next:
|
||||
onDone();
|
||||
break;
|
||||
case R.id.next:
|
||||
onDone();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,23 +32,23 @@ import com.android.email.R;
|
||||
import com.android.email.Utility;
|
||||
|
||||
public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
OnCheckedChangeListener {
|
||||
OnCheckedChangeListener {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
|
||||
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
|
||||
|
||||
private static final int smtpPorts[] = {
|
||||
25, 465, 465, 25, 25
|
||||
25, 465, 465, 25, 25
|
||||
};
|
||||
|
||||
private static final String smtpSchemes[] = {
|
||||
"smtp", "smtp+ssl", "smtp+ssl+", "smtp+tls", "smtp+tls+"
|
||||
"smtp", "smtp+ssl", "smtp+ssl+", "smtp+tls", "smtp+tls+"
|
||||
};
|
||||
private static final int webdavPorts[] = {
|
||||
80, 443, 443, 443, 443
|
||||
};
|
||||
private static final String webdavSchemes[] = {
|
||||
"webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
|
||||
"webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
|
||||
};
|
||||
|
||||
private EditText mUsernameView;
|
||||
@ -82,18 +82,18 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
setContentView(R.layout.account_setup_outgoing);
|
||||
|
||||
mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT);
|
||||
|
||||
try {
|
||||
if (new URI(mAccount.getStoreUri()).getScheme().startsWith("webdav")) {
|
||||
mAccount.setTransportUri(mAccount.getStoreUri());
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, false, true);
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (new URI(mAccount.getStoreUri()).getScheme().startsWith("webdav")) {
|
||||
mAccount.setTransportUri(mAccount.getStoreUri());
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, false, true);
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
mUsernameView = (EditText)findViewById(R.id.account_username);
|
||||
mPasswordView = (EditText)findViewById(R.id.account_password);
|
||||
mServerView = (EditText)findViewById(R.id.account_server);
|
||||
@ -107,13 +107,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
mRequireLoginView.setOnCheckedChangeListener(this);
|
||||
|
||||
SpinnerOption securityTypes[] = {
|
||||
new SpinnerOption(0, getString(R.string.account_setup_incoming_security_none_label)),
|
||||
new SpinnerOption(1,
|
||||
getString(R.string.account_setup_incoming_security_ssl_optional_label)),
|
||||
new SpinnerOption(2, getString(R.string.account_setup_incoming_security_ssl_label)),
|
||||
new SpinnerOption(3,
|
||||
getString(R.string.account_setup_incoming_security_tls_optional_label)),
|
||||
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
||||
new SpinnerOption(0, getString(R.string.account_setup_incoming_security_none_label)),
|
||||
new SpinnerOption(1,
|
||||
getString(R.string.account_setup_incoming_security_ssl_optional_label)),
|
||||
new SpinnerOption(2, getString(R.string.account_setup_incoming_security_ssl_label)),
|
||||
new SpinnerOption(3,
|
||||
getString(R.string.account_setup_incoming_security_tls_optional_label)),
|
||||
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
||||
};
|
||||
|
||||
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||
@ -225,12 +225,12 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
|
||||
private void validateFields() {
|
||||
mNextButton
|
||||
.setEnabled(
|
||||
Utility.domainFieldValid(mServerView) &&
|
||||
Utility.requiredFieldValid(mPortView) &&
|
||||
(!mRequireLoginView.isChecked() ||
|
||||
(Utility.requiredFieldValid(mUsernameView) &&
|
||||
Utility.requiredFieldValid(mPasswordView))));
|
||||
.setEnabled(
|
||||
Utility.domainFieldValid(mServerView) &&
|
||||
Utility.requiredFieldValid(mPortView) &&
|
||||
(!mRequireLoginView.isChecked() ||
|
||||
(Utility.requiredFieldValid(mUsernameView) &&
|
||||
Utility.requiredFieldValid(mPasswordView))));
|
||||
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
||||
}
|
||||
|
||||
@ -259,10 +259,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
String userInfo = null;
|
||||
if (mRequireLoginView.isChecked()) {
|
||||
userInfo = mUsernameView.getText().toString() + ":"
|
||||
+ mPasswordView.getText().toString();
|
||||
+ mPasswordView.getText().toString();
|
||||
}
|
||||
uri = new URI(smtpSchemes[securityType], userInfo, mServerView.getText().toString(),
|
||||
Integer.parseInt(mPortView.getText().toString()), null, null, null);
|
||||
Integer.parseInt(mPortView.getText().toString()), null, null, null);
|
||||
mAccount.setTransportUri(uri.toString());
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, false, true);
|
||||
} catch (Exception e) {
|
||||
@ -272,14 +272,14 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
*/
|
||||
failure(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.next:
|
||||
onNext();
|
||||
break;
|
||||
case R.id.next:
|
||||
onNext();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,11 +287,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
mRequireLoginSettingsView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
validateFields();
|
||||
}
|
||||
private void failure(Exception use)
|
||||
{
|
||||
private void failure(Exception use) {
|
||||
Log.e(Email.LOG_TAG, "Failure", use);
|
||||
String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
|
||||
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
|
@ -25,17 +25,17 @@ import com.android.email.mail.Folder.FolderClass;
|
||||
import com.android.email.mail.store.LocalStore.LocalFolder;
|
||||
|
||||
public class FolderSettings extends K9PreferenceActivity {
|
||||
|
||||
|
||||
private static final String EXTRA_FOLDER_NAME = "com.android.email.folderName";
|
||||
private static final String EXTRA_ACCOUNT = "com.android.email.account";
|
||||
|
||||
|
||||
private static final String PREFERENCE_TOP_CATERGORY = "folder_settings";
|
||||
private static final String PREFERENCE_DISPLAY_CLASS = "folder_settings_folder_display_mode";
|
||||
private static final String PREFERENCE_SYNC_CLASS = "folder_settings_folder_sync_mode";
|
||||
private static final String PREFERENCE_PUSH_CLASS = "folder_settings_folder_push_mode";
|
||||
|
||||
private LocalFolder mFolder;
|
||||
|
||||
|
||||
private ListPreference mDisplayClass;
|
||||
private ListPreference mSyncClass;
|
||||
private ListPreference mPushClass;
|
||||
@ -53,29 +53,23 @@ public class FolderSettings extends K9PreferenceActivity {
|
||||
|
||||
String folderName = (String)getIntent().getSerializableExtra(EXTRA_FOLDER_NAME);
|
||||
Account mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT);
|
||||
|
||||
try
|
||||
{
|
||||
Store localStore = Store.getInstance(mAccount.getLocalStoreUri(),
|
||||
getApplication());
|
||||
mFolder = (LocalFolder) localStore.getFolder(folderName);
|
||||
mFolder.refresh(Preferences.getPreferences(this));
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
Log.e(Email.LOG_TAG, "Unable to edit folder " + folderName + " preferences", me);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isPushCapable = false;
|
||||
|
||||
try {
|
||||
Store localStore = Store.getInstance(mAccount.getLocalStoreUri(),
|
||||
getApplication());
|
||||
mFolder = (LocalFolder) localStore.getFolder(folderName);
|
||||
mFolder.refresh(Preferences.getPreferences(this));
|
||||
} catch (MessagingException me) {
|
||||
Log.e(Email.LOG_TAG, "Unable to edit folder " + folderName + " preferences", me);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isPushCapable = false;
|
||||
Store store = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
store = Store.getInstance(mAccount.getStoreUri(), getApplication());
|
||||
isPushCapable = store.isPushCapable();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
Log.e(Email.LOG_TAG, "Could not get remote store", e);
|
||||
}
|
||||
|
||||
@ -83,7 +77,7 @@ public class FolderSettings extends K9PreferenceActivity {
|
||||
|
||||
Preference category = findPreference(PREFERENCE_TOP_CATERGORY);
|
||||
category.setTitle(folderName);
|
||||
|
||||
|
||||
mDisplayClass = (ListPreference) findPreference(PREFERENCE_DISPLAY_CLASS);
|
||||
mDisplayClass.setValue(mFolder.getDisplayClass().name());
|
||||
mDisplayClass.setSummary(mDisplayClass.getEntry());
|
||||
@ -109,7 +103,7 @@ public class FolderSettings extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mPushClass = (ListPreference) findPreference(PREFERENCE_PUSH_CLASS);
|
||||
mPushClass.setEnabled(isPushCapable);
|
||||
mPushClass.setValue(mFolder.getRawPushClass().name());
|
||||
@ -128,30 +122,24 @@ public class FolderSettings extends K9PreferenceActivity {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
try
|
||||
{
|
||||
mFolder.refresh(Preferences.getPreferences(this));
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
Log.e(Email.LOG_TAG, "Could not refresh folder preferences for folder " + mFolder.getName(), me);
|
||||
try {
|
||||
mFolder.refresh(Preferences.getPreferences(this));
|
||||
} catch (MessagingException me) {
|
||||
Log.e(Email.LOG_TAG, "Could not refresh folder preferences for folder " + mFolder.getName(), me);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSettings() {
|
||||
mFolder.setDisplayClass(FolderClass.valueOf(mDisplayClass.getValue()));
|
||||
mFolder.setSyncClass(FolderClass.valueOf(mSyncClass.getValue()));
|
||||
mFolder.setPushClass(FolderClass.valueOf(mPushClass.getValue()));
|
||||
|
||||
try
|
||||
{
|
||||
mFolder.save(Preferences.getPreferences(this));
|
||||
Email.setServicesEnabled(this);
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
Log.e(Email.LOG_TAG, "Could not refresh folder preferences for folder " + mFolder.getName(), me);
|
||||
}
|
||||
mFolder.setDisplayClass(FolderClass.valueOf(mDisplayClass.getValue()));
|
||||
mFolder.setSyncClass(FolderClass.valueOf(mSyncClass.getValue()));
|
||||
mFolder.setPushClass(FolderClass.valueOf(mPushClass.getValue()));
|
||||
|
||||
try {
|
||||
mFolder.save(Preferences.getPreferences(this));
|
||||
Email.setServicesEnabled(this);
|
||||
} catch (MessagingException me) {
|
||||
Log.e(Email.LOG_TAG, "Could not refresh folder preferences for folder " + mFolder.getName(), me);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,5 +150,5 @@ public class FolderSettings extends K9PreferenceActivity {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ public class Prefs extends K9PreferenceActivity {
|
||||
private ListPreference mBackgroundOps;
|
||||
private CheckBoxPreference mDebugLogging;
|
||||
private CheckBoxPreference mSensitiveLogging;
|
||||
|
||||
|
||||
private String initBackgroundOps;
|
||||
|
||||
|
||||
|
||||
public static void actionPrefs(Context context) {
|
||||
Intent i = new Intent(context, Prefs.class);
|
||||
@ -64,7 +64,7 @@ public class Prefs extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mBackgroundOps = (ListPreference) findPreference(PREFERENCE_BACKGROUND_OPS);
|
||||
initBackgroundOps = Email.getBackgroundOps().toString();
|
||||
mBackgroundOps.setValue(initBackgroundOps);
|
||||
@ -78,13 +78,13 @@ public class Prefs extends K9PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mDebugLogging = (CheckBoxPreference)findPreference(PREFERENCE_DEBUG_LOGGING);
|
||||
mSensitiveLogging = (CheckBoxPreference)findPreference(PREFERENCE_SENSITIVE_LOGGING);
|
||||
|
||||
mDebugLogging.setChecked(Email.DEBUG);
|
||||
mSensitiveLogging.setChecked(Email.DEBUG_SENSITIVE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,12 +100,11 @@ public class Prefs extends K9PreferenceActivity {
|
||||
String newBackgroundOps = mBackgroundOps.getValue();
|
||||
Email.setBackgroundOps(newBackgroundOps);
|
||||
Email.save(preferences);
|
||||
if (newBackgroundOps.equals(initBackgroundOps) == false)
|
||||
{
|
||||
if (newBackgroundOps.equals(initBackgroundOps) == false) {
|
||||
MailService.backgroundDataChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package com.android.email.activity.setup;
|
||||
|
Loading…
x
Reference in New Issue
Block a user