Merge pull request #3135 from philipwhiuk/improveCodeStyle

Improve code style in several Activity classes
This commit is contained in:
Vincent Breitmoser 2018-01-27 10:43:02 +01:00 committed by GitHub
commit 6767f41505
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 560 additions and 560 deletions

View file

@ -122,21 +122,21 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
private ConcurrentMap<BaseAccount, String> pendingWork = new ConcurrentHashMap<BaseAccount, String>(); private ConcurrentMap<BaseAccount, String> pendingWork = new ConcurrentHashMap<BaseAccount, String>();
private BaseAccount mSelectedContextAccount; private BaseAccount selectedContextAccount;
private int mUnreadMessageCount = 0; private int unreadMessageCount = 0;
private AccountsHandler mHandler = new AccountsHandler(); private AccountsHandler handler = new AccountsHandler();
private AccountsAdapter mAdapter; private AccountsAdapter adapter;
private SearchAccount mAllMessagesAccount = null; private SearchAccount allMessagesAccount = null;
private SearchAccount mUnifiedInboxAccount = null; private SearchAccount unifiedInboxAccount = null;
private FontSizes mFontSizes = K9.getFontSizes(); private FontSizes fontSizes = K9.getFontSizes();
private MenuItem mRefreshMenuItem; private MenuItem refreshMenuItem;
private ActionBar mActionBar; private ActionBar actionBar;
private TextView mActionBarTitle; private TextView actionBarTitle;
private TextView mActionBarSubTitle; private TextView actionBarSubTitle;
private TextView mActionBarUnread; private TextView actionBarUnread;
private boolean exportGlobalSettings; private boolean exportGlobalSettings;
private ArrayList<String> exportAccountUuids; private ArrayList<String> exportAccountUuids;
@ -146,7 +146,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
* *
* @see #onRetainNonConfigurationInstance() * @see #onRetainNonConfigurationInstance()
*/ */
private NonConfigurationInstance mNonConfigurationInstance; private NonConfigurationInstance nonConfigurationInstance;
private static final int ACTIVITY_REQUEST_PICK_SETTINGS_FILE = 1; private static final int ACTIVITY_REQUEST_PICK_SETTINGS_FILE = 1;
@ -154,22 +154,22 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
class AccountsHandler extends Handler { class AccountsHandler extends Handler {
private void setViewTitle() { private void setViewTitle() {
mActionBarTitle.setText(getString(R.string.accounts_title)); actionBarTitle.setText(getString(R.string.accounts_title));
if (mUnreadMessageCount == 0) { if (unreadMessageCount == 0) {
mActionBarUnread.setVisibility(View.GONE); actionBarUnread.setVisibility(View.GONE);
} else { } else {
mActionBarUnread.setText(String.format("%d", mUnreadMessageCount)); actionBarUnread.setText(String.format("%d", unreadMessageCount));
mActionBarUnread.setVisibility(View.VISIBLE); actionBarUnread.setVisibility(View.VISIBLE);
} }
String operation = mListener.getOperation(Accounts.this); String operation = mListener.getOperation(Accounts.this);
operation = operation.trim(); operation = operation.trim();
if (operation.length() < 1) { if (operation.length() < 1) {
mActionBarSubTitle.setVisibility(View.GONE); actionBarSubTitle.setVisibility(View.GONE);
} else { } else {
mActionBarSubTitle.setVisibility(View.VISIBLE); actionBarSubTitle.setVisibility(View.VISIBLE);
mActionBarSubTitle.setText(operation); actionBarSubTitle.setText(operation);
} }
} }
public void refreshTitle() { public void refreshTitle() {
@ -183,8 +183,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
public void dataChanged() { public void dataChanged() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
if (mAdapter != null) { if (adapter != null) {
mAdapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
} }
}); });
@ -213,8 +213,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG); Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
toast.show(); toast.show();
if (mAdapter != null) { if (adapter != null) {
mAdapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
} }
}); });
@ -222,16 +222,16 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
public void progress(final boolean progress) { public void progress(final boolean progress) {
// Make sure we don't try this before the menu is initialized // Make sure we don't try this before the menu is initialized
// this could happen while the activity is initialized. // this could happen while the activity is initialized.
if (mRefreshMenuItem == null) { if (refreshMenuItem == null) {
return; return;
} }
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
if (progress) { if (progress) {
mRefreshMenuItem.setActionView(R.layout.actionbar_indeterminate_progress_actionview); refreshMenuItem.setActionView(R.layout.actionbar_indeterminate_progress_actionview);
} else { } else {
mRefreshMenuItem.setActionView(null); refreshMenuItem.setActionView(null);
} }
} }
}); });
@ -247,13 +247,13 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
} }
public void setProgress(boolean progress) { public void setProgress(boolean progress) {
mHandler.progress(progress); handler.progress(progress);
} }
ActivityListener mListener = new ActivityListener() { ActivityListener mListener = new ActivityListener() {
@Override @Override
public void informUserOfStatus() { public void informUserOfStatus() {
mHandler.refreshTitle(); handler.refreshTitle();
} }
@Override @Override
@ -282,23 +282,23 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
} }
accountStats.put(account.getUuid(), stats); accountStats.put(account.getUuid(), stats);
if (account instanceof Account) { if (account instanceof Account) {
mUnreadMessageCount += stats.unreadMessageCount - oldUnreadMessageCount; unreadMessageCount += stats.unreadMessageCount - oldUnreadMessageCount;
} }
mHandler.dataChanged(); handler.dataChanged();
pendingWork.remove(account); pendingWork.remove(account);
if (pendingWork.isEmpty()) { if (pendingWork.isEmpty()) {
mHandler.progress(Window.PROGRESS_END); handler.progress(Window.PROGRESS_END);
mHandler.refreshTitle(); handler.refreshTitle();
} else { } else {
int level = (Window.PROGRESS_END / mAdapter.getCount()) * (mAdapter.getCount() - pendingWork.size()) ; int level = (Window.PROGRESS_END / adapter.getCount()) * (adapter.getCount() - pendingWork.size()) ;
mHandler.progress(level); handler.progress(level);
} }
} }
@Override @Override
public void accountSizeChanged(Account account, long oldSize, long newSize) { public void accountSizeChanged(Account account, long oldSize, long newSize) {
mHandler.accountSizeChanged(account, oldSize, newSize); handler.accountSizeChanged(account, oldSize, newSize);
} }
@Override @Override
@ -310,21 +310,21 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
MessagingController.getInstance(getApplication()).getAccountStats(Accounts.this, account, mListener); MessagingController.getInstance(getApplication()).getAccountStats(Accounts.this, account, mListener);
super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages); super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages);
mHandler.progress(false); handler.progress(false);
} }
@Override @Override
public void synchronizeMailboxStarted(Account account, String folder) { public void synchronizeMailboxStarted(Account account, String folder) {
super.synchronizeMailboxStarted(account, folder); super.synchronizeMailboxStarted(account, folder);
mHandler.progress(true); handler.progress(true);
} }
@Override @Override
public void synchronizeMailboxFailed(Account account, String folder, public void synchronizeMailboxFailed(Account account, String folder,
String message) { String message) {
super.synchronizeMailboxFailed(account, folder, message); super.synchronizeMailboxFailed(account, folder, message);
mHandler.progress(false); handler.progress(false);
} }
@ -406,7 +406,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true); boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true);
if (startup && K9.startIntegratedInbox() && !K9.isHideSpecialAccounts()) { if (startup && K9.startIntegratedInbox() && !K9.isHideSpecialAccounts()) {
onOpenAccount(mUnifiedInboxAccount); onOpenAccount(unifiedInboxAccount);
finish(); finish();
return; return;
} else if (startup && accounts.size() == 1 && onOpenAccount(accounts.get(0))) { } else if (startup && accounts.size() == 1 && onOpenAccount(accounts.get(0))) {
@ -415,7 +415,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
} }
requestWindowFeature(Window.FEATURE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS);
mActionBar = getActionBar(); actionBar = getActionBar();
initializeActionBar(); initializeActionBar();
setContentView(R.layout.accounts); setContentView(R.layout.accounts);
ListView listView = getListView(); ListView listView = getListView();
@ -427,16 +427,16 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) { if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) {
String accountUuid = icicle.getString("selectedContextAccount"); String accountUuid = icicle.getString("selectedContextAccount");
mSelectedContextAccount = Preferences.getPreferences(this).getAccount(accountUuid); selectedContextAccount = Preferences.getPreferences(this).getAccount(accountUuid);
} }
restoreAccountStats(icicle); restoreAccountStats(icicle);
mHandler.setViewTitle(); handler.setViewTitle();
// Handle activity restarts because of a configuration change (e.g. rotating the screen) // Handle activity restarts because of a configuration change (e.g. rotating the screen)
mNonConfigurationInstance = (NonConfigurationInstance) getLastNonConfigurationInstance(); nonConfigurationInstance = (NonConfigurationInstance) getLastNonConfigurationInstance();
if (mNonConfigurationInstance != null) { if (nonConfigurationInstance != null) {
mNonConfigurationInstance.restore(this); nonConfigurationInstance.restore(this);
} }
ChangeLog cl = new ChangeLog(this); ChangeLog cl = new ChangeLog(this);
@ -446,23 +446,23 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
} }
private void initializeActionBar() { private void initializeActionBar() {
mActionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowCustomEnabled(true);
mActionBar.setCustomView(R.layout.actionbar_custom); actionBar.setCustomView(R.layout.actionbar_custom);
View customView = mActionBar.getCustomView(); View customView = actionBar.getCustomView();
mActionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first); actionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first);
mActionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub); actionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub);
mActionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count); actionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count);
mActionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false);
} }
/** /**
* Creates and initializes the special accounts ('Unified Inbox' and 'All Messages') * Creates and initializes the special accounts ('Unified Inbox' and 'All Messages')
*/ */
private void createSpecialAccounts() { private void createSpecialAccounts() {
mUnifiedInboxAccount = SearchAccount.createUnifiedInboxAccount(this); unifiedInboxAccount = SearchAccount.createUnifiedInboxAccount(this);
mAllMessagesAccount = SearchAccount.createAllMessagesAccount(this); allMessagesAccount = SearchAccount.createAllMessagesAccount(this);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -472,17 +472,17 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
if (oldStats != null) { if (oldStats != null) {
accountStats.putAll(oldStats); accountStats.putAll(oldStats);
} }
mUnreadMessageCount = icicle.getInt(STATE_UNREAD_COUNT); unreadMessageCount = icicle.getInt(STATE_UNREAD_COUNT);
} }
} }
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
if (mSelectedContextAccount != null) { if (selectedContextAccount != null) {
outState.putString(SELECTED_CONTEXT_ACCOUNT, mSelectedContextAccount.getUuid()); outState.putString(SELECTED_CONTEXT_ACCOUNT, selectedContextAccount.getUuid());
} }
outState.putSerializable(STATE_UNREAD_COUNT, mUnreadMessageCount); outState.putSerializable(STATE_UNREAD_COUNT, unreadMessageCount);
outState.putSerializable(ACCOUNT_STATS, accountStats); outState.putSerializable(ACCOUNT_STATS, accountStats);
outState.putBoolean(STATE_EXPORT_GLOBAL_SETTINGS, exportGlobalSettings); outState.putBoolean(STATE_EXPORT_GLOBAL_SETTINGS, exportGlobalSettings);
@ -534,8 +534,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
@Override @Override
public Object onRetainNonConfigurationInstance() { public Object onRetainNonConfigurationInstance() {
Object retain = null; Object retain = null;
if (mNonConfigurationInstance != null && mNonConfigurationInstance.retain()) { if (nonConfigurationInstance != null && nonConfigurationInstance.retain()) {
retain = mNonConfigurationInstance; retain = nonConfigurationInstance;
} }
return retain; return retain;
} }
@ -572,27 +572,27 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
List<BaseAccount> newAccounts; List<BaseAccount> newAccounts;
if (!K9.isHideSpecialAccounts() && accounts.size() > 0) { if (!K9.isHideSpecialAccounts() && accounts.size() > 0) {
if (mUnifiedInboxAccount == null || mAllMessagesAccount == null) { if (unifiedInboxAccount == null || allMessagesAccount == null) {
createSpecialAccounts(); createSpecialAccounts();
} }
newAccounts = new ArrayList<BaseAccount>(accounts.size() + newAccounts = new ArrayList<BaseAccount>(accounts.size() +
SPECIAL_ACCOUNTS_COUNT); SPECIAL_ACCOUNTS_COUNT);
newAccounts.add(mUnifiedInboxAccount); newAccounts.add(unifiedInboxAccount);
newAccounts.add(mAllMessagesAccount); newAccounts.add(allMessagesAccount);
} else { } else {
newAccounts = new ArrayList<BaseAccount>(accounts.size()); newAccounts = new ArrayList<BaseAccount>(accounts.size());
} }
newAccounts.addAll(accounts); newAccounts.addAll(accounts);
mAdapter = new AccountsAdapter(newAccounts); adapter = new AccountsAdapter(newAccounts);
getListView().setAdapter(mAdapter); getListView().setAdapter(adapter);
if (!newAccounts.isEmpty()) { if (!newAccounts.isEmpty()) {
mHandler.progress(Window.PROGRESS_START); handler.progress(Window.PROGRESS_START);
} }
pendingWork.clear(); pendingWork.clear();
mHandler.refreshTitle(); handler.refreshTitle();
MessagingController controller = MessagingController.getInstance(getApplication()); MessagingController controller = MessagingController.getInstance(getApplication());
@ -1037,7 +1037,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
} }
private void onDeleteAccount(Account account) { private void onDeleteAccount(Account account) {
mSelectedContextAccount = account; selectedContextAccount = account;
showDialog(DIALOG_REMOVE_ACCOUNT); showDialog(DIALOG_REMOVE_ACCOUNT);
} }
@ -1051,21 +1051,21 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
// dismissed. Make sure we have all information necessary before creating a new dialog. // dismissed. Make sure we have all information necessary before creating a new dialog.
switch (id) { switch (id) {
case DIALOG_REMOVE_ACCOUNT: { case DIALOG_REMOVE_ACCOUNT: {
if (mSelectedContextAccount == null) { if (selectedContextAccount == null) {
return null; return null;
} }
return ConfirmationDialog.create(this, id, return ConfirmationDialog.create(this, id,
R.string.account_delete_dlg_title, R.string.account_delete_dlg_title,
getString(R.string.account_delete_dlg_instructions_fmt, getString(R.string.account_delete_dlg_instructions_fmt,
mSelectedContextAccount.getDescription()), selectedContextAccount.getDescription()),
R.string.okay_action, R.string.okay_action,
R.string.cancel_action, R.string.cancel_action,
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
if (mSelectedContextAccount instanceof Account) { if (selectedContextAccount instanceof Account) {
Account realAccount = (Account) mSelectedContextAccount; Account realAccount = (Account) selectedContextAccount;
try { try {
realAccount.getLocalStore().delete(); realAccount.getLocalStore().delete();
} catch (Exception e) { } catch (Exception e) {
@ -1083,22 +1083,22 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
}); });
} }
case DIALOG_CLEAR_ACCOUNT: { case DIALOG_CLEAR_ACCOUNT: {
if (mSelectedContextAccount == null) { if (selectedContextAccount == null) {
return null; return null;
} }
return ConfirmationDialog.create(this, id, return ConfirmationDialog.create(this, id,
R.string.account_clear_dlg_title, R.string.account_clear_dlg_title,
getString(R.string.account_clear_dlg_instructions_fmt, getString(R.string.account_clear_dlg_instructions_fmt,
mSelectedContextAccount.getDescription()), selectedContextAccount.getDescription()),
R.string.okay_action, R.string.okay_action,
R.string.cancel_action, R.string.cancel_action,
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
if (mSelectedContextAccount instanceof Account) { if (selectedContextAccount instanceof Account) {
Account realAccount = (Account) mSelectedContextAccount; Account realAccount = (Account) selectedContextAccount;
mHandler.workingAccount(realAccount, handler.workingAccount(realAccount,
R.string.clearing_account); R.string.clearing_account);
MessagingController.getInstance(getApplication()) MessagingController.getInstance(getApplication())
.clear(realAccount, null); .clear(realAccount, null);
@ -1107,22 +1107,22 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
}); });
} }
case DIALOG_RECREATE_ACCOUNT: { case DIALOG_RECREATE_ACCOUNT: {
if (mSelectedContextAccount == null) { if (selectedContextAccount == null) {
return null; return null;
} }
return ConfirmationDialog.create(this, id, return ConfirmationDialog.create(this, id,
R.string.account_recreate_dlg_title, R.string.account_recreate_dlg_title,
getString(R.string.account_recreate_dlg_instructions_fmt, getString(R.string.account_recreate_dlg_instructions_fmt,
mSelectedContextAccount.getDescription()), selectedContextAccount.getDescription()),
R.string.okay_action, R.string.okay_action,
R.string.cancel_action, R.string.cancel_action,
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
if (mSelectedContextAccount instanceof Account) { if (selectedContextAccount instanceof Account) {
Account realAccount = (Account) mSelectedContextAccount; Account realAccount = (Account) selectedContextAccount;
mHandler.workingAccount(realAccount, handler.workingAccount(realAccount,
R.string.recreating_account); R.string.recreating_account);
MessagingController.getInstance(getApplication()) MessagingController.getInstance(getApplication())
.recreate(realAccount, null); .recreate(realAccount, null);
@ -1156,17 +1156,17 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
switch (id) { switch (id) {
case DIALOG_REMOVE_ACCOUNT: { case DIALOG_REMOVE_ACCOUNT: {
alert.setMessage(getString(R.string.account_delete_dlg_instructions_fmt, alert.setMessage(getString(R.string.account_delete_dlg_instructions_fmt,
mSelectedContextAccount.getDescription())); selectedContextAccount.getDescription()));
break; break;
} }
case DIALOG_CLEAR_ACCOUNT: { case DIALOG_CLEAR_ACCOUNT: {
alert.setMessage(getString(R.string.account_clear_dlg_instructions_fmt, alert.setMessage(getString(R.string.account_clear_dlg_instructions_fmt,
mSelectedContextAccount.getDescription())); selectedContextAccount.getDescription()));
break; break;
} }
case DIALOG_RECREATE_ACCOUNT: { case DIALOG_RECREATE_ACCOUNT: {
alert.setMessage(getString(R.string.account_recreate_dlg_instructions_fmt, alert.setMessage(getString(R.string.account_recreate_dlg_instructions_fmt,
mSelectedContextAccount.getDescription())); selectedContextAccount.getDescription()));
break; break;
} }
} }
@ -1180,10 +1180,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
// submenus don't actually set the menuInfo, so the "advanced" // submenus don't actually set the menuInfo, so the "advanced"
// submenu wouldn't work. // submenu wouldn't work.
if (menuInfo != null) { if (menuInfo != null) {
mSelectedContextAccount = (BaseAccount)getListView().getItemAtPosition(menuInfo.position); selectedContextAccount = (BaseAccount)getListView().getItemAtPosition(menuInfo.position);
} }
if (mSelectedContextAccount instanceof Account) { if (selectedContextAccount instanceof Account) {
Account realAccount = (Account)mSelectedContextAccount; Account realAccount = (Account) selectedContextAccount;
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.delete_account: case R.id.delete_account:
onDeleteAccount(realAccount); onDeleteAccount(realAccount);
@ -1377,7 +1377,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.accounts_option, menu); getMenuInflater().inflate(R.menu.accounts_option, menu);
mRefreshMenuItem = menu.findItem(R.id.check_mail); refreshMenuItem = menu.findItem(R.id.check_mail);
return true; return true;
} }
@ -1387,7 +1387,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
menu.setHeaderTitle(R.string.accounts_context_menu_title); menu.setHeaderTitle(R.string.accounts_context_menu_title);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
BaseAccount account = mAdapter.getItem(info.position); BaseAccount account = adapter.getItem(info.position);
if ((account instanceof Account) && !((Account) account).isEnabled()) { if ((account instanceof Account) && !((Account) account).isEnabled()) {
getMenuInflater().inflate(R.menu.disabled_accounts_context, menu); getMenuInflater().inflate(R.menu.disabled_accounts_context, menu);
@ -1743,7 +1743,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
* {@link Accounts#onRetainNonConfigurationInstance()} is called. * {@link Accounts#onRetainNonConfigurationInstance()} is called.
*/ */
private void setNonConfigurationInstance(NonConfigurationInstance inst) { private void setNonConfigurationInstance(NonConfigurationInstance inst) {
mNonConfigurationInstance = inst; nonConfigurationInstance = inst;
} }
class AccountsAdapter extends ArrayAdapter<BaseAccount> { class AccountsAdapter extends ArrayAdapter<BaseAccount> {
@ -1841,8 +1841,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
mFontSizes.setViewTextSize(holder.description, mFontSizes.getAccountName()); fontSizes.setViewTextSize(holder.description, fontSizes.getAccountName());
mFontSizes.setViewTextSize(holder.email, mFontSizes.getAccountDescription()); fontSizes.setViewTextSize(holder.email, fontSizes.getAccountDescription());
if (account instanceof SearchAccount) { if (account instanceof SearchAccount) {
holder.folders.setVisibility(View.GONE); holder.folders.setVisibility(View.GONE);

View file

@ -78,48 +78,48 @@ public class FolderList extends K9ListActivity {
private static final boolean REFRESH_REMOTE = true; private static final boolean REFRESH_REMOTE = true;
private ListView mListView; private ListView listView;
private FolderListAdapter mAdapter; private FolderListAdapter adapter;
private LayoutInflater mInflater; private LayoutInflater inflater;
private Account mAccount; private Account account;
private FolderListHandler mHandler = new FolderListHandler(); private FolderListHandler handler = new FolderListHandler();
private int mUnreadMessageCount; private int unreadMessageCount;
private FontSizes mFontSizes = K9.getFontSizes(); private FontSizes fontSizes = K9.getFontSizes();
private Context context; private Context context;
private MenuItem mRefreshMenuItem; private MenuItem refreshMenuItem;
private View mActionBarProgressView; private View actionBarProgressView;
private ActionBar mActionBar; private ActionBar actionBar;
private TextView mActionBarTitle; private TextView actionBarTitle;
private TextView mActionBarSubTitle; private TextView actionBarSubTitle;
private TextView mActionBarUnread; private TextView actionBarUnread;
class FolderListHandler extends Handler { class FolderListHandler extends Handler {
public void refreshTitle() { public void refreshTitle() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
mActionBarTitle.setText(getString(R.string.folders_title)); actionBarTitle.setText(getString(R.string.folders_title));
if (mUnreadMessageCount == 0) { if (unreadMessageCount == 0) {
mActionBarUnread.setVisibility(View.GONE); actionBarUnread.setVisibility(View.GONE);
} else { } else {
mActionBarUnread.setText(String.format("%d", mUnreadMessageCount)); actionBarUnread.setText(String.format("%d", unreadMessageCount));
mActionBarUnread.setVisibility(View.VISIBLE); actionBarUnread.setVisibility(View.VISIBLE);
} }
String operation = mAdapter.mListener.getOperation(FolderList.this); String operation = adapter.mListener.getOperation(FolderList.this);
if (operation.length() < 1) { if (operation.length() < 1) {
mActionBarSubTitle.setText(mAccount.getEmail()); actionBarSubTitle.setText(account.getEmail());
} else { } else {
mActionBarSubTitle.setText(operation); actionBarSubTitle.setText(operation);
} }
} }
}); });
@ -129,10 +129,10 @@ public class FolderList extends K9ListActivity {
public void newFolders(final List<FolderInfoHolder> newFolders) { public void newFolders(final List<FolderInfoHolder> newFolders) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
mAdapter.mFolders.clear(); adapter.mFolders.clear();
mAdapter.mFolders.addAll(newFolders); adapter.mFolders.addAll(newFolders);
mAdapter.mFilteredFolders = mAdapter.mFolders; adapter.mFilteredFolders = adapter.mFolders;
mHandler.dataChanged(); handler.dataChanged();
} }
}); });
} }
@ -140,7 +140,7 @@ public class FolderList extends K9ListActivity {
public void workingAccount(final int res) { public void workingAccount(final int res) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
String toastText = getString(res, mAccount.getDescription()); String toastText = getString(res, account.getDescription());
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_SHORT); Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
@ -150,7 +150,7 @@ public class FolderList extends K9ListActivity {
public void accountSizeChanged(final long oldSize, final long newSize) { public void accountSizeChanged(final long oldSize, final long newSize) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
String toastText = getString(R.string.account_size_changed, mAccount.getDescription(), SizeFormatter.formatSize(getApplication(), oldSize), SizeFormatter.formatSize(getApplication(), newSize)); String toastText = getString(R.string.account_size_changed, account.getDescription(), SizeFormatter.formatSize(getApplication(), oldSize), SizeFormatter.formatSize(getApplication(), newSize));
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG); Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
toast.show(); toast.show();
@ -161,7 +161,7 @@ public class FolderList extends K9ListActivity {
public void folderLoading(final String folder, final boolean loading) { public void folderLoading(final String folder, final boolean loading) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
FolderInfoHolder folderHolder = mAdapter.getFolder(folder); FolderInfoHolder folderHolder = adapter.getFolder(folder);
if (folderHolder != null) { if (folderHolder != null) {
@ -175,16 +175,16 @@ public class FolderList extends K9ListActivity {
public void progress(final boolean progress) { public void progress(final boolean progress) {
// Make sure we don't try this before the menu is initialized // Make sure we don't try this before the menu is initialized
// this could happen while the activity is initialized. // this could happen while the activity is initialized.
if (mRefreshMenuItem == null) { if (refreshMenuItem == null) {
return; return;
} }
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
if (progress) { if (progress) {
mRefreshMenuItem.setActionView(mActionBarProgressView); refreshMenuItem.setActionView(actionBarProgressView);
} else { } else {
mRefreshMenuItem.setActionView(null); refreshMenuItem.setActionView(null);
} }
} }
}); });
@ -194,7 +194,7 @@ public class FolderList extends K9ListActivity {
public void dataChanged() { public void dataChanged() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
mAdapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });
} }
@ -214,7 +214,7 @@ public class FolderList extends K9ListActivity {
MessagingListener listener = new SimpleMessagingListener() { MessagingListener listener = new SimpleMessagingListener() {
@Override @Override
public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages) { public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages) {
if (!account.equals(mAccount)) { if (!account.equals(FolderList.this.account)) {
return; return;
} }
wakeLock.release(); wakeLock.release();
@ -223,14 +223,14 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void synchronizeMailboxFailed(Account account, String folder, public void synchronizeMailboxFailed(Account account, String folder,
String message) { String message) {
if (!account.equals(mAccount)) { if (!account.equals(FolderList.this.account)) {
return; return;
} }
wakeLock.release(); wakeLock.release();
} }
}; };
MessagingController.getInstance(getApplication()).synchronizeMailbox(mAccount, folder.name, listener, null); MessagingController.getInstance(getApplication()).synchronizeMailbox(account, folder.name, listener, null);
sendMail(mAccount); sendMail(account);
} }
public static Intent actionHandleAccountIntent(Context context, Account account, boolean fromShortcut) { public static Intent actionHandleAccountIntent(Context context, Account account, boolean fromShortcut) {
@ -259,25 +259,25 @@ public class FolderList extends K9ListActivity {
return; return;
} }
mActionBarProgressView = getActionBarProgressView(); actionBarProgressView = getActionBarProgressView();
mActionBar = getActionBar(); actionBar = getActionBar();
initializeActionBar(); initializeActionBar();
setContentView(R.layout.folder_list); setContentView(R.layout.folder_list);
mListView = getListView(); listView = getListView();
mListView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); listView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mListView.setLongClickable(true); listView.setLongClickable(true);
mListView.setFastScrollEnabled(true); listView.setFastScrollEnabled(true);
mListView.setScrollingCacheEnabled(false); listView.setScrollingCacheEnabled(false);
mListView.setOnItemClickListener(new OnItemClickListener() { listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onOpenFolder(((FolderInfoHolder)mAdapter.getItem(position)).name); onOpenFolder(((FolderInfoHolder) adapter.getItem(position)).name);
} }
}); });
registerForContextMenu(mListView); registerForContextMenu(listView);
mListView.setSaveEnabled(true); listView.setSaveEnabled(true);
mInflater = getLayoutInflater(); inflater = getLayoutInflater();
context = this; context = this;
@ -303,26 +303,26 @@ public class FolderList extends K9ListActivity {
} }
private void initializeActionBar() { private void initializeActionBar() {
mActionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowCustomEnabled(true);
mActionBar.setCustomView(R.layout.actionbar_custom); actionBar.setCustomView(R.layout.actionbar_custom);
View customView = mActionBar.getCustomView(); View customView = actionBar.getCustomView();
mActionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first); actionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first);
mActionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub); actionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub);
mActionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count); actionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count);
mActionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
setIntent(intent); // onNewIntent doesn't autoset our "internal" intent setIntent(intent); // onNewIntent doesn't autoset our "internal" intent
mUnreadMessageCount = 0; unreadMessageCount = 0;
String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT); String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT);
mAccount = Preferences.getPreferences(this).getAccount(accountUuid); account = Preferences.getPreferences(this).getAccount(accountUuid);
if (mAccount == null) { if (account == null) {
/* /*
* This can happen when a launcher shortcut is created for an * This can happen when a launcher shortcut is created for an
* account, and then the account is deleted or data is wiped, and * account, and then the account is deleted or data is wiped, and
@ -333,8 +333,8 @@ public class FolderList extends K9ListActivity {
} }
if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false) && if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false) &&
!K9.FOLDER_NONE.equals(mAccount.getAutoExpandFolderName())) { !K9.FOLDER_NONE.equals(account.getAutoExpandFolderName())) {
onOpenFolder(mAccount.getAutoExpandFolderName()); onOpenFolder(account.getAutoExpandFolderName());
finish(); finish();
} else { } else {
initializeActivityView(); initializeActivityView();
@ -342,11 +342,11 @@ public class FolderList extends K9ListActivity {
} }
private void initializeActivityView() { private void initializeActivityView() {
mAdapter = new FolderListAdapter(); adapter = new FolderListAdapter();
restorePreviousData(); restorePreviousData();
setListAdapter(mAdapter); setListAdapter(adapter);
getListView().setTextFilterEnabled(mAdapter.getFilter() != null); // should never be false but better safe then sorry getListView().setTextFilterEnabled(adapter.getFilter() != null); // should never be false but better safe then sorry
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -354,20 +354,20 @@ public class FolderList extends K9ListActivity {
final Object previousData = getLastNonConfigurationInstance(); final Object previousData = getLastNonConfigurationInstance();
if (previousData != null) { if (previousData != null) {
mAdapter.mFolders = (ArrayList<FolderInfoHolder>) previousData; adapter.mFolders = (ArrayList<FolderInfoHolder>) previousData;
mAdapter.mFilteredFolders = Collections.unmodifiableList(mAdapter.mFolders); adapter.mFilteredFolders = Collections.unmodifiableList(adapter.mFolders);
} }
} }
@Override public Object onRetainNonConfigurationInstance() { @Override public Object onRetainNonConfigurationInstance() {
return (mAdapter == null) ? null : mAdapter.mFolders; return (adapter == null) ? null : adapter.mFolders;
} }
@Override public void onPause() { @Override public void onPause() {
super.onPause(); super.onPause();
MessagingController.getInstance(getApplication()).removeListener(mAdapter.mListener); MessagingController.getInstance(getApplication()).removeListener(adapter.mListener);
mAdapter.mListener.onPause(this); adapter.mListener.onPause(this);
} }
/** /**
@ -378,25 +378,25 @@ public class FolderList extends K9ListActivity {
@Override public void onResume() { @Override public void onResume() {
super.onResume(); super.onResume();
if (!mAccount.isAvailable(this)) { if (!account.isAvailable(this)) {
Timber.i("account unavaliabale, not showing folder-list but account-list"); Timber.i("account unavaliabale, not showing folder-list but account-list");
Accounts.listAccounts(this); Accounts.listAccounts(this);
finish(); finish();
return; return;
} }
if (mAdapter == null) if (adapter == null)
initializeActivityView(); initializeActivityView();
mHandler.refreshTitle(); handler.refreshTitle();
MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener); MessagingController.getInstance(getApplication()).addListener(adapter.mListener);
//mAccount.refresh(Preferences.getPreferences(this)); //account.refresh(Preferences.getPreferences(this));
MessagingController.getInstance(getApplication()).getAccountStats(this, mAccount, mAdapter.mListener); MessagingController.getInstance(getApplication()).getAccountStats(this, account, adapter.mListener);
onRefresh(!REFRESH_REMOTE); onRefresh(!REFRESH_REMOTE);
MessagingController.getInstance(getApplication()).cancelNotificationsForAccount(mAccount); MessagingController.getInstance(getApplication()).cancelNotificationsForAccount(account);
mAdapter.mListener.onResume(this); adapter.mListener.onResume(this);
} }
@Override @Override
@ -442,19 +442,19 @@ public class FolderList extends K9ListActivity {
}//onKeyDown }//onKeyDown
private void setDisplayMode(FolderMode newMode) { private void setDisplayMode(FolderMode newMode) {
mAccount.setFolderDisplayMode(newMode); account.setFolderDisplayMode(newMode);
mAccount.save(Preferences.getPreferences(this)); account.save(Preferences.getPreferences(this));
if (mAccount.getFolderPushMode() != FolderMode.NONE) { if (account.getFolderPushMode() != FolderMode.NONE) {
MailService.actionRestartPushers(this, null); MailService.actionRestartPushers(this, null);
} }
mAdapter.getFilter().filter(null); adapter.getFilter().filter(null);
onRefresh(false); onRefresh(false);
} }
private void onRefresh(final boolean forceRemote) { private void onRefresh(final boolean forceRemote) {
MessagingController.getInstance(getApplication()).listFolders(mAccount, forceRemote, mAdapter.mListener); MessagingController.getInstance(getApplication()).listFolders(account, forceRemote, adapter.mListener);
} }
@ -462,7 +462,7 @@ public class FolderList extends K9ListActivity {
Prefs.actionPrefs(this); Prefs.actionPrefs(this);
} }
private void onEditAccount() { private void onEditAccount() {
AccountSettings.actionSettings(this, mAccount); AccountSettings.actionSettings(this, account);
} }
private void onAccounts() { private void onAccounts() {
@ -471,17 +471,17 @@ public class FolderList extends K9ListActivity {
} }
private void onEmptyTrash(final Account account) { private void onEmptyTrash(final Account account) {
mHandler.dataChanged(); handler.dataChanged();
MessagingController.getInstance(getApplication()).emptyTrash(account, null); MessagingController.getInstance(getApplication()).emptyTrash(account, null);
} }
private void onClearFolder(Account account, String folderName) { private void onClearFolder(Account account, String folderName) {
MessagingController.getInstance(getApplication()).clearFolder(account, folderName, mAdapter.mListener); MessagingController.getInstance(getApplication()).clearFolder(account, folderName, adapter.mListener);
} }
private void sendMail(Account account) { private void sendMail(Account account) {
MessagingController.getInstance(getApplication()).sendPendingMessages(account, mAdapter.mListener); MessagingController.getInstance(getApplication()).sendPendingMessages(account, adapter.mListener);
} }
@Override public boolean onOptionsItemSelected(MenuItem item) { @Override public boolean onOptionsItemSelected(MenuItem item) {
@ -497,17 +497,17 @@ public class FolderList extends K9ListActivity {
return true; return true;
case R.id.compose: case R.id.compose:
MessageActions.actionCompose(this, mAccount); MessageActions.actionCompose(this, account);
return true; return true;
case R.id.check_mail: case R.id.check_mail:
MessagingController.getInstance(getApplication()).checkMail(this, mAccount, true, true, mAdapter.mListener); MessagingController.getInstance(getApplication()).checkMail(this, account, true, true, adapter.mListener);
return true; return true;
case R.id.send_messages: case R.id.send_messages:
MessagingController.getInstance(getApplication()).sendPendingMessages(mAccount, null); MessagingController.getInstance(getApplication()).sendPendingMessages(account, null);
return true; return true;
@ -527,12 +527,12 @@ public class FolderList extends K9ListActivity {
return true; return true;
case R.id.empty_trash: case R.id.empty_trash:
onEmptyTrash(mAccount); onEmptyTrash(account);
return true; return true;
case R.id.compact: case R.id.compact:
onCompact(mAccount); onCompact(account);
return true; return true;
@ -560,27 +560,27 @@ public class FolderList extends K9ListActivity {
@Override @Override
public boolean onSearchRequested() { public boolean onSearchRequested() {
Bundle appData = new Bundle(); Bundle appData = new Bundle();
appData.putString(MessageList.EXTRA_SEARCH_ACCOUNT, mAccount.getUuid()); appData.putString(MessageList.EXTRA_SEARCH_ACCOUNT, account.getUuid());
startSearch(null, false, appData, false); startSearch(null, false, appData, false);
return true; return true;
} }
private void onOpenFolder(String folder) { private void onOpenFolder(String folder) {
LocalSearch search = new LocalSearch(folder); LocalSearch search = new LocalSearch(folder);
search.addAccountUuid(mAccount.getUuid()); search.addAccountUuid(account.getUuid());
search.addAllowedFolder(folder); search.addAllowedFolder(folder);
MessageList.actionDisplaySearch(this, search, false, false); MessageList.actionDisplaySearch(this, search, false, false);
} }
private void onCompact(Account account) { private void onCompact(Account account) {
mHandler.workingAccount(R.string.compacting_account); handler.workingAccount(R.string.compacting_account);
MessagingController.getInstance(getApplication()).compact(account, null); MessagingController.getInstance(getApplication()).compact(account, null);
} }
@Override public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.folder_list_option, menu); getMenuInflater().inflate(R.menu.folder_list_option, menu);
mRefreshMenuItem = menu.findItem(R.id.check_mail); refreshMenuItem = menu.findItem(R.id.check_mail);
configureFolderSearchView(menu); configureFolderSearchView(menu);
return true; return true;
} }
@ -594,13 +594,13 @@ public class FolderList extends K9ListActivity {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {
folderMenuItem.collapseActionView(); folderMenuItem.collapseActionView();
mActionBarTitle.setText(getString(R.string.filter_folders_action)); actionBarTitle.setText(getString(R.string.filter_folders_action));
return true; return true;
} }
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
mAdapter.getFilter().filter(newText); adapter.getFilter().filter(newText);
return true; return true;
} }
}); });
@ -609,7 +609,7 @@ public class FolderList extends K9ListActivity {
@Override @Override
public boolean onClose() { public boolean onClose() {
mActionBarTitle.setText(getString(R.string.folders_title)); actionBarTitle.setText(getString(R.string.folders_title));
return false; return false;
} }
}); });
@ -617,17 +617,17 @@ public class FolderList extends K9ListActivity {
@Override public boolean onContextItemSelected(android.view.MenuItem item) { @Override public boolean onContextItemSelected(android.view.MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo(); AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo();
FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position); FolderInfoHolder folder = (FolderInfoHolder) adapter.getItem(info.position);
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.clear_local_folder: case R.id.clear_local_folder:
onClearFolder(mAccount, folder.name); onClearFolder(account, folder.name);
break; break;
case R.id.refresh_folder: case R.id.refresh_folder:
checkMail(folder); checkMail(folder);
break; break;
case R.id.folder_settings: case R.id.folder_settings:
FolderSettings.actionSettings(this, mAccount, folder.name); FolderSettings.actionSettings(this, account, folder.name);
break; break;
} }
@ -639,7 +639,7 @@ public class FolderList extends K9ListActivity {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
getMenuInflater().inflate(R.menu.folder_context, menu); getMenuInflater().inflate(R.menu.folder_context, menu);
FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position); FolderInfoHolder folder = (FolderInfoHolder) adapter.getItem(info.position);
menu.setHeaderTitle(folder.displayName); menu.setHeaderTitle(folder.displayName);
} }
@ -679,25 +679,25 @@ public class FolderList extends K9ListActivity {
private ActivityListener mListener = new ActivityListener() { private ActivityListener mListener = new ActivityListener() {
@Override @Override
public void informUserOfStatus() { public void informUserOfStatus() {
mHandler.refreshTitle(); handler.refreshTitle();
mHandler.dataChanged(); handler.dataChanged();
} }
@Override @Override
public void accountStatusChanged(BaseAccount account, AccountStats stats) { public void accountStatusChanged(BaseAccount account, AccountStats stats) {
if (!account.equals(mAccount)) { if (!account.equals(FolderList.this.account)) {
return; return;
} }
if (stats == null) { if (stats == null) {
return; return;
} }
mUnreadMessageCount = stats.unreadMessageCount; unreadMessageCount = stats.unreadMessageCount;
mHandler.refreshTitle(); handler.refreshTitle();
} }
@Override @Override
public void listFoldersStarted(Account account) { public void listFoldersStarted(Account account) {
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
mHandler.progress(true); handler.progress(true);
} }
super.listFoldersStarted(account); super.listFoldersStarted(account);
@ -705,8 +705,8 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void listFoldersFailed(Account account, String message) { public void listFoldersFailed(Account account, String message) {
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
mHandler.progress(false); handler.progress(false);
Toast.makeText(context, R.string.fetching_folders_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(context, R.string.fetching_folders_failed, Toast.LENGTH_SHORT).show();
} }
super.listFoldersFailed(account, message); super.listFoldersFailed(account, message);
@ -714,11 +714,11 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void listFoldersFinished(Account account) { public void listFoldersFinished(Account account) {
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
mHandler.progress(false); handler.progress(false);
MessagingController.getInstance(getApplication()).refreshListener(mAdapter.mListener); MessagingController.getInstance(getApplication()).refreshListener(adapter.mListener);
mHandler.dataChanged(); handler.dataChanged();
} }
super.listFoldersFinished(account); super.listFoldersFinished(account);
@ -726,7 +726,7 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void listFolders(Account account, List<LocalFolder> folders) { public void listFolders(Account account, List<LocalFolder> folders) {
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
List<FolderInfoHolder> newFolders = new LinkedList<FolderInfoHolder>(); List<FolderInfoHolder> newFolders = new LinkedList<FolderInfoHolder>();
List<FolderInfoHolder> topFolders = new LinkedList<FolderInfoHolder>(); List<FolderInfoHolder> topFolders = new LinkedList<FolderInfoHolder>();
@ -751,9 +751,9 @@ public class FolderList extends K9ListActivity {
} }
if (holder == null) { if (holder == null) {
holder = new FolderInfoHolder(context, folder, mAccount, -1); holder = new FolderInfoHolder(context, folder, FolderList.this.account, -1);
} else { } else {
holder.populate(context, folder, mAccount, -1); holder.populate(context, folder, FolderList.this.account, -1);
} }
if (folder.isInTopGroup()) { if (folder.isInTopGroup()) {
@ -765,7 +765,7 @@ public class FolderList extends K9ListActivity {
Collections.sort(newFolders); Collections.sort(newFolders);
Collections.sort(topFolders); Collections.sort(topFolders);
topFolders.addAll(newFolders); topFolders.addAll(newFolders);
mHandler.newFolders(topFolders); handler.newFolders(topFolders);
} }
super.listFolders(account, folders); super.listFolders(account, folders);
} }
@ -773,11 +773,11 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void synchronizeMailboxStarted(Account account, String folder) { public void synchronizeMailboxStarted(Account account, String folder) {
super.synchronizeMailboxStarted(account, folder); super.synchronizeMailboxStarted(account, folder);
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
mHandler.progress(true); handler.progress(true);
mHandler.folderLoading(folder, true); handler.folderLoading(folder, true);
mHandler.dataChanged(); handler.dataChanged();
} }
} }
@ -785,9 +785,9 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages) { public void synchronizeMailboxFinished(Account account, String folder, int totalMessagesInMailbox, int numNewMessages) {
super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages); super.synchronizeMailboxFinished(account, folder, totalMessagesInMailbox, numNewMessages);
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
mHandler.progress(false); handler.progress(false);
mHandler.folderLoading(folder, false); handler.folderLoading(folder, false);
refreshFolder(account, folder); refreshFolder(account, folder);
} }
@ -806,10 +806,10 @@ public class FolderList extends K9ListActivity {
localFolder = account.getLocalStore().getFolder(folderName); localFolder = account.getLocalStore().getFolder(folderName);
FolderInfoHolder folderHolder = getFolder(folderName); FolderInfoHolder folderHolder = getFolder(folderName);
if (folderHolder != null) { if (folderHolder != null) {
folderHolder.populate(context, localFolder, mAccount, -1); folderHolder.populate(context, localFolder, FolderList.this.account, -1);
folderHolder.flaggedMessageCount = -1; folderHolder.flaggedMessageCount = -1;
mHandler.dataChanged(); handler.dataChanged();
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -825,31 +825,31 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void synchronizeMailboxFailed(Account account, String folder, String message) { public void synchronizeMailboxFailed(Account account, String folder, String message) {
super.synchronizeMailboxFailed(account, folder, message); super.synchronizeMailboxFailed(account, folder, message);
if (!account.equals(mAccount)) { if (!account.equals(FolderList.this.account)) {
return; return;
} }
mHandler.progress(false); handler.progress(false);
mHandler.folderLoading(folder, false); handler.folderLoading(folder, false);
// String mess = truncateStatus(message); // String mess = truncateStatus(message);
// mHandler.folderStatus(folder, mess); // handler.folderStatus(folder, mess);
FolderInfoHolder holder = getFolder(folder); FolderInfoHolder holder = getFolder(folder);
if (holder != null) { if (holder != null) {
holder.lastChecked = 0; holder.lastChecked = 0;
} }
mHandler.dataChanged(); handler.dataChanged();
} }
@Override @Override
public void setPushActive(Account account, String folderName, boolean enabled) { public void setPushActive(Account account, String folderName, boolean enabled) {
if (!account.equals(mAccount)) { if (!account.equals(FolderList.this.account)) {
return; return;
} }
FolderInfoHolder holder = getFolder(folderName); FolderInfoHolder holder = getFolder(folderName);
@ -857,7 +857,7 @@ public class FolderList extends K9ListActivity {
if (holder != null) { if (holder != null) {
holder.pushActive = enabled; holder.pushActive = enabled;
mHandler.dataChanged(); handler.dataChanged();
} }
} }
@ -869,14 +869,14 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void emptyTrashCompleted(Account account) { public void emptyTrashCompleted(Account account) {
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
refreshFolder(account, mAccount.getTrashFolderName()); refreshFolder(account, FolderList.this.account.getTrashFolderName());
} }
} }
@Override @Override
public void folderStatusChanged(Account account, String folderName, int unreadMessageCount) { public void folderStatusChanged(Account account, String folderName, int unreadMessageCount) {
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
refreshFolder(account, folderName); refreshFolder(account, folderName);
informUserOfStatus(); informUserOfStatus();
} }
@ -885,8 +885,8 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void sendPendingMessagesCompleted(Account account) { public void sendPendingMessagesCompleted(Account account) {
super.sendPendingMessagesCompleted(account); super.sendPendingMessagesCompleted(account);
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
refreshFolder(account, mAccount.getOutboxFolderName()); refreshFolder(account, FolderList.this.account.getOutboxFolderName());
} }
} }
@ -894,23 +894,23 @@ public class FolderList extends K9ListActivity {
public void sendPendingMessagesStarted(Account account) { public void sendPendingMessagesStarted(Account account) {
super.sendPendingMessagesStarted(account); super.sendPendingMessagesStarted(account);
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
mHandler.dataChanged(); handler.dataChanged();
} }
} }
@Override @Override
public void sendPendingMessagesFailed(Account account) { public void sendPendingMessagesFailed(Account account) {
super.sendPendingMessagesFailed(account); super.sendPendingMessagesFailed(account);
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
refreshFolder(account, mAccount.getOutboxFolderName()); refreshFolder(account, FolderList.this.account.getOutboxFolderName());
} }
} }
@Override @Override
public void accountSizeChanged(Account account, long oldSize, long newSize) { public void accountSizeChanged(Account account, long oldSize, long newSize) {
if (account.equals(mAccount)) { if (account.equals(FolderList.this.account)) {
mHandler.accountSizeChanged(oldSize, newSize); handler.accountSizeChanged(oldSize, newSize);
} }
} }
}; };
@ -950,7 +950,7 @@ public class FolderList extends K9ListActivity {
if (convertView != null) { if (convertView != null) {
view = convertView; view = convertView;
} else { } else {
view = mInflater.inflate(R.layout.folder_list_item, parent, false); view = inflater.inflate(R.layout.folder_list_item, parent, false);
} }
FolderViewHolder holder = (FolderViewHolder) view.getTag(); FolderViewHolder holder = (FolderViewHolder) view.getTag();
@ -1018,16 +1018,16 @@ public class FolderList extends K9ListActivity {
try { try {
folder.unreadMessageCount = folder.folder.getUnreadMessageCount(); folder.unreadMessageCount = folder.folder.getUnreadMessageCount();
} catch (Exception e) { } catch (Exception e) {
Timber.e("Unable to get unreadMessageCount for %s:%s", mAccount.getDescription(), folder.name); Timber.e("Unable to get unreadMessageCount for %s:%s", account.getDescription(), folder.name);
} }
} }
if (folder.unreadMessageCount > 0) { if (folder.unreadMessageCount > 0) {
holder.newMessageCount.setText(String.format("%d", folder.unreadMessageCount)); holder.newMessageCount.setText(String.format("%d", folder.unreadMessageCount));
holder.newMessageCountWrapper.setOnClickListener( holder.newMessageCountWrapper.setOnClickListener(
createUnreadSearch(mAccount, folder)); createUnreadSearch(account, folder));
holder.newMessageCountWrapper.setVisibility(View.VISIBLE); holder.newMessageCountWrapper.setVisibility(View.VISIBLE);
holder.newMessageCountIcon.setBackgroundDrawable( holder.newMessageCountIcon.setBackgroundDrawable(
mAccount.generateColorChip(false, false).drawable()); account.generateColorChip(false, false).drawable());
} else { } else {
holder.newMessageCountWrapper.setVisibility(View.GONE); holder.newMessageCountWrapper.setVisibility(View.GONE);
} }
@ -1037,17 +1037,17 @@ public class FolderList extends K9ListActivity {
try { try {
folder.flaggedMessageCount = folder.folder.getFlaggedMessageCount(); folder.flaggedMessageCount = folder.folder.getFlaggedMessageCount();
} catch (Exception e) { } catch (Exception e) {
Timber.e("Unable to get flaggedMessageCount for %s:%s", mAccount.getDescription(), folder.name); Timber.e("Unable to get flaggedMessageCount for %s:%s", account.getDescription(), folder.name);
} }
} }
if (K9.messageListStars() && folder.flaggedMessageCount > 0) { if (K9.messageListStars() && folder.flaggedMessageCount > 0) {
holder.flaggedMessageCount.setText(String.format("%d", folder.flaggedMessageCount)); holder.flaggedMessageCount.setText(String.format("%d", folder.flaggedMessageCount));
holder.flaggedMessageCountWrapper.setOnClickListener( holder.flaggedMessageCountWrapper.setOnClickListener(
createFlaggedSearch(mAccount, folder)); createFlaggedSearch(account, folder));
holder.flaggedMessageCountWrapper.setVisibility(View.VISIBLE); holder.flaggedMessageCountWrapper.setVisibility(View.VISIBLE);
holder.flaggedMessageCountIcon.setBackgroundDrawable( holder.flaggedMessageCountIcon.setBackgroundDrawable(
mAccount.generateColorChip(false, true).drawable()); account.generateColorChip(false, true).drawable());
} else { } else {
holder.flaggedMessageCountWrapper.setVisibility(View.GONE); holder.flaggedMessageCountWrapper.setVisibility(View.GONE);
} }
@ -1059,10 +1059,10 @@ public class FolderList extends K9ListActivity {
} }
}); });
holder.chip.setBackgroundColor(mAccount.getChipColor()); holder.chip.setBackgroundColor(account.getChipColor());
mFontSizes.setViewTextSize(holder.folderName, mFontSizes.getFolderName()); fontSizes.setViewTextSize(holder.folderName, fontSizes.getFolderName());
if (K9.wrapFolderNames()) { if (K9.wrapFolderNames()) {
holder.folderName.setEllipsize(null); holder.folderName.setEllipsize(null);
@ -1072,7 +1072,7 @@ public class FolderList extends K9ListActivity {
holder.folderName.setEllipsize(TruncateAt.START); holder.folderName.setEllipsize(TruncateAt.START);
holder.folderName.setSingleLine(true); holder.folderName.setSingleLine(true);
} }
mFontSizes.setViewTextSize(holder.folderStatus, mFontSizes.getFolderStatus()); fontSizes.setViewTextSize(holder.folderStatus, fontSizes.getFolderStatus());
return view; return view;
} }

View file

@ -14,17 +14,17 @@ import com.fsck.k9.activity.misc.SwipeGestureDetector.OnSwipeGestureListener;
public abstract class K9ListActivity extends ListActivity implements K9ActivityMagic { public abstract class K9ListActivity extends ListActivity implements K9ActivityMagic {
private K9ActivityCommon mBase; private K9ActivityCommon base;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
mBase = K9ActivityCommon.newInstance(this); base = K9ActivityCommon.newInstance(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@Override @Override
public boolean dispatchTouchEvent(MotionEvent event) { public boolean dispatchTouchEvent(MotionEvent event) {
mBase.preDispatchTouchEvent(event); base.preDispatchTouchEvent(event);
return super.dispatchTouchEvent(event); return super.dispatchTouchEvent(event);
} }
@ -35,7 +35,7 @@ public abstract class K9ListActivity extends ListActivity implements K9ActivityM
@Override @Override
public void setupGestureDetector(OnSwipeGestureListener listener) { public void setupGestureDetector(OnSwipeGestureListener listener) {
mBase.setupGestureDetector(listener); base.setupGestureDetector(listener);
} }
@Override @Override

File diff suppressed because it is too large Load diff