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";
...@@ -270,80 +261,70 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O ...@@ -270,80 +261,70 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
super.onPause(); super.onPause();
} }
@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( return true;
R.drawable.ic_menu_invite); }
menu.add(0, OPTION_MENU_CLOSE_CHATS_ID, 0,
getText(R.string.close_chats)).setIcon( @Override
R.drawable.ic_menu_end_conversation); public boolean onOptionsItemSelected(MenuItem item) {
menu.add(0, OPTION_MENU_PREFERENCE_EDITOR_ID, 0, switch (item.getItemId()) {
getResources().getText(R.string.preference_editor)).setIcon( case R.id.action_search:
android.R.drawable.ic_menu_preferences); search();
menu.add(0, OPTION_MENU_STATUS_EDITOR_ID, 0, return true;
getText(R.string.status_editor)).setIcon( case R.id.action_change_status:
R.drawable.ic_menu_notifications); startActivity(StatusEditor.createIntent(this));
menu.add(0, OPTION_MENU_EXIT_ID, 0, getText(R.string.exit)).setIcon( return true;
android.R.drawable.ic_menu_close_clear_cancel); case R.id.action_add_contact:
menu.add(0, OPTION_MENU_JOIN_ROOM_ID, 0, getText(R.string.muc_add)); startActivity(ContactAdd.createIntent(this));
menu.add(0, OPTION_MENU_SEARCH_ID, 0, return true;
getText(android.R.string.search_go)); case R.id.action_close_chats:
menu.add(0, OPTION_MENU_CHAT_LIST_ID, 0, getText(R.string.chat_list)) closeAllChats();
.setIcon(R.drawable.ic_menu_friendslist); return true;
return true; case R.id.action_join_conference:
} startActivity(MUCEditor.createIntent(this));
return true;
@Override case R.id.action_chat_list:
public boolean onOptionsItemSelected(MenuItem item) { startActivity(ChatList.createIntent(this));
super.onOptionsItemSelected(item); return true;
switch (item.getItemId()) { case R.id.action_settings:
case OPTION_MENU_ADD_CONTACT_ID: startActivity(PreferenceEditor.createIntent(this));
startActivity(ContactAdd.createIntent(this)); return true;
return true; case R.id.action_exit:
case OPTION_MENU_STATUS_EDITOR_ID: exit();
startActivity(StatusEditor.createIntent(this)); return true;
return true; default:
case OPTION_MENU_PREFERENCE_EDITOR_ID: return super.onOptionsItemSelected(item);
startActivity(PreferenceEditor.createIntent(this)); }
return true; }
case OPTION_MENU_CHAT_LIST_ID:
startActivity(ChatList.createIntent(this)); private void exit() {
return true; Application.getInstance().requestToClose();
case OPTION_MENU_JOIN_ROOM_ID: showDialog(DIALOG_CLOSE_APPLICATION_ID);
startActivity(MUCEditor.createIntent(this)); getContactListFragment().unregisterListeners();
return true; new Handler().postDelayed(new Runnable() {
case OPTION_MENU_EXIT_ID: @Override
Application.getInstance().requestToClose(); public void run() {
showDialog(DIALOG_CLOSE_APPLICATION_ID); // Close activity if application was not killed yet.
getContactListFragment().unregisterListeners(); finish();
new Handler().postDelayed(new Runnable() { }
@Override }, CLOSE_ACTIVITY_AFTER_DELAY);
public void run() { }
// Close activity if application was not killed yet.
finish(); private void closeAllChats() {
} for (AbstractChat chat : MessageManager.getInstance()
}, CLOSE_ACTIVITY_AFTER_DELAY); .getActiveChats()) {
return true; MessageManager.getInstance().closeChat(chat.getAccount(),
case OPTION_MENU_SEARCH_ID: chat.getUser());
search(); NotificationManager.getInstance().removeMessageNotification(
return true; chat.getAccount(), chat.getUser());
case OPTION_MENU_CLOSE_CHATS_ID: }
for (AbstractChat chat : MessageManager.getInstance() getContactListFragment().getAdapter().onChange();
.getActiveChats()) { }
MessageManager.getInstance().closeChat(chat.getAccount(),
chat.getUser());
NotificationManager.getInstance().removeMessageNotification(
chat.getAccount(), chat.getUser());
}
getContactListFragment().getAdapter().onChange();
return true;
}
return false;
}
private ContactListFragment getContactListFragment() { private ContactListFragment getContactListFragment() {
return (ContactListFragment) getSupportFragmentManager() return (ContactListFragment) getSupportFragmentManager()
.findFragmentByTag(CONTACT_LIST_TAG); .findFragmentByTag(CONTACT_LIST_TAG);
} }
......
<?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