merge
authorNikita Kozlov <nikita@beem-project.com>
Fri, 25 Sep 2009 17:57:55 +0200
changeset 391 6dd5e802c6fb
parent 390 d9737e4bc517 (current diff)
parent 389 e6161048130d (diff)
child 392 73f7707528f0
merge
AndroidManifest.xml
src/com/beem/project/beem/jingle/JingleService.java
src/com/beem/project/beem/ui/ContactList.java
--- a/AndroidManifest.xml	Fri Sep 25 17:53:50 2009 +0200
+++ b/AndroidManifest.xml	Fri Sep 25 17:57:55 2009 +0200
@@ -44,6 +44,12 @@
 					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
 			</intent-filter>
 		</activity>
+		<activity android:name=".jingle.demo.JingleCallActivity" android:label="JingleDemoCall">
+			<intent-filter>
+				<action android:name="android.intent.action.MAIN" />
+				<category android:name="android.intent.category.LAUNCHER" />
+			</intent-filter>
+		</activity>
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
 			<intent-filter>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/jingle_call_activity.xml	Fri Sep 25 17:57:55 2009 +0200
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+	android:layout_width="wrap_content" android:layout_height="wrap_content"
+	android:orientation="vertical">
+	<TextView android:text="Jid:" android:id="@+id/jingledemocalljidlabel"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+	<EditText android:id="@+id/jingledemocalljid"
+		android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
+	<TextView android:text="Password:" android:id="@+id/jingledemocallpasswordlabel"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+	<EditText android:id="@+id/jingledemocallpassword"
+		android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textPassword" ></EditText>
+
+	<Button android:text="Connexion" android:id="@+id/jingledemocallconnectbutton"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
+	<TextView android:text="Call who :" android:id="@+id/jingledemocallreceiverlabel"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+
+<EditText android:text="" android:id="@+id/jingledemocallreceiver" android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
+
+<Button android:text="Call" android:id="@+id/jingledemocallbutton" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
+</LinearLayout>
--- a/res/values-en/strings.xml	Fri Sep 25 17:53:50 2009 +0200
+++ b/res/values-en/strings.xml	Fri Sep 25 17:57:55 2009 +0200
@@ -207,5 +207,6 @@
 	 <string name="contact_list_menu_add_contact">Add a contact</string>
 	 <string name="contact_list_menu_settings">Settings</string>
 	 <string name="contact_list_all_contact">All contacts</string>
+	 <string name="contact_list_no_group">No group</string>
 
 </resources>
--- a/res/values-fr/strings.xml	Fri Sep 25 17:53:50 2009 +0200
+++ b/res/values-fr/strings.xml	Fri Sep 25 17:57:55 2009 +0200
@@ -201,5 +201,6 @@
 	 <string name="contact_list_menu_add_contact">Ajouter un contact</string>
 	 <string name="contact_list_menu_settings">Paramètres</string>
 	 <string name="contact_list_all_contact">Tous les contacts</string>
+	 <string name="contact_list_no_group">Aucun groupe</string>
 
 </resources>
--- a/src/com/beem/project/beem/jingle/JingleService.java	Fri Sep 25 17:53:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/JingleService.java	Fri Sep 25 17:57:55 2009 +0200
@@ -40,9 +40,6 @@
 
 	mMediaManagers = new ArrayList<JingleMediaManager>();
 	mMediaManagers.add(new MicrophoneRTPManager(bt));
-	//mJingleManager = new JingleManager(xmppConnection, mMediaManagers);
-	//mJingleManager.addJingleSessionRequestListener(new BeemJingleSessionRequestListener());
-
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/demo/JingleCallActivity.java	Fri Sep 25 17:57:55 2009 +0200
@@ -0,0 +1,88 @@
+package com.beem.project.beem.jingle.demo;
+
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.util.StringUtils;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.beem.project.beem.R;
+import com.beem.project.beem.jingle.JingleService;
+
+/**
+ * Activity used to test Jingle call.
+ * @author darisk
+ */
+public class JingleCallActivity extends Activity {
+
+    private XMPPConnection mConnection;
+    private ConnectionConfiguration mConf;
+    private JingleService mJingle;
+
+    private Button mBtconnect;
+    private Button mBtcall;
+    private EditText mEdJID;
+    private EditText mEdPassword;
+    private EditText mEdReceiver;
+
+    /**
+     * Constructor.
+     */
+    public JingleCallActivity() {
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+	// TODO Auto-generated method stub
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.jingle_call_activity);
+	// localhost
+	mConf = new ConnectionConfiguration("10.0.2.2", 5222);
+	mEdJID = (EditText) findViewById(R.id.jingledemocalljid);
+	mEdPassword = (EditText) findViewById(R.id.jingledemocallpassword);
+	mEdReceiver = (EditText) findViewById(R.id.jingledemocallreceiver);
+	mBtconnect = (Button) findViewById(R.id.jingledemocallconnectbutton);
+	mBtconnect.setOnClickListener(new OnClickListener() {
+
+	    @Override
+	    public void onClick(View arg0) {
+		String jid = mEdJID.getText().toString();
+		String login = StringUtils.parseName(jid);
+		mConnection = new XMPPConnection(mConf);
+		String password = mEdPassword.getText().toString();
+		try {
+		    mConnection.connect();
+	            mConnection.login(login, password);
+	            mJingle = new JingleService(mConnection);
+	            mBtcall.setEnabled(true);
+                } catch (XMPPException e) {
+	            // TODO Auto-generated catch block
+	            e.printStackTrace();
+                }
+	    }
+
+	});
+	mBtcall = (Button) findViewById(R.id.jingledemocallbutton);
+	mBtcall.setOnClickListener(new OnClickListener() {
+	    @Override
+	    public void onClick(View arg0) {
+		String jid = mEdReceiver.getText().toString();
+		if (!"".equals(jid)) {
+		    mJingle.call(jid);
+		    Toast.makeText(JingleCallActivity.this, "Appel en cours", Toast.LENGTH_SHORT);
+		} else
+		    Toast.makeText(JingleCallActivity.this, "Remplir le champ (JID complet en  toto@tutu.com/truc)",
+			    Toast.LENGTH_SHORT);
+	    }
+	});
+
+    }
+
+}
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri Sep 25 17:53:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Sep 25 17:57:55 2009 +0200
@@ -1,5 +1,6 @@
 package com.beem.project.beem.ui;
 
+import java.security.spec.MGF1ParameterSpec;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -160,6 +161,12 @@
 	unbindService(mServConn);
     }
 
+    @Override
+    public void onContentChanged() {
+	super.onContentChanged();
+	Log.i("OO", "CHANGED");
+    }
+
     /**
      * Comparator Contact by Name.
      */
@@ -267,7 +274,7 @@
 	@Override
 	public boolean onItemLongClick(AdapterView<?> arg0, View v, int pos, long lpos) {
 	    Contact c = mListContact.get(pos);
-	    ContactDialog dialogContact = new ContactDialog(ContactList.this, c, "MYSTATICGROUP");
+	    ContactDialog dialogContact = new ContactDialog(ContactList.this, c, mCurGroup);
 	    dialogContact.setOwnerActivity(ContactList.this);
 	    dialogContact.show();
 	    return true;
@@ -362,8 +369,21 @@
 	}
 
 	@Override
-	public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
-	    // TODO Auto-generated method stub
+	public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {	    
+	    List<Contact> tmpContactList = mContactOnGroup.get(group);
+	    Contact curContact = null;
+	    for (Contact c : tmpContactList) {
+		if (jid.equals(c.getJID())) {
+		    curContact = c;
+		    tmpContactList.remove(c);
+		    c.getGroups().remove(group);
+		    break;
+		}
+	    }
+	    if (curContact != null && curContact.getGroups().size() == 0) {
+		mContactOnGroup.get(getString(R.string.contact_list_no_group)).add(curContact);
+	    }
+	    mHandler.post(new RunnableChange());
 	}
 
 	/**
@@ -371,7 +391,6 @@
 	 */
 	@Override
 	public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
-	    // TODO gerer la presence au niveau de chaque ressources ?
 	    String from = presence.getFrom();
 	    boolean resfound = false;
 	    for (Contact curContact : mListContact) {
@@ -584,16 +603,20 @@
 		    List<String> tmpGroupList = mRoster.getGroupsNames();
 		    Collections.sort(tmpGroupList);
 		    mListGroup = tmpGroupList;
+		    mListGroup.add(getString(R.string.contact_list_no_group));
 		    if (tmpGroupList.size() > 0) {
+			List<Contact> tmpNoGroup = new ArrayList<Contact>();
 			for (String s : tmpGroupList) {
 			    List<Contact> tmpList = new ArrayList<Contact>();
 			    for (Contact c : tmpContactList) {
-				if (c.getGroups().contains(s)) {
+				if (c.getGroups().size() == 0 && !tmpNoGroup.contains(c))
+				    tmpNoGroup.add(c);
+				else if (c.getGroups().contains(s))
 				    tmpList.add(c);
-				}
 			    }
 			    mContactOnGroup.put(s, tmpList);
 			}
+			mContactOnGroup.put(getString(R.string.contact_list_no_group), tmpNoGroup);
 			mCurGroup = tmpGroupList.get(0);
 		    } else {
 			mCurGroup = null;