mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Formatting of Accounts.java
This commit is contained in:
parent
0f51eb54c1
commit
416ac8b646
@ -149,16 +149,16 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
class AccountsHandler extends Handler {
|
||||
private void setViewTitle() {
|
||||
mActionBarTitle.setText(" "+getString(R.string.accounts_title));
|
||||
mActionBarTitle.setText(" " + getString(R.string.accounts_title));
|
||||
mActionBarUnread.setText(String.valueOf(mUnreadMessageCount));
|
||||
|
||||
String operation = mListener.getOperation(Accounts.this, getTimeFormat());
|
||||
operation.trim();
|
||||
if (operation.length() < 1) {
|
||||
mActionBarSubTitle.setVisibility(View.GONE);
|
||||
mActionBarSubTitle.setVisibility(View.GONE);
|
||||
} else {
|
||||
mActionBarSubTitle.setVisibility(View.VISIBLE);
|
||||
mActionBarSubTitle.setText(operation);
|
||||
mActionBarSubTitle.setVisibility(View.VISIBLE);
|
||||
mActionBarSubTitle.setText(operation);
|
||||
}
|
||||
}
|
||||
public void refreshTitle() {
|
||||
@ -217,7 +217,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (progress) {
|
||||
if (progress) {
|
||||
mRefreshMenuItem.setActionView(R.layout.actionbar_indeterminate_progress_actionview);
|
||||
} else {
|
||||
mRefreshMenuItem.setActionView(null);
|
||||
@ -374,8 +374,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
// see if we should show the welcome message
|
||||
if (accounts.length < 1) {
|
||||
WelcomeMessage.showWelcomeMessage(this);
|
||||
finish();
|
||||
WelcomeMessage.showWelcomeMessage(this);
|
||||
finish();
|
||||
}
|
||||
|
||||
boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true);
|
||||
@ -400,31 +400,31 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
// Enable context action bar behaviour
|
||||
getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
|
||||
// is already in selection mode we ignore the next ones
|
||||
if (mSelectedContextAccount != null) {
|
||||
return false;
|
||||
}
|
||||
// is already in selection mode we ignore the next ones
|
||||
if (mSelectedContextAccount != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mSelectedContextAccount = mAdapter.getItem(position);
|
||||
mSelectedContextAccount = mAdapter.getItem(position);
|
||||
|
||||
// we only handle real accounts this way
|
||||
if (mSelectedContextAccount instanceof SearchAccount) {
|
||||
mSelectedContextAccount = null;
|
||||
return false;
|
||||
}
|
||||
// we only handle real accounts this way
|
||||
if (mSelectedContextAccount instanceof SearchAccount) {
|
||||
mSelectedContextAccount = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
mSelectedContextAccount = mAdapter.getItem(position);
|
||||
mActionMode = Accounts.this.startActionMode(mActionModeCallback);
|
||||
mActionMode.invalidate();
|
||||
mActionMode.setTitle(String.format(getString(R.string.actionbar_string_selected),
|
||||
mSelectedContextAccount.getDescription()));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
mSelectedContextAccount = mAdapter.getItem(position);
|
||||
mActionMode = Accounts.this.startActionMode(mActionModeCallback);
|
||||
mActionMode.invalidate();
|
||||
mActionMode.setTitle(String.format(getString(R.string.actionbar_string_selected),
|
||||
mSelectedContextAccount.getDescription()));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) {
|
||||
String accountUuid = icicle.getString("selectedContextAccount");
|
||||
@ -441,15 +441,15 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
}
|
||||
|
||||
private void initializeActionBar() {
|
||||
mActionBar.setDisplayShowCustomEnabled(true);
|
||||
mActionBar.setCustomView(R.layout.actionbar_custom);
|
||||
mActionBar.setDisplayShowCustomEnabled(true);
|
||||
mActionBar.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 = 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);
|
||||
|
||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -545,8 +545,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
// see if we should show the welcome message
|
||||
if (accounts.length < 1) {
|
||||
WelcomeMessage.showWelcomeMessage(this);
|
||||
finish();
|
||||
WelcomeMessage.showWelcomeMessage(this);
|
||||
finish();
|
||||
}
|
||||
|
||||
List<BaseAccount> newAccounts;
|
||||
@ -646,10 +646,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
* @return false if unsuccessfull
|
||||
*/
|
||||
private boolean onOpenAccount(BaseAccount account) {
|
||||
// if we are still in a selection finish it
|
||||
if (mSelectedContextAccount != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
// if we are still in a selection finish it
|
||||
if (mSelectedContextAccount != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
|
||||
if (account instanceof SearchAccount) {
|
||||
SearchAccount searchAccount = (SearchAccount)account;
|
||||
@ -781,7 +781,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
String outgoingPassword = null;
|
||||
if (mOutgoingPasswordView != null) {
|
||||
outgoingPassword = (mUseIncomingView.isChecked()) ?
|
||||
incomingPassword : mOutgoingPasswordView.getText().toString();
|
||||
incomingPassword : mOutgoingPasswordView.getText().toString();
|
||||
}
|
||||
|
||||
dialog.dismiss();
|
||||
@ -805,21 +805,21 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
// Use the dialog's layout inflater so its theme is used (and not the activity's theme).
|
||||
View layout = mDialog.getLayoutInflater().inflate(
|
||||
R.layout.accounts_password_prompt, null);
|
||||
R.layout.accounts_password_prompt, null);
|
||||
|
||||
// Set the intro text that tells the user what to do
|
||||
TextView intro = (TextView) layout.findViewById(R.id.password_prompt_intro);
|
||||
String serverPasswords = activity.getResources().getQuantityString(
|
||||
R.plurals.settings_import_server_passwords,
|
||||
(configureOutgoingServer) ? 2 : 1);
|
||||
R.plurals.settings_import_server_passwords,
|
||||
(configureOutgoingServer) ? 2 : 1);
|
||||
intro.setText(activity.getString(R.string.settings_import_activate_account_intro,
|
||||
mAccount.getDescription(), serverPasswords));
|
||||
mAccount.getDescription(), serverPasswords));
|
||||
|
||||
// Display the hostname of the incoming server
|
||||
TextView incomingText = (TextView) layout.findViewById(
|
||||
R.id.password_prompt_incoming_server);
|
||||
R.id.password_prompt_incoming_server);
|
||||
incomingText.setText(activity.getString(R.string.settings_import_incoming_server,
|
||||
incoming.host));
|
||||
incoming.host));
|
||||
|
||||
mIncomingPasswordView = (EditText) layout.findViewById(R.id.incoming_server_password);
|
||||
mIncomingPasswordView.addTextChangedListener(this);
|
||||
@ -827,16 +827,16 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
if (configureOutgoingServer) {
|
||||
// Display the hostname of the outgoing server
|
||||
TextView outgoingText = (TextView) layout.findViewById(
|
||||
R.id.password_prompt_outgoing_server);
|
||||
R.id.password_prompt_outgoing_server);
|
||||
outgoingText.setText(activity.getString(R.string.settings_import_outgoing_server,
|
||||
outgoing.host));
|
||||
outgoing.host));
|
||||
|
||||
mOutgoingPasswordView = (EditText) layout.findViewById(
|
||||
R.id.outgoing_server_password);
|
||||
R.id.outgoing_server_password);
|
||||
mOutgoingPasswordView.addTextChangedListener(this);
|
||||
|
||||
mUseIncomingView = (CheckBox) layout.findViewById(
|
||||
R.id.use_incoming_server_password);
|
||||
R.id.use_incoming_server_password);
|
||||
mUseIncomingView.setChecked(true);
|
||||
mUseIncomingView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
@ -887,7 +887,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
// If the checkbox to use the incoming server password is checked we need to make
|
||||
// sure that the password box for the outgoing server isn't empty.
|
||||
else if (mUseIncomingView.isChecked() ||
|
||||
mOutgoingPasswordView.getText().length() > 0) {
|
||||
mOutgoingPasswordView.getText().length() > 0) {
|
||||
enable = true;
|
||||
}
|
||||
}
|
||||
@ -918,8 +918,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
private Application mApplication;
|
||||
|
||||
protected SetPasswordsAsyncTask(Activity activity, Account account,
|
||||
String incomingPassword, String outgoingPassword,
|
||||
List<Account> remainingAccounts) {
|
||||
String incomingPassword, String outgoingPassword,
|
||||
List<Account> remainingAccounts) {
|
||||
super(activity);
|
||||
mAccount = account;
|
||||
mIncomingPassword = incomingPassword;
|
||||
@ -933,7 +933,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
String title = mActivity.getString(R.string.settings_import_activate_account_header);
|
||||
int passwordCount = (mOutgoingPassword == null) ? 1 : 2;
|
||||
String message = mActivity.getResources().getQuantityString(
|
||||
R.plurals.settings_import_setting_passwords, passwordCount);
|
||||
R.plurals.settings_import_setting_passwords, passwordCount);
|
||||
mProgressDialog = ProgressDialog.show(mActivity, title, message, true);
|
||||
}
|
||||
|
||||
@ -999,101 +999,101 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
// Android recreates our dialogs on configuration changes even when they have been
|
||||
// dismissed. Make sure we have all information necessary before creating a new dialog.
|
||||
switch (id) {
|
||||
case DIALOG_REMOVE_ACCOUNT: {
|
||||
if (mSelectedContextAccount == null) {
|
||||
return null;
|
||||
}
|
||||
case DIALOG_REMOVE_ACCOUNT: {
|
||||
if (mSelectedContextAccount == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.account_delete_dlg_title,
|
||||
getString(R.string.account_delete_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()),
|
||||
R.string.okay_action,
|
||||
R.string.cancel_action,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mSelectedContextAccount instanceof Account) {
|
||||
Account realAccount = (Account) mSelectedContextAccount;
|
||||
try {
|
||||
realAccount.getLocalStore().delete();
|
||||
} catch (Exception e) {
|
||||
// Ignore, this may lead to localStores on sd-cards that
|
||||
// are currently not inserted to be left
|
||||
}
|
||||
MessagingController.getInstance(getApplication())
|
||||
.notifyAccountCancel(Accounts.this, realAccount);
|
||||
Preferences.getPreferences(Accounts.this)
|
||||
.deleteAccount(realAccount);
|
||||
K9.setServicesEnabled(Accounts.this);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
case DIALOG_CLEAR_ACCOUNT: {
|
||||
if (mSelectedContextAccount == null) {
|
||||
return null;
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.account_delete_dlg_title,
|
||||
getString(R.string.account_delete_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()),
|
||||
R.string.okay_action,
|
||||
R.string.cancel_action,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mSelectedContextAccount instanceof Account) {
|
||||
Account realAccount = (Account) mSelectedContextAccount;
|
||||
try {
|
||||
realAccount.getLocalStore().delete();
|
||||
} catch (Exception e) {
|
||||
// Ignore, this may lead to localStores on sd-cards that
|
||||
// are currently not inserted to be left
|
||||
}
|
||||
MessagingController.getInstance(getApplication())
|
||||
.notifyAccountCancel(Accounts.this, realAccount);
|
||||
Preferences.getPreferences(Accounts.this)
|
||||
.deleteAccount(realAccount);
|
||||
K9.setServicesEnabled(Accounts.this);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.account_clear_dlg_title,
|
||||
getString(R.string.account_clear_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.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,
|
||||
R.string.clearing_account);
|
||||
MessagingController.getInstance(getApplication())
|
||||
.clear(realAccount, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
case DIALOG_CLEAR_ACCOUNT: {
|
||||
if (mSelectedContextAccount == null) {
|
||||
return null;
|
||||
}
|
||||
case DIALOG_RECREATE_ACCOUNT: {
|
||||
if (mSelectedContextAccount == null) {
|
||||
return null;
|
||||
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.account_clear_dlg_title,
|
||||
getString(R.string.account_clear_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.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,
|
||||
R.string.clearing_account);
|
||||
MessagingController.getInstance(getApplication())
|
||||
.clear(realAccount, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
case DIALOG_RECREATE_ACCOUNT: {
|
||||
if (mSelectedContextAccount == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.account_recreate_dlg_title,
|
||||
getString(R.string.account_recreate_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.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,
|
||||
R.string.recreating_account);
|
||||
MessagingController.getInstance(getApplication())
|
||||
.recreate(realAccount, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
case DIALOG_NO_FILE_MANAGER: {
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.import_dialog_error_title,
|
||||
getString(R.string.import_dialog_error_message),
|
||||
R.string.open_market,
|
||||
R.string.close,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Uri uri = Uri.parse(ANDROID_MARKET_URL);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.account_recreate_dlg_title,
|
||||
getString(R.string.account_recreate_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.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,
|
||||
R.string.recreating_account);
|
||||
MessagingController.getInstance(getApplication())
|
||||
.recreate(realAccount, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
case DIALOG_NO_FILE_MANAGER: {
|
||||
return ConfirmationDialog.create(this, id,
|
||||
R.string.import_dialog_error_title,
|
||||
getString(R.string.import_dialog_error_message),
|
||||
R.string.open_market,
|
||||
R.string.close,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Uri uri = Uri.parse(ANDROID_MARKET_URL);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return super.onCreateDialog(id);
|
||||
@ -1103,21 +1103,21 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
public void onPrepareDialog(int id, Dialog d) {
|
||||
AlertDialog alert = (AlertDialog) d;
|
||||
switch (id) {
|
||||
case DIALOG_REMOVE_ACCOUNT: {
|
||||
alert.setMessage(getString(R.string.account_delete_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
}
|
||||
case DIALOG_CLEAR_ACCOUNT: {
|
||||
alert.setMessage(getString(R.string.account_clear_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
}
|
||||
case DIALOG_RECREATE_ACCOUNT: {
|
||||
alert.setMessage(getString(R.string.account_recreate_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
}
|
||||
case DIALOG_REMOVE_ACCOUNT: {
|
||||
alert.setMessage(getString(R.string.account_delete_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
}
|
||||
case DIALOG_CLEAR_ACCOUNT: {
|
||||
alert.setMessage(getString(R.string.account_clear_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
}
|
||||
case DIALOG_RECREATE_ACCOUNT: {
|
||||
alert.setMessage(getString(R.string.account_recreate_dlg_instructions_fmt,
|
||||
mSelectedContextAccount.getDescription()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
super.onPrepareDialog(id, d);
|
||||
@ -1280,7 +1280,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
if (infos.size() > 0) {
|
||||
startActivityForResult(Intent.createChooser(i, null),
|
||||
ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
|
||||
ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
|
||||
} else {
|
||||
showDialog(DIALOG_NO_FILE_MANAGER);
|
||||
}
|
||||
@ -1418,7 +1418,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
int imported = mImportResults.importedAccounts.size();
|
||||
String accounts = activity.getResources().getQuantityString(
|
||||
R.plurals.settings_import_success, imported, imported);
|
||||
R.plurals.settings_import_success, imported, imported);
|
||||
return activity.getString(R.string.settings_import_success, accounts, mFilename);
|
||||
}
|
||||
|
||||
@ -1532,46 +1532,46 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
builder.setTitle(activity.getString(R.string.settings_import_selection));
|
||||
builder.setInverseBackgroundForced(true);
|
||||
builder.setPositiveButton(R.string.okay_action,
|
||||
new DialogInterface.OnClickListener() {
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ListView listView = ((AlertDialog) dialog).getListView();
|
||||
SparseBooleanArray pos = listView.getCheckedItemPositions();
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ListView listView = ((AlertDialog) dialog).getListView();
|
||||
SparseBooleanArray pos = listView.getCheckedItemPositions();
|
||||
|
||||
boolean includeGlobals = mImportContents.globalSettings ? pos.get(0) : false;
|
||||
List<String> accountUuids = new ArrayList<String>();
|
||||
int start = mImportContents.globalSettings ? 1 : 0;
|
||||
for (int i = start, end = listView.getCount(); i < end; i++) {
|
||||
if (pos.get(i)) {
|
||||
accountUuids.add(mImportContents.accounts.get(i-start).uuid);
|
||||
}
|
||||
boolean includeGlobals = mImportContents.globalSettings ? pos.get(0) : false;
|
||||
List<String> accountUuids = new ArrayList<String>();
|
||||
int start = mImportContents.globalSettings ? 1 : 0;
|
||||
for (int i = start, end = listView.getCount(); i < end; i++) {
|
||||
if (pos.get(i)) {
|
||||
accountUuids.add(mImportContents.accounts.get(i - start).uuid);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Think some more about this. Overwriting could change the store
|
||||
* type. This requires some additional code in order to work smoothly
|
||||
* while the app is running.
|
||||
*/
|
||||
boolean overwrite = false;
|
||||
|
||||
dialog.dismiss();
|
||||
activity.setNonConfigurationInstance(null);
|
||||
|
||||
ImportAsyncTask importAsyncTask = new ImportAsyncTask(activity,
|
||||
includeGlobals, accountUuids, overwrite, mUri);
|
||||
activity.setNonConfigurationInstance(importAsyncTask);
|
||||
importAsyncTask.execute();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* TODO: Think some more about this. Overwriting could change the store
|
||||
* type. This requires some additional code in order to work smoothly
|
||||
* while the app is running.
|
||||
*/
|
||||
boolean overwrite = false;
|
||||
|
||||
dialog.dismiss();
|
||||
activity.setNonConfigurationInstance(null);
|
||||
|
||||
ImportAsyncTask importAsyncTask = new ImportAsyncTask(activity,
|
||||
includeGlobals, accountUuids, overwrite, mUri);
|
||||
activity.setNonConfigurationInstance(importAsyncTask);
|
||||
importAsyncTask.execute();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel_action,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
activity.setNonConfigurationInstance(null);
|
||||
}
|
||||
});
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
activity.setNonConfigurationInstance(null);
|
||||
}
|
||||
});
|
||||
mDialog = builder.show();
|
||||
}
|
||||
}
|
||||
@ -1791,83 +1791,81 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
*/
|
||||
private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(mSelectedContextAccount);
|
||||
if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
|
||||
menu.findItem(R.id.move_up).setVisible(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
menu.findItem(R.id.move_up).setVisible(true);
|
||||
}
|
||||
if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
|
||||
menu.findItem(R.id.move_down).setVisible(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
menu.findItem(R.id.move_down).setVisible(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
mSelectedContextAccount = null;
|
||||
mActionMode = null;
|
||||
}
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
mSelectedContextAccount = null;
|
||||
mActionMode = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.accounts_context, menu);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.accounts_context, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
Account realAccount = (Account)mSelectedContextAccount;
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
Account realAccount = (Account)mSelectedContextAccount;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.delete_account:
|
||||
onDeleteAccount(realAccount);
|
||||
break;
|
||||
case R.id.edit_account:
|
||||
onEditAccount(realAccount);
|
||||
break;
|
||||
case R.id.activate:
|
||||
onActivateAccount(realAccount);
|
||||
break;
|
||||
case R.id.check_mail:
|
||||
onCheckMail(realAccount);
|
||||
break;
|
||||
case R.id.clear_pending:
|
||||
onClearCommands(realAccount);
|
||||
break;
|
||||
case R.id.empty_trash:
|
||||
onEmptyTrash(realAccount);
|
||||
break;
|
||||
case R.id.compact:
|
||||
onCompact(realAccount);
|
||||
break;
|
||||
case R.id.clear:
|
||||
onClear(realAccount);
|
||||
break;
|
||||
case R.id.recreate:
|
||||
onRecreate(realAccount);
|
||||
break;
|
||||
case R.id.export:
|
||||
onExport(false, realAccount);
|
||||
break;
|
||||
case R.id.move_up:
|
||||
onMove(realAccount, true);
|
||||
break;
|
||||
case R.id.move_down:
|
||||
onMove(realAccount, false);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
switch (item.getItemId()) {
|
||||
case R.id.delete_account:
|
||||
onDeleteAccount(realAccount);
|
||||
break;
|
||||
case R.id.edit_account:
|
||||
onEditAccount(realAccount);
|
||||
break;
|
||||
case R.id.activate:
|
||||
onActivateAccount(realAccount);
|
||||
break;
|
||||
case R.id.check_mail:
|
||||
onCheckMail(realAccount);
|
||||
break;
|
||||
case R.id.clear_pending:
|
||||
onClearCommands(realAccount);
|
||||
break;
|
||||
case R.id.empty_trash:
|
||||
onEmptyTrash(realAccount);
|
||||
break;
|
||||
case R.id.compact:
|
||||
onCompact(realAccount);
|
||||
break;
|
||||
case R.id.clear:
|
||||
onClear(realAccount);
|
||||
break;
|
||||
case R.id.recreate:
|
||||
onRecreate(realAccount);
|
||||
break;
|
||||
case R.id.export:
|
||||
onExport(false, realAccount);
|
||||
break;
|
||||
case R.id.move_up:
|
||||
onMove(realAccount, true);
|
||||
break;
|
||||
case R.id.move_down:
|
||||
onMove(realAccount, false);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public void onExport(final boolean includeGlobals, final Account account) {
|
||||
|
||||
@ -1893,7 +1891,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
|
||||
private ExportAsyncTask(Accounts activity, boolean includeGlobals,
|
||||
Set<String> accountUuids) {
|
||||
Set<String> accountUuids) {
|
||||
super(activity);
|
||||
mIncludeGlobals = includeGlobals;
|
||||
mAccountUuids = accountUuids;
|
||||
@ -1910,7 +1908,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
try {
|
||||
mFileName = SettingsExporter.exportToFile(mContext, mIncludeGlobals,
|
||||
mAccountUuids);
|
||||
mAccountUuids);
|
||||
} catch (SettingsImportExportException e) {
|
||||
Log.w(K9.LOG_TAG, "Exception during export", e);
|
||||
return false;
|
||||
@ -1929,11 +1927,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
if (success) {
|
||||
activity.showSimpleDialog(R.string.settings_export_success_header,
|
||||
R.string.settings_export_success, mFileName);
|
||||
R.string.settings_export_success, mFileName);
|
||||
} else {
|
||||
//TODO: better error messages
|
||||
activity.showSimpleDialog(R.string.settings_export_failed_header,
|
||||
R.string.settings_export_failure);
|
||||
R.string.settings_export_failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1949,7 +1947,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
private ImportResults mImportResults;
|
||||
|
||||
private ImportAsyncTask(Accounts activity, boolean includeGlobals,
|
||||
List<String> accountUuids, boolean overwrite, Uri uri) {
|
||||
List<String> accountUuids, boolean overwrite, Uri uri) {
|
||||
super(activity);
|
||||
mIncludeGlobals = includeGlobals;
|
||||
mAccountUuids = accountUuids;
|
||||
@ -1970,11 +1968,13 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
InputStream is = mContext.getContentResolver().openInputStream(mUri);
|
||||
try {
|
||||
mImportResults = SettingsImporter.importSettings(mContext, is,
|
||||
mIncludeGlobals, mAccountUuids, mOverwrite);
|
||||
mIncludeGlobals, mAccountUuids, mOverwrite);
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) { /* Ignore */ }
|
||||
} catch (IOException e) {
|
||||
/* Ignore */
|
||||
}
|
||||
}
|
||||
} catch (SettingsImportExportException e) {
|
||||
Log.w(K9.LOG_TAG, "Exception during import", e);
|
||||
@ -2004,7 +2004,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
if (success && (globalSettings || imported > 0)) {
|
||||
if (imported == 0) {
|
||||
activity.showSimpleDialog(R.string.settings_import_success_header,
|
||||
R.string.settings_import_global_settings_success, filename);
|
||||
R.string.settings_import_global_settings_success, filename);
|
||||
} else {
|
||||
activity.showAccountsImportedDialog(mImportResults, filename);
|
||||
}
|
||||
@ -2013,7 +2013,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
} else {
|
||||
//TODO: better error messages
|
||||
activity.showSimpleDialog(R.string.settings_import_failed_header,
|
||||
R.string.settings_import_failure, filename);
|
||||
R.string.settings_import_failure, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2045,13 +2045,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) { /* Ignore */ }
|
||||
} catch (IOException e) {
|
||||
/* Ignore */
|
||||
}
|
||||
}
|
||||
} catch (SettingsImportExportException e) {
|
||||
Log.w(K9.LOG_TAG, "Exception during export", e);
|
||||
return false;
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.w(K9.LOG_TAG, "Couldn't read content from URI " + mUri);
|
||||
return false;
|
||||
}
|
||||
@ -2073,7 +2074,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
String filename = mUri.getLastPathSegment();
|
||||
//TODO: better error messages
|
||||
activity.showSimpleDialog(R.string.settings_import_failed_header,
|
||||
R.string.settings_import_failure, filename);
|
||||
R.string.settings_import_failure, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user