Commit 2e99802f authored by Grigory Fedorov's avatar Grigory Fedorov

Contact list options menu changed to used xml resources.Several iIcons added.

parent 155af8df
...@@ -80,15 +80,6 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O ...@@ -80,15 +80,6 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
private static final String SAVED_ACTION = "com.xabber.android.ui.ContactList.SAVED_ACTION"; private static final String SAVED_ACTION = "com.xabber.android.ui.ContactList.SAVED_ACTION";
private static final String SAVED_SEND_TEXT = "com.xabber.android.ui.ContactList.SAVED_SEND_TEXT"; private static final String SAVED_SEND_TEXT = "com.xabber.android.ui.ContactList.SAVED_SEND_TEXT";
private static final int OPTION_MENU_ADD_CONTACT_ID = 0x02;
private static final int OPTION_MENU_STATUS_EDITOR_ID = 0x04;
private static final int OPTION_MENU_PREFERENCE_EDITOR_ID = 0x05;
private static final int OPTION_MENU_CHAT_LIST_ID = 0x06;
private static final int OPTION_MENU_JOIN_ROOM_ID = 0x07;
private static final int OPTION_MENU_EXIT_ID = 0x08;
private static final int OPTION_MENU_SEARCH_ID = 0x0A;
private static final int OPTION_MENU_CLOSE_CHATS_ID = 0x0B;
private static final int DIALOG_CLOSE_APPLICATION_ID = 0x57; private static final int DIALOG_CLOSE_APPLICATION_ID = 0x57;
private static final String CONTACT_LIST_TAG = "CONTACT_LIST"; private static final String CONTACT_LIST_TAG = "CONTACT_LIST";
...@@ -273,48 +264,43 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O ...@@ -273,48 +264,43 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
menu.add(0, OPTION_MENU_ADD_CONTACT_ID, 0, getMenuInflater().inflate(R.menu.contact_list, menu);
getText(R.string.contact_add)).setIcon(
R.drawable.ic_menu_invite);
menu.add(0, OPTION_MENU_CLOSE_CHATS_ID, 0,
getText(R.string.close_chats)).setIcon(
R.drawable.ic_menu_end_conversation);
menu.add(0, OPTION_MENU_PREFERENCE_EDITOR_ID, 0,
getResources().getText(R.string.preference_editor)).setIcon(
android.R.drawable.ic_menu_preferences);
menu.add(0, OPTION_MENU_STATUS_EDITOR_ID, 0,
getText(R.string.status_editor)).setIcon(
R.drawable.ic_menu_notifications);
menu.add(0, OPTION_MENU_EXIT_ID, 0, getText(R.string.exit)).setIcon(
android.R.drawable.ic_menu_close_clear_cancel);
menu.add(0, OPTION_MENU_JOIN_ROOM_ID, 0, getText(R.string.muc_add));
menu.add(0, OPTION_MENU_SEARCH_ID, 0,
getText(android.R.string.search_go));
menu.add(0, OPTION_MENU_CHAT_LIST_ID, 0, getText(R.string.chat_list))
.setIcon(R.drawable.ic_menu_friendslist);
return true; return true;
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch (item.getItemId()) { switch (item.getItemId()) {
case OPTION_MENU_ADD_CONTACT_ID: case R.id.action_search:
startActivity(ContactAdd.createIntent(this)); search();
return true; return true;
case OPTION_MENU_STATUS_EDITOR_ID: case R.id.action_change_status:
startActivity(StatusEditor.createIntent(this)); startActivity(StatusEditor.createIntent(this));
return true; return true;
case OPTION_MENU_PREFERENCE_EDITOR_ID: case R.id.action_add_contact:
startActivity(PreferenceEditor.createIntent(this)); startActivity(ContactAdd.createIntent(this));
return true; return true;
case OPTION_MENU_CHAT_LIST_ID: case R.id.action_close_chats:
startActivity(ChatList.createIntent(this)); closeAllChats();
return true; return true;
case OPTION_MENU_JOIN_ROOM_ID: case R.id.action_join_conference:
startActivity(MUCEditor.createIntent(this)); startActivity(MUCEditor.createIntent(this));
return true; return true;
case OPTION_MENU_EXIT_ID: case R.id.action_chat_list:
startActivity(ChatList.createIntent(this));
return true;
case R.id.action_settings:
startActivity(PreferenceEditor.createIntent(this));
return true;
case R.id.action_exit:
exit();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void exit() {
Application.getInstance().requestToClose(); Application.getInstance().requestToClose();
showDialog(DIALOG_CLOSE_APPLICATION_ID); showDialog(DIALOG_CLOSE_APPLICATION_ID);
getContactListFragment().unregisterListeners(); getContactListFragment().unregisterListeners();
...@@ -325,11 +311,9 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O ...@@ -325,11 +311,9 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
finish(); finish();
} }
}, CLOSE_ACTIVITY_AFTER_DELAY); }, CLOSE_ACTIVITY_AFTER_DELAY);
return true; }
case OPTION_MENU_SEARCH_ID:
search(); private void closeAllChats() {
return true;
case OPTION_MENU_CLOSE_CHATS_ID:
for (AbstractChat chat : MessageManager.getInstance() for (AbstractChat chat : MessageManager.getInstance()
.getActiveChats()) { .getActiveChats()) {
MessageManager.getInstance().closeChat(chat.getAccount(), MessageManager.getInstance().closeChat(chat.getAccount(),
...@@ -338,9 +322,6 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O ...@@ -338,9 +322,6 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
chat.getAccount(), chat.getUser()); chat.getAccount(), chat.getUser());
} }
getContactListFragment().getAdapter().onChange(); getContactListFragment().getAdapter().onChange();
return true;
}
return false;
} }
private ContactListFragment getContactListFragment() { private ContactListFragment getContactListFragment() {
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_search"
android:title="@android:string/search_go"
app:showAsAction="always"
android:orderInCategory="100"
android:icon="@drawable/ic_search_white_24dp"
/>
<item android:id="@+id/action_add_contact"
android:title="@string/contact_add"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_person_add_white_24dp"
android:orderInCategory="110"
/>
<item android:id="@+id/action_join_conference"
android:title="@string/muc_add"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_group_white_24dp"
android:orderInCategory="120"
/>
<item android:id="@+id/action_change_status"
android:title="@string/status_editor"
app:showAsAction="never"
android:orderInCategory="130"
/>
<item android:id="@+id/action_chat_list"
android:title="@string/chat_list"
app:showAsAction="never"
android:orderInCategory="140"
/>
<item android:id="@+id/action_close_chats"
android:title="@string/close_chats"
app:showAsAction="never"
android:orderInCategory="150"
/>
<item android:id="@+id/action_settings"
android:title="@string/preference_editor"
app:showAsAction="never"
android:orderInCategory="160"
android:icon="@drawable/ic_settings_white_24dp"
/>
<item android:id="@+id/action_exit"
android:title="@string/exit"
app:showAsAction="never"
android:orderInCategory="200"
/>
</menu>
\ No newline at end of file
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