1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 00:58:50 -05:00

Changed code formatting. No functional changes

This commit is contained in:
cketti 2012-03-18 22:06:44 +01:00
parent b7c1f8ab2f
commit 4f2412eacd

View File

@ -36,6 +36,16 @@ import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
public class ChooseFolder extends K9ListActivity { public class ChooseFolder extends K9ListActivity {
public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseFolder_account";
public static final String EXTRA_CUR_FOLDER = "com.fsck.k9.ChooseFolder_curfolder";
public static final String EXTRA_SEL_FOLDER = "com.fsck.k9.ChooseFolder_selfolder";
public static final String EXTRA_NEW_FOLDER = "com.fsck.k9.ChooseFolder_newfolder";
public static final String EXTRA_MESSAGE = "com.fsck.k9.ChooseFolder_message";
public static final String EXTRA_SHOW_CURRENT = "com.fsck.k9.ChooseFolder_showcurrent";
public static final String EXTRA_SHOW_FOLDER_NONE = "com.fsck.k9.ChooseFolder_showOptionNone";
public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = "com.fsck.k9.ChooseFolder_showDisplayableOnly";
String mFolder; String mFolder;
String mSelectFolder; String mSelectFolder;
Account mAccount; Account mAccount;
@ -54,6 +64,7 @@ public class ChooseFolder extends K9ListActivity {
* while this activity is showing. * while this activity is showing.
*/ */
private Account.FolderMode mMode; private Account.FolderMode mMode;
/** /**
* Current filter used by our ArrayAdapter.<br/> * Current filter used by our ArrayAdapter.<br/>
* Created on the fly and invalidated if a new * Created on the fly and invalidated if a new
@ -61,14 +72,6 @@ public class ChooseFolder extends K9ListActivity {
*/ */
private FolderListFilter<String> mMyFilter = null; private FolderListFilter<String> mMyFilter = null;
public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseFolder_account";
public static final String EXTRA_CUR_FOLDER = "com.fsck.k9.ChooseFolder_curfolder";
public static final String EXTRA_SEL_FOLDER = "com.fsck.k9.ChooseFolder_selfolder";
public static final String EXTRA_NEW_FOLDER = "com.fsck.k9.ChooseFolder_newfolder";
public static final String EXTRA_MESSAGE = "com.fsck.k9.ChooseFolder_message";
public static final String EXTRA_SHOW_CURRENT = "com.fsck.k9.ChooseFolder_showcurrent";
public static final String EXTRA_SHOW_FOLDER_NONE = "com.fsck.k9.ChooseFolder_showOptionNone";
public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = "com.fsck.k9.ChooseFolder_showDisplayableOnly";
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -110,55 +113,54 @@ public class ChooseFolder extends K9ListActivity {
setListAdapter(mAdapter); setListAdapter(mAdapter);
mMode = mAccount.getFolderTargetMode(); mMode = mAccount.getFolderTargetMode();
MessagingController.getInstance(getApplication()).listFolders(mAccount, false, mListener); MessagingController.getInstance(getApplication()).listFolders(mAccount, false, mListener);
this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { this.getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(); Intent result = new Intent();
intent.putExtra(EXTRA_ACCOUNT, mAccount.getUuid()); result.putExtra(EXTRA_ACCOUNT, mAccount.getUuid());
intent.putExtra(EXTRA_CUR_FOLDER, mFolder); result.putExtra(EXTRA_CUR_FOLDER, mFolder);
String destFolderName = (String)((TextView)view).getText(); String destFolderName = (String)((TextView)view).getText();
if (mHeldInbox != null && getString(R.string.special_mailbox_name_inbox).equals(destFolderName)) { if (mHeldInbox != null && getString(R.string.special_mailbox_name_inbox).equals(destFolderName)) {
destFolderName = mHeldInbox; destFolderName = mHeldInbox;
} }
intent.putExtra(EXTRA_NEW_FOLDER, destFolderName); result.putExtra(EXTRA_NEW_FOLDER, destFolderName);
intent.putExtra(EXTRA_MESSAGE, mMessageReference); result.putExtra(EXTRA_MESSAGE, mMessageReference);
setResult(RESULT_OK, intent); setResult(RESULT_OK, result);
finish(); finish();
} }
}); });
} }
class ChooseFolderHandler extends Handler { class ChooseFolderHandler 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;
private static final int MSG_SET_SELECTED_FOLDER = 4; private static final int MSG_SET_SELECTED_FOLDER = 4;
@Override @Override
public void handleMessage(android.os.Message msg) { public void handleMessage(android.os.Message msg) {
switch (msg.what) { switch (msg.what) {
case MSG_PROGRESS: case MSG_PROGRESS: {
setProgressBarIndeterminateVisibility(msg.arg1 != 0); setProgressBarIndeterminateVisibility(msg.arg1 != 0);
break; break;
case MSG_DATA_CHANGED: }
mAdapter.notifyDataSetChanged(); case MSG_DATA_CHANGED: {
mAdapter.notifyDataSetChanged();
/* /*
* Only enable the text filter after the list has been * Only enable the text filter after the list has been
* populated to avoid possible race conditions because our * populated to avoid possible race conditions because our
* FolderListFilter isn't really thread-safe. * FolderListFilter isn't really thread-safe.
*/ */
getListView().setTextFilterEnabled(true); getListView().setTextFilterEnabled(true);
break; break;
case MSG_SET_SELECTED_FOLDER: }
getListView().setSelection(msg.arg1); case MSG_SET_SELECTED_FOLDER: {
break; getListView().setSelection(msg.arg1);
break;
}
} }
} }
@ -181,52 +183,48 @@ public class ChooseFolder extends K9ListActivity {
} }
} }
@Override public boolean onCreateOptionsMenu(Menu menu) { @Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.folder_select_option, menu); getMenuInflater().inflate(R.menu.folder_select_option, menu);
return true; return true;
} }
@Override public boolean onOptionsItemSelected(MenuItem item) { @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.display_1st_class: {
setDisplayMode(FolderMode.FIRST_CLASS);
case R.id.display_1st_class: { return true;
setDisplayMode(FolderMode.FIRST_CLASS); }
return true; case R.id.display_1st_and_2nd_class: {
} setDisplayMode(FolderMode.FIRST_AND_SECOND_CLASS);
case R.id.display_1st_and_2nd_class: { return true;
setDisplayMode(FolderMode.FIRST_AND_SECOND_CLASS); }
return true; case R.id.display_not_second_class: {
} setDisplayMode(FolderMode.NOT_SECOND_CLASS);
case R.id.display_not_second_class: { return true;
setDisplayMode(FolderMode.NOT_SECOND_CLASS); }
return true; case R.id.display_all: {
} setDisplayMode(FolderMode.ALL);
case R.id.display_all: { return true;
setDisplayMode(FolderMode.ALL); }
return true; case R.id.list_folders: {
} onRefresh();
return true;
case R.id.list_folders: { }
onRefresh(); case R.id.filter_folders: {
onEnterFilter();
return true; return true;
} }
case R.id.filter_folders: { default: {
onEnterFilter(); return super.onOptionsItemSelected(item);
} }
return true;
default:
return super.onOptionsItemSelected(item);
} }
} }
private void onRefresh() { private void onRefresh() {
MessagingController.getInstance(getApplication()).listFolders(mAccount, true, mListener); MessagingController.getInstance(getApplication()).listFolders(mAccount, true, mListener);
} }
/** /**
@ -238,40 +236,37 @@ public class ChooseFolder extends K9ListActivity {
final EditText input = new EditText(this); final EditText input = new EditText(this);
input.addTextChangedListener(new TextWatcher() { input.addTextChangedListener(new TextWatcher() {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
mAdapter.getFilter().filter(input.getText().toString()); mAdapter.getFilter().filter(input.getText().toString());
} }
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, public void beforeTextChanged(CharSequence s, int start, int count, int after) {
int after) { /* not used */ }
}
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) { /* not used */ }
}
}); });
input.setHint(R.string.folder_list_filter_hint); input.setHint(R.string.folder_list_filter_hint);
filterAlert.setView(input); filterAlert.setView(input);
filterAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { filterAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) { public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString().trim(); String value = input.getText().toString().trim();
mAdapter.getFilter().filter(value); mAdapter.getFilter().filter(value);
} }
}); });
filterAlert.setNegativeButton("Cancel", filterAlert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener() { @Override
public void onClick(DialogInterface dialog, int whichButton) { public void onClick(DialogInterface dialog, int whichButton) {
mAdapter.getFilter().filter(""); mAdapter.getFilter().filter("");
} }
}); });
filterAlert.show(); filterAlert.show();
} }
private void setDisplayMode(FolderMode aMode) { private void setDisplayMode(FolderMode aMode) {
@ -281,8 +276,7 @@ public class ChooseFolder extends K9ListActivity {
mMyFilter.invalidate(); mMyFilter.invalidate();
} }
//re-populate the list //re-populate the list
MessagingController.getInstance(getApplication()).listFolders(mAccount, MessagingController.getInstance(getApplication()).listFolders(mAccount, false, mListener);
false, mListener);
} }
private MessagingListener mListener = new MessagingListener() { private MessagingListener mListener = new MessagingListener() {
@ -322,23 +316,27 @@ public class ChooseFolder extends K9ListActivity {
String name = folder.getName(); String name = folder.getName();
// Inbox needs to be compared case-insensitively // Inbox needs to be compared case-insensitively
if (mHideCurrentFolder && (name.equals(mFolder) || if (mHideCurrentFolder && (name.equals(mFolder) || (
(mAccount.getInboxFolderName().equalsIgnoreCase(mFolder) && mAccount.getInboxFolderName().equalsIgnoreCase(name)))) { mAccount.getInboxFolderName().equalsIgnoreCase(mFolder) &&
mAccount.getInboxFolderName().equalsIgnoreCase(name)))) {
continue; continue;
} }
try { try {
folder.refresh(prefs); folder.refresh(prefs);
Folder.FolderClass fMode = folder.getDisplayClass(); Folder.FolderClass fMode = folder.getDisplayClass();
if ((aMode == Account.FolderMode.FIRST_CLASS && fMode != Folder.FolderClass.FIRST_CLASS) if ((aMode == Account.FolderMode.FIRST_CLASS &&
|| (aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS && fMode != Folder.FolderClass.FIRST_CLASS) || (
aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS &&
fMode != Folder.FolderClass.FIRST_CLASS && fMode != Folder.FolderClass.FIRST_CLASS &&
fMode != Folder.FolderClass.SECOND_CLASS) fMode != Folder.FolderClass.SECOND_CLASS) || (
|| (aMode == Account.FolderMode.NOT_SECOND_CLASS && fMode == Folder.FolderClass.SECOND_CLASS)) { aMode == Account.FolderMode.NOT_SECOND_CLASS &&
fMode == Folder.FolderClass.SECOND_CLASS)) {
continue; continue;
} }
} catch (MessagingException me) { } catch (MessagingException me) {
Log.e(K9.LOG_TAG, "Couldn't get prefs to check for displayability of folder " + folder.getName(), me); Log.e(K9.LOG_TAG, "Couldn't get prefs to check for displayability of folder " +
folder.getName(), me);
} }
localFolders.add(folder.getName()); localFolders.add(folder.getName());
@ -350,6 +348,7 @@ public class ChooseFolder extends K9ListActivity {
} }
Collections.sort(localFolders, new Comparator<String>() { Collections.sort(localFolders, new Comparator<String>() {
@Override
public int compare(String aName, String bName) { public int compare(String aName, String bName) {
if (K9.FOLDER_NONE.equalsIgnoreCase(aName)) { if (K9.FOLDER_NONE.equalsIgnoreCase(aName)) {
return -1; return -1;
@ -380,7 +379,8 @@ public class ChooseFolder extends K9ListActivity {
if (mAccount.getInboxFolderName().equalsIgnoreCase(name)) { if (mAccount.getInboxFolderName().equalsIgnoreCase(name)) {
folderList.add(getString(R.string.special_mailbox_name_inbox)); folderList.add(getString(R.string.special_mailbox_name_inbox));
mHeldInbox = name; mHeldInbox = name;
} else if (!K9.ERROR_FOLDER_NAME.equals(name) && !account.getOutboxFolderName().equals(name)) { } else if (!K9.ERROR_FOLDER_NAME.equals(name) &&
!account.getOutboxFolderName().equals(name)) {
folderList.add(name); folderList.add(name);
} }
@ -393,14 +393,16 @@ public class ChooseFolder extends K9ListActivity {
if (name.equals(mSelectFolder)) { if (name.equals(mSelectFolder)) {
selectedFolder = position; selectedFolder = position;
} }
} else if (name.equals(mFolder) || } else if (name.equals(mFolder) || (
(mAccount.getInboxFolderName().equalsIgnoreCase(mFolder) && mAccount.getInboxFolderName().equalsIgnoreCase(name))) { mAccount.getInboxFolderName().equalsIgnoreCase(mFolder) &&
mAccount.getInboxFolderName().equalsIgnoreCase(name))) {
selectedFolder = position; selectedFolder = position;
} }
position++; position++;
} }
} finally { } finally {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
// Now we're in the UI-thread, we can safely change the contents of the adapter. // Now we're in the UI-thread, we can safely change the contents of the adapter.
mAdapter.clear(); mAdapter.clear();