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