Super mercurial le retour du commit oubliƩ apres le merge du pull -f -r19
authorPhilippe Lago <lago_p@epitech.net>
Wed, 08 Apr 2009 00:02:09 +0200
changeset 84 9a4dbd7fe546
parent 71 fb3e3ed4bafc (diff)
parent 80 29f0d6a23321 (current diff)
child 85 7d0e36aa1be5
Super mercurial le retour du commit oubliƩ apres le merge du pull -f -r19
res/layout/messagelist.xml
res/layout/sendim.xml
res/values/strings.xml
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/SendIM.java
--- a/AndroidManifest.xml	Tue Apr 07 10:25:40 2009 +0200
+++ b/AndroidManifest.xml	Wed Apr 08 00:02:09 2009 +0200
@@ -2,7 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 	package="com.beem.project.beem" android:versionCode="1"
 	android:versionName="1.0">
-	<application android:label="@string/app_name" android:name="BeemApplication">
+	<application android:label="@string/app_name" android:name="BeemApplication" android:theme="@style/customtheme">
 		<activity android:name=".ui.ContactList" android:label="@string/app_name">
 			<intent-filter>
 				<action android:name="android.intent.action.MAIN" />
Binary file res/drawable/background.png has changed
Binary file res/drawable/xmpp.jpg has changed
--- a/res/layout/messagelist.xml	Tue Apr 07 10:25:40 2009 +0200
+++ b/res/layout/messagelist.xml	Wed Apr 08 00:02:09 2009 +0200
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <TextView xmlns:android="http://schemas.android.com/apk/res/android" id="text1"
           android:textSize="2mm"
-          android:textColor="@color/black"
           android:singleLine="false"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"/>
\ No newline at end of file
--- a/res/layout/sendim.xml	Tue Apr 07 10:25:40 2009 +0200
+++ b/res/layout/sendim.xml	Wed Apr 08 00:02:09 2009 +0200
@@ -2,8 +2,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent" 
-    android:layout_height="fill_parent"
-    android:background="@color/blue_sky">
+    android:layout_height="fill_parent">
 
     <ListView android:id="@android:id/list"
         android:layout_width="fill_parent" 
--- a/res/values/strings.xml	Tue Apr 07 10:25:40 2009 +0200
+++ b/res/values/strings.xml	Wed Apr 08 00:02:09 2009 +0200
@@ -28,7 +28,7 @@
 	<string name="PreferenceProxyTypeSocks5">SOCKS5</string>
 
 	<!--  SendIM class -->
-	<string name="SendIMSays">says :\n</string>
+	<string name="SendIMSays"> says :\n</string>
 	<string name="SendIMHint">Tip text here</string>
 	<string name="SendIMState">Is : </string>
 	<string name="SendIMFrom">and is speaking from : </string>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/values/style.xml	Wed Apr 08 00:02:09 2009 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <style name="customtheme" parent="android:Theme">
+ </style>
+ 
+  	<style name="customtheme.login"> 
+    <item name="android:windowBackground">@drawable/background</item>
+    <item name="android:windowNoTitle">true</item>
+
+ 
+  </style>        
+</resources>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java	Tue Apr 07 10:25:40 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Wed Apr 08 00:02:09 2009 +0200
@@ -91,7 +91,7 @@
 	} else {
 	    mConnectionConfiguration = new ConnectionConfiguration(mHost);
 	}
-	mConnectionConfiguration.setSendPresence(false);
+	mConnectionConfiguration.setSendPresence(true);
     }
 
     /**
--- a/src/com/beem/project/beem/ui/SendIM.java	Tue Apr 07 10:25:40 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Wed Apr 08 00:02:09 2009 +0200
@@ -4,7 +4,10 @@
 
 import android.app.ListActivity;
 import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.RemoteException;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
@@ -16,8 +19,15 @@
 import android.widget.ArrayAdapter;
 import android.widget.EditText;
 
+import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.R;
 import com.beem.project.beem.service.Contact;
+import com.beem.project.beem.service.Message;
+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.IXmppFacade;
 
 /**
  * @author barbu This activity class provide the view for instant messaging
@@ -31,7 +41,15 @@
     private ArrayAdapter<String> mAdapter;
     private SendIMDialogSmiley mSmyDialog;
     private SharedPreferences mSet;
+    private SharedPreferences mGlobalSettings;
+    private BeemApplication mBeemApplication;
+    private Handler mHandler;
+    private IXmppFacade mService = null;
     private Contact mContact;
+    private IChatManager mChatManager;
+    private IChatManagerListener mChatManagerListener;
+    private IMessageListener mMessageListener;
+    private IChat mChat;
 
     /**
      * Constructor.
@@ -46,11 +64,15 @@
     @Override
     public void onCreate(Bundle saveBundle) {
 	super.onCreate(saveBundle);
-
+	mHandler = new Handler();
+	mChatManagerListener = new OnChatListener();
+	mMessageListener = new OnMessageListener();
+	mBeemApplication = BeemApplication.getApplication(this);
 	setContentView(R.layout.sendim);
 	mToSend = (EditText) findViewById(R.id.userText);
 	mSet = getSharedPreferences("lol", MODE_PRIVATE);
 	mSmyDialog = new SendIMDialogSmiley(this, mSet);
+	mGlobalSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
 
 	mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist,
 		mMessages);
@@ -65,7 +87,16 @@
     @Override
     public void onStart() {
 	super.onStart();
-
+	mBeemApplication.startBeemService();
+	mService = mBeemApplication.getXmppFacade();
+	try {
+	    mChatManager = mService.getChatManager();
+	    mChatManager.addChatCreationListener(mChatManagerListener);
+	    mChat = mChatManager.createChat(mContact, mMessageListener);
+	} catch (RemoteException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	}
     }
 
     /**
@@ -82,19 +113,17 @@
      */
     private void sendText() {
 	String text = mToSend.getText().toString();
+	String from = mGlobalSettings.getString(getString(R.string.PreferenceJID), "You");
 	if (!text.equals("")) {
-	    /*
-	     * Prepare the message to be send
-	     */
-	    /* Message msg = new Message("barbu", Message.Type.chat); */
-	    /* msg.setBody(text); */
-	    /*
-	     * Rien a voir il faut changer le mContact.getJID() et remplacer
-	     * avec son pseudo cetait juste un test pour savoir qu'on recupere
-	     * bien le contact a qui envoyer les infos
-	     */
-	    mAdapter.add(mContact.getJID() + " "
-		    + getString(R.string.SendIMSays) + text);
+	    Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
+	    msg.setBody(text);
+	    try {
+		mChat.sendMessage(msg);
+	    } catch (RemoteException e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	    }
+	    mAdapter.add(from + getString(R.string.SendIMSays) + text);
 	    mToSend.setText(null);
 	}
     }
@@ -139,4 +168,27 @@
 		return false;
 	}
     }
+    
+    private class OnChatListener extends IChatManagerListener.Stub {
+
+	@Override
+	public void chatCreated(IChat chat, boolean locally)
+		throws RemoteException {
+	    Log.i("LOG", "chatCreated");
+	    
+	}
+	
+    }
+    
+    private class OnMessageListener extends IMessageListener.Stub {
+
+	@Override
+	public void processMessage(IChat chat, Message msg)
+		throws RemoteException {
+	    Log.i("LOG", "processMessage");
+	    mAdapter.add(mContact.getJID() + " "
+		    + getString(R.string.SendIMSays) + msg.getBody());
+	}
+	
+    }
 }