mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Revert "Context actionbar for the account screen."
We're not ready for this sort of living in the futre yet.
This reverts commit 0f51eb54c1
.
Conflicts:
res/drawable-hdpi/ic_action_settings_light.png
res/drawable-ldpi/ic_action_settings_light.png
res/drawable-mdpi/ic_action_settings_light.png
res/drawable-xhdpi/ic_action_settings_light.png
res/menu/accounts_context.xml
res/values/strings.xml
src/com/fsck/k9/activity/Accounts.java
This commit is contained in:
parent
297e859b90
commit
46edd8f793
@ -1,51 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/open"
|
||||
android:title="@string/open_action" />
|
||||
<item android:id="@+id/check_mail"
|
||||
android:title="@string/check_mail_action"
|
||||
android:showAsAction="always"
|
||||
android:icon="?attr/iconActionRefresh" />
|
||||
|
||||
android:title="@string/check_mail_action" />
|
||||
<item android:id="@+id/empty_trash"
|
||||
android:title="@string/empty_trash_action"
|
||||
android:showAsAction="always"
|
||||
android:icon="?attr/iconActionDelete" />
|
||||
|
||||
android:title="@string/empty_trash_action" />
|
||||
<item android:id="@+id/edit_account"
|
||||
android:title="@string/account_settings_action"
|
||||
android:showAsAction="always"
|
||||
android:icon="?attr/iconActionSettings"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/compact"
|
||||
android:title="@string/compact_action"
|
||||
android:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/clear"
|
||||
android:title="@string/clear_action"
|
||||
android:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/recreate"
|
||||
android:title="@string/recreate_action"
|
||||
android:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/delete_account"
|
||||
android:title="@string/remove_account_action"
|
||||
android:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/clear_pending"
|
||||
android:title="@string/clear_pending_action"
|
||||
android:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/export"
|
||||
android:title="@string/settings_export_account"
|
||||
android:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/move_up"
|
||||
android:title="@string/manage_accounts_move_up_action"
|
||||
android:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/move_down"
|
||||
android:title="@string/manage_accounts_move_down_action"
|
||||
android:showAsAction="never"/>
|
||||
|
||||
android:title="@string/account_settings_action" />
|
||||
<item android:id="@+id/advanced"
|
||||
android:title="@string/advanced">
|
||||
<menu>
|
||||
<item android:id="@+id/compact"
|
||||
android:title="@string/compact_action" />
|
||||
<item android:id="@+id/clear"
|
||||
android:title="@string/clear_action" />
|
||||
<item android:id="@+id/recreate"
|
||||
android:title="@string/recreate_action" />
|
||||
<item android:id="@+id/delete_account"
|
||||
android:title="@string/remove_account_action" />
|
||||
<item android:id="@+id/clear_pending"
|
||||
android:title="@string/clear_pending_action" />
|
||||
<item android:id="@+id/export"
|
||||
android:title="@string/settings_export_account" />
|
||||
<item android:id="@+id/move_up"
|
||||
android:title="@string/manage_accounts_move_up_action" />
|
||||
<item android:id="@+id/move_down"
|
||||
android:title="@string/manage_accounts_move_down_action" />
|
||||
</menu>
|
||||
</item>
|
||||
</menu>
|
||||
|
@ -28,18 +28,21 @@ import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
@ -48,12 +51,10 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.ActionMode;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.AccountStats;
|
||||
import com.fsck.k9.BaseAccount;
|
||||
@ -79,6 +80,7 @@ import com.fsck.k9.mail.Transport;
|
||||
import com.fsck.k9.mail.internet.MimeUtility;
|
||||
import com.fsck.k9.mail.store.StorageManager;
|
||||
import com.fsck.k9.mail.store.WebDavStore;
|
||||
import com.fsck.k9.view.ColorChip;
|
||||
import com.fsck.k9.preferences.SettingsExporter;
|
||||
import com.fsck.k9.preferences.SettingsImportExportException;
|
||||
import com.fsck.k9.preferences.SettingsImporter;
|
||||
@ -86,7 +88,6 @@ import com.fsck.k9.preferences.SettingsImporter.AccountDescription;
|
||||
import com.fsck.k9.preferences.SettingsImporter.AccountDescriptionPair;
|
||||
import com.fsck.k9.preferences.SettingsImporter.ImportContents;
|
||||
import com.fsck.k9.preferences.SettingsImporter.ImportResults;
|
||||
import com.fsck.k9.view.ColorChip;
|
||||
|
||||
|
||||
public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
@ -131,7 +132,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
private MenuItem mRefreshMenuItem;
|
||||
private ActionBar mActionBar;
|
||||
private ActionMode mActionMode;
|
||||
|
||||
private TextView mActionBarTitle;
|
||||
private TextView mActionBarSubTitle;
|
||||
@ -398,33 +398,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
listView.setScrollingCacheEnabled(false);
|
||||
registerForContextMenu(listView);
|
||||
|
||||
// Enable context action bar behaviour
|
||||
getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
@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;
|
||||
}
|
||||
|
||||
mSelectedContextAccount = mAdapter.getItem(position);
|
||||
|
||||
// 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;
|
||||
}
|
||||
});
|
||||
|
||||
if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) {
|
||||
String accountUuid = icicle.getString("selectedContextAccount");
|
||||
@ -441,8 +414,8 @@ 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);
|
||||
@ -646,11 +619,6 @@ 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 (account instanceof SearchAccount) {
|
||||
SearchAccount searchAccount = (SearchAccount)account;
|
||||
MessageList.actionHandle(this, searchAccount.getDescription(), searchAccount);
|
||||
@ -1027,7 +995,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
.deleteAccount(realAccount);
|
||||
K9.setServicesEnabled(Accounts.this);
|
||||
refresh();
|
||||
mActionMode.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1124,6 +1091,64 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
super.onPrepareDialog(id, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(android.view.MenuItem item) {
|
||||
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)item.getMenuInfo();
|
||||
// submenus don't actually set the menuInfo, so the "advanced"
|
||||
// submenu wouldn't work.
|
||||
if (menuInfo != null) {
|
||||
mSelectedContextAccount = (BaseAccount)getListView().getItemAtPosition(menuInfo.position);
|
||||
}
|
||||
Account realAccount = null;
|
||||
if (mSelectedContextAccount instanceof 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.open:
|
||||
onOpenAccount(mSelectedContextAccount);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void onCompact(Account account) {
|
||||
mHandler.workingAccount(account, R.string.compacting_account);
|
||||
MessagingController.getInstance(getApplication()).compact(account, null);
|
||||
@ -1263,6 +1288,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
return version;
|
||||
}
|
||||
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
@ -1271,6 +1300,45 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
menu.setHeaderTitle(R.string.accounts_context_menu_title);
|
||||
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
||||
BaseAccount account = mAdapter.getItem(info.position);
|
||||
|
||||
if ((account instanceof Account) && !((Account) account).isEnabled()) {
|
||||
getMenuInflater().inflate(R.menu.disabled_accounts_context, menu);
|
||||
} else {
|
||||
getMenuInflater().inflate(R.menu.accounts_context, menu);
|
||||
}
|
||||
|
||||
if (account instanceof SearchAccount) {
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
android.view.MenuItem item = menu.getItem(i);
|
||||
if (item.getItemId() != R.id.open) {
|
||||
item.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account);
|
||||
if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
|
||||
menu.findItem(R.id.move_up).setEnabled(false);
|
||||
}
|
||||
else {
|
||||
menu.findItem(R.id.move_up).setEnabled(true);
|
||||
}
|
||||
if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
|
||||
menu.findItem(R.id.move_down).setEnabled(false);
|
||||
}
|
||||
else {
|
||||
menu.findItem(R.id.move_down).setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onImport() {
|
||||
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
@ -1786,88 +1854,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Assume this will only be used for REAL ACCOUNTS. This means not the
|
||||
* unified inbox, all messages ( and whatever may come in the future ).
|
||||
*/
|
||||
private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
|
||||
|
||||
@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 {
|
||||
menu.findItem(R.id.move_up).setVisible(true);
|
||||
}
|
||||
if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
|
||||
menu.findItem(R.id.move_down).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.move_down).setVisible(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@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 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;
|
||||
}
|
||||
};
|
||||
|
||||
public void onExport(final boolean includeGlobals, final Account account) {
|
||||
|
||||
// TODO, prompt to allow a user to choose which accounts to export
|
||||
|
Loading…
Reference in New Issue
Block a user