Improve code style in several Activity classes

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

View file

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

View file

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

File diff suppressed because it is too large Load diff