--- a/res/menu/contact_list.xml Fri Jul 23 11:12:14 2010 +0200
+++ b/res/menu/contact_list.xml Fri Jul 23 13:32:00 2010 +0200
@@ -6,6 +6,9 @@
<item android:id="@+id/menu_change_status"
android:visible="true"
android:title="@string/contact_list_menu_status"/>
+ <item android:id="@+id/contact_list_menu_chatlist"
+ android:visible="true" android:icon="@drawable/ic_menu_chat_dashboard"
+ android:title="@string/chat_menu_change_chat"/>
<item android:id="@+id/contact_list_menu_settings"
android:visible="true"
android:title="@string/contact_list_menu_settings"
--- a/src/com/beem/project/beem/ui/Chat.java Fri Jul 23 11:12:14 2010 +0200
+++ b/src/com/beem/project/beem/ui/Chat.java Fri Jul 23 13:32:00 2010 +0200
@@ -43,19 +43,18 @@
*/
package com.beem.project.beem.ui;
+import java.text.DateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Date;
-import java.text.DateFormat;
import org.jivesoftware.smack.util.StringUtils;
import android.app.Activity;
-import android.app.AlertDialog;
+import android.app.Dialog;
import android.content.ComponentName;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
@@ -74,9 +73,9 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
@@ -91,10 +90,11 @@
import com.beem.project.beem.service.aidl.IBeemRosterListener;
import com.beem.project.beem.service.aidl.IChat;
import com.beem.project.beem.service.aidl.IChatManager;
+import com.beem.project.beem.service.aidl.IChatManagerListener;
import com.beem.project.beem.service.aidl.IMessageListener;
-import com.beem.project.beem.service.aidl.IChatManagerListener;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.ui.dialogs.builders.ChatList;
import com.beem.project.beem.utils.BeemBroadcastReceiver;
import com.beem.project.beem.utils.Status;
@@ -272,10 +272,8 @@
try {
final List<Contact> openedChats = mChatManager.getOpenedChatList();
Log.d(TAG, "opened chats = " + openedChats);
- if (openedChats.size() > 0)
- createChatSwitcherDialog(openedChats);
- else
- createNoActiveChatsDialog();
+ Dialog chatList = new ChatList(Chat.this, openedChats).create();
+ chatList.show();
} catch (RemoteException e) {
Log.e(TAG, e.getMessage());
}
@@ -295,41 +293,6 @@
}
/**
- * Create the change chat dialog.
- * @param openedChats A list containing the JID of participants of the opened chats.
- */
- private void createChatSwitcherDialog(final List<Contact> openedChats) {
- CharSequence[] items = new CharSequence[openedChats.size()];
-
- int i = 0;
- for (Contact c : openedChats) {
- items[i++] = c.getName();
- }
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.chat_dialog_change_chat_title));
- builder.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- Intent chatIntent = new Intent(getApplicationContext(), com.beem.project.beem.ui.Chat.class);
- chatIntent.setData((openedChats.get(item)).toUri());
- startActivity(chatIntent);
- }
- });
- AlertDialog chatSwitcherDialog = builder.create();
- chatSwitcherDialog.show();
- }
-
- /**
- * Create a dialog which notify the user that there're not another one active chat.
- */
- private void createNoActiveChatsDialog() {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(getString(R.string.chat_no_more_chats));
- AlertDialog noActiveChatsDialog = builder.create();
- noActiveChatsDialog.show();
- }
-
- /**
* Change the displayed chat.
* @param contact the targeted contact of the new chat
* @throws RemoteException If a Binder remote-invocation error occurred.
--- a/src/com/beem/project/beem/ui/ContactList.java Fri Jul 23 11:12:14 2010 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri Jul 23 13:32:00 2010 +0200
@@ -43,13 +43,12 @@
package com.beem.project.beem.ui;
import java.util.ArrayList;
-import java.util.LinkedList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import org.jivesoftware.smack.util.StringUtils;
@@ -76,6 +75,8 @@
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.AdapterView;
+import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
@@ -83,21 +84,21 @@
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
-import android.widget.AdapterView.AdapterContextMenuInfo;
-import android.widget.AdapterView.OnItemClickListener;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
import com.beem.project.beem.service.PresenceAdapter;
import com.beem.project.beem.service.aidl.IBeemRosterListener;
+import com.beem.project.beem.service.aidl.IChatManager;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppFacade;
import com.beem.project.beem.ui.dialogs.builders.Alias;
+import com.beem.project.beem.ui.dialogs.builders.ChatList;
import com.beem.project.beem.ui.dialogs.builders.DeleteContact;
import com.beem.project.beem.ui.dialogs.builders.ResendSubscription;
import com.beem.project.beem.utils.BeemBroadcastReceiver;
+import com.beem.project.beem.utils.SortedList;
import com.beem.project.beem.utils.Status;
-import com.beem.project.beem.utils.SortedList;
/**
* The contact list activity displays the roster of the user.
@@ -130,6 +131,7 @@
private IRoster mRoster;
private Contact mSelectedContact;
private IXmppFacade mXmppFacade;
+ private IChatManager mChatManager;
private SharedPreferences mSettings;
private LayoutInflater mInflater;
private BeemBanner mAdapterBanner;
@@ -169,6 +171,16 @@
case R.id.menu_disconnect:
stopService(SERVICE_INTENT);
finish();
+ case R.id.contact_list_menu_chatlist:
+ List<Contact> openedChats;
+ try {
+ openedChats = mChatManager.getOpenedChatList();
+ Log.d(TAG, "opened chats = " + openedChats);
+ Dialog chatList = new ChatList(ContactList.this, openedChats).create();
+ chatList.show();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
return true;
default:
return false;
@@ -235,7 +247,7 @@
break;
case R.id.contact_list_context_menu_userinfo_subscription:
Dialog subscription = new ResendSubscription(ContactList.this,
- mXmppFacade, mSelectedContact).create();
+ mXmppFacade, mSelectedContact).create();
subscription.show();
result = true;
break;
@@ -456,7 +468,7 @@
if (!mListGroup.contains(group)) {
mListGroup.add(mListGroup.size() - 1, group);
List<Contact> tmplist = new SortedList<Contact>(
- new LinkedList<Contact>(), mComparator);
+ new LinkedList<Contact>(), mComparator);
mContactOnGroup.put(group, tmplist);
}
mContactOnGroup.get(group).remove(contact);
@@ -539,11 +551,11 @@
String noGroup = getString(R.string.contact_list_no_group);
String allGroup = getString(R.string.contact_list_all_contact);
final boolean add = ((!hideDisconnected || Status.statusOnline(contact.getStatus())) && // must show and
- (
- (listName.equals(noGroup) && groups.isEmpty()) || // in no group
- groups.contains(listName) || // or in current
- listName.equals(allGroup) // or in all
- ));
+ (
+ (listName.equals(noGroup) && groups.isEmpty()) || // in no group
+ groups.contains(listName) || // or in current
+ listName.equals(allGroup) // or in all
+ ));
mHandler.post(new Runnable() {
public void run() {
mListContact.remove(contact);
@@ -642,7 +654,7 @@
if (curContact != null) {
TextView v = (TextView) view.findViewById(R.id.contactlistpseudo);
LevelListDrawable mStatusDrawable = (LevelListDrawable) getResources()
- .getDrawable(R.drawable.status_icon);
+ .getDrawable(R.drawable.status_icon);
mStatusDrawable.setLevel(curContact.getStatus());
v.setCompoundDrawablesWithIntrinsicBounds(mStatusDrawable, null, null, null);
v.setText(curContact.getName());
@@ -748,7 +760,6 @@
try {
mRoster = mXmppFacade.getRoster();
if (mRoster != null) {
- List<Contact> tmpContactList = mRoster.getContactList();
List<String> tmpGroupList = mRoster.getGroupsNames();
Collections.sort(tmpGroupList);
mListGroup.clear();
@@ -764,7 +775,8 @@
String group = getString(R.string.contact_list_all_contact);
buildContactList(group);
mRoster.addRosterListener(mBeemRosterListener);
- Log.d(TAG, "add rester listneer");
+ Log.d(TAG, "add roster listener");
+ mChatManager = mXmppFacade.getChatManager();
}
} catch (RemoteException e) {
e.printStackTrace();
@@ -779,6 +791,7 @@
e.printStackTrace();
}
mXmppFacade = null;
+ mChatManager = null;
mRoster = null;
mListContact.clear();
mListGroup.clear();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/dialogs/builders/ChatList.java Fri Jul 23 13:32:00 2010 +0200
@@ -0,0 +1,90 @@
+/*
+ BEEM is a videoconference application on the Android Platform.
+
+ Copyright (C) 2009 by Frederic-Charles Barthelery,
+ Jean-Manuel Da Silva,
+ Nikita Kozlov,
+ Philippe Lago,
+ Jean Baptiste Vergely,
+ Vincent Veronis.
+
+ This file is part of BEEM.
+
+ BEEM is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ BEEM is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with BEEM. If not, see <http://www.gnu.org/licenses/>.
+
+ Please send bug reports with examples or suggestions to
+ contact@beem-project.com or http://dev.beem-project.com/
+
+ Epitech, hereby disclaims all copyright interest in the program "Beem"
+ written by Frederic-Charles Barthelery,
+ Jean-Manuel Da Silva,
+ Nikita Kozlov,
+ Philippe Lago,
+ Jean Baptiste Vergely,
+ Vincent Veronis.
+
+ Nicolas Sadirac, November 26, 2009
+ President of Epitech.
+
+ Flavien Astraud, November 26, 2009
+ Head of the EIP Laboratory.
+
+*/
+package com.beem.project.beem.ui.dialogs.builders;
+
+import java.util.List;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.Contact;
+
+/**
+ * Create the change chat dialog.
+ */
+public class ChatList extends AlertDialog.Builder {
+
+ //private static final String TAG = "Dialogs.Builders > Chat list";
+
+ /**
+ * Constructor.
+ * @param context context activity.
+ * @param openedChats A list containing the JID of participants of the opened chats.
+ */
+ public ChatList(final Context context, final List<Contact> openedChats) {
+ super(context);
+
+ if (openedChats.size() > 0) {
+ CharSequence[] items = new CharSequence[openedChats.size()];
+
+ int i = 0;
+ for (Contact c : openedChats) {
+ items[i++] = c.getName();
+ }
+ setTitle(R.string.chat_dialog_change_chat_title);
+ setItems(items, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ Intent chatIntent = new Intent(context, com.beem.project.beem.ui.Chat.class);
+ chatIntent.setData((openedChats.get(item)).toUri());
+ context.startActivity(chatIntent);
+ }
+ });
+ } else {
+ setMessage(R.string.chat_no_more_chats);
+ }
+ }
+}