Commit 7e258b6e authored by Alexander Ivanov's avatar Alexander Ivanov

Separate context menu creation for contacts, groups and accounts.

parent a977f78f
...@@ -488,11 +488,25 @@ public class ContactList extends ManagedListActivity implements ...@@ -488,11 +488,25 @@ public class ContactList extends ManagedListActivity implements
// Account toggler // Account toggler
return; return;
if (baseEntity instanceof AbstractContact) { if (baseEntity instanceof AbstractContact) {
// Contact createContactContextMenu((AbstractContact) baseEntity, menu);
actionWithAccount = baseEntity.getAccount(); } else if (baseEntity instanceof AccountConfiguration) {
createAccountContextMenu(baseEntity.getAccount(), menu);
} else if (baseEntity instanceof GroupConfiguration) {
createGroupContextMenu(baseEntity.getAccount(),
baseEntity.getUser(), menu);
}
} else {
// Account panel
createAccountContextMenu(
(String) accountToggleAdapter.getItemForView(view), menu);
}
}
private void createContactContextMenu(AbstractContact abstractContact,
ContextMenu menu) {
actionWithAccount = abstractContact.getAccount();
actionWithGroup = null; actionWithGroup = null;
actionWithUser = baseEntity.getUser(); actionWithUser = abstractContact.getUser();
AbstractContact abstractContact = (AbstractContact) baseEntity;
menu.setHeaderTitle(abstractContact.getName()); menu.setHeaderTitle(abstractContact.getName());
menu.add(0, CONTEXT_MENU_VIEW_CHAT_ID, 0, getResources() menu.add(0, CONTEXT_MENU_VIEW_CHAT_ID, 0, getResources()
.getText(R.string.chat_viewer)); .getText(R.string.chat_viewer));
...@@ -534,17 +548,13 @@ public class ContactList extends ManagedListActivity implements ...@@ -534,17 +548,13 @@ public class ContactList extends ManagedListActivity implements
menu.add(0, CONTEXT_MENU_DISCARD_SUBSCRIPTION_ID, 0, menu.add(0, CONTEXT_MENU_DISCARD_SUBSCRIPTION_ID, 0,
getText(R.string.discard_subscription)); getText(R.string.discard_subscription));
} }
return; }
} else if (baseEntity instanceof GroupConfiguration) {
// Group or account in contact list
actionWithAccount = baseEntity.getAccount();
actionWithGroup = baseEntity.getUser();
actionWithUser = null;
if (baseEntity instanceof AccountConfiguration) { private void createGroupContextMenu(String account, String group,
actionWithGroup = null; ContextMenu menu) {
} else { actionWithAccount = account;
// Group actionWithGroup = group;
actionWithUser = null;
menu.setHeaderTitle(GroupManager.getInstance() menu.setHeaderTitle(GroupManager.getInstance()
.getGroupName(actionWithAccount, actionWithGroup)); .getGroupName(actionWithAccount, actionWithGroup));
if (actionWithGroup != GroupManager.ACTIVE_CHATS if (actionWithGroup != GroupManager.ACTIVE_CHATS
...@@ -555,21 +565,13 @@ public class ContactList extends ManagedListActivity implements ...@@ -555,21 +565,13 @@ public class ContactList extends ManagedListActivity implements
menu.add(0, CONTEXT_MENU_GROUP_DELETE_ID, 0, menu.add(0, CONTEXT_MENU_GROUP_DELETE_ID, 0,
getText(R.string.group_remove)); getText(R.string.group_remove));
} }
} createOfflineModeContextMenu(menu);
} else { }
return;
} private void createAccountContextMenu(String account, ContextMenu menu) {
} else { actionWithAccount = account;
// Account panel
actionWithAccount = (String) accountToggleAdapter
.getItemForView(view);
actionWithGroup = null; actionWithGroup = null;
actionWithUser = null; actionWithUser = null;
}
// Group or account
if (actionWithGroup == null) {
// Account
menu.setHeaderTitle(AccountManager.getInstance().getVerboseName( menu.setHeaderTitle(AccountManager.getInstance().getVerboseName(
actionWithAccount)); actionWithAccount));
AccountItem accountItem = AccountManager.getInstance().getAccount( AccountItem accountItem = AccountManager.getInstance().getAccount(
...@@ -588,8 +590,10 @@ public class ContactList extends ManagedListActivity implements ...@@ -588,8 +590,10 @@ public class ContactList extends ManagedListActivity implements
menu.add(0, CONTEXT_MENU_ACCOUNT_ADD_CONTACT_ID, 0, menu.add(0, CONTEXT_MENU_ACCOUNT_ADD_CONTACT_ID, 0,
getText(R.string.contact_add)); getText(R.string.contact_add));
} }
} createOfflineModeContextMenu(menu);
}
private void createOfflineModeContextMenu(ContextMenu menu) {
if (actionWithGroup != null || SettingsManager.contactsShowAccounts()) { if (actionWithGroup != null || SettingsManager.contactsShowAccounts()) {
SubMenu mapMode = menu.addSubMenu(getResources().getText( SubMenu mapMode = menu.addSubMenu(getResources().getText(
R.string.show_offline_settings)); R.string.show_offline_settings));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment