--- a/AndroidManifest.xml Tue Apr 21 21:52:03 2009 +0200
+++ b/AndroidManifest.xml Tue Apr 21 22:49:38 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" android:theme="@style/customtheme.contactList" android:icon="@drawable/logo">
+ <application android:label="@string/app_name" android:name="BeemApplication" android:theme="@style/customtheme.contactList" android:icon="@drawable/signal">
<activity android:name=".ui.ContactList" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -12,6 +12,7 @@
</activity>
<activity android:name=".ui.ContactListSettings" android:label="@string/app_name" />
<activity android:name=".ui.SendIM" android:label="@string/app_name" />
+ <activity android:name=".ui.ChangeStatus" android:label="@string/app_name" />
<activity android:name=".ui.AccountCreation" android:label="@string/app_name" />
<service android:name="BeemService" android:enabled="true"
android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
Binary file res/drawable/signal.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/changestatus.xml Tue Apr 21 22:49:38 2009 +0200
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <Spinner android:id="@+id/ChangeStatusSpinner"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:drawSelectorOnTop="true"/>
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/ChangeStatusText"
+ android:textColor="@color/blue_sky"/>
+
+ <EditText android:id="@+id/ChangeStatusText"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:lines="6"/>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <Button android:id="@+id/ChangeStatusOk"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:text="@string/OkButton"/>
+
+ <Button android:id="@+id/ChangeStatusClear"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:text="@string/ClearButton"/>
+ </LinearLayout>
+</LinearLayout>
\ No newline at end of file
--- a/res/layout/contactlistsettings.xml Tue Apr 21 21:52:03 2009 +0200
+++ b/res/layout/contactlistsettings.xml Tue Apr 21 22:49:38 2009 +0200
@@ -13,26 +13,26 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Host/Port:"
- android:minWidth="70dp"
+ android:minWidth="90dp"
/>
<EditText android:id="@+id/host"
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="16sp"
android:autoText="false"
android:capitalize="none"
- android:minWidth="150dp"
+ android:layout_weight="2"
android:scrollHorizontally="true"/>
<EditText android:id="@+id/port"
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="16sp"
android:autoText="false"
- android:minWidth="80dp"
android:capitalize="none"
+ android:layout_weight="3"
android:scrollHorizontally="true"/>
</LinearLayout>
@@ -45,15 +45,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Userid:"
- android:minWidth="70dp"
+ android:minWidth="90dp"
/>
<EditText android:id="@+id/userid"
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="16sp"
android:autoText="false"
- android:minWidth="250dp"
android:capitalize="none"
android:scrollHorizontally="true"/>
</LinearLayout>
@@ -66,23 +65,23 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password:"
- android:minWidth="70dp"
+ android:minWidth="90dp"
/>
<EditText android:id="@+id/password"
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:password="true"
android:textSize="16sp"
android:autoText="false"
- android:minWidth="250dp"
android:capitalize="none"
android:scrollHorizontally="true"/>
</LinearLayout>
<Button android:id="@+id/ok"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
android:text="OK">
<requestFocus/>
</Button>
--- a/res/values/strings.xml Tue Apr 21 21:52:03 2009 +0200
+++ b/res/values/strings.xml Tue Apr 21 22:49:38 2009 +0200
@@ -1,19 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Beem</string>
-
+ <string name="OkButton">Ok</string>
+ <string name="ClearButton">Clear</string>
+
<!-- Beem class -->
<string name="BeemJabberID">Jabber ID</string>
+ <!-- BeemApplication class -->
+
+ <string name="BeemApplicationConnect">Connecting...</string>
+
<!-- BeemService class -->
+
<string name="BeemServiceDescription">Use the Beem Service</string>
<string name="BeemServiceCreated">BeemService Created</string>
<string name="BeemServiceDestroyed">BeemService destroyed</string>
<!-- Preferences informations -->
+
<string name="PreferenceFileName">Beem</string>
-
<string name="PreferenceHostKey">host</string>
<string name="PreferenceJID">Jabber ID</string><string name="PreferenceLoginKey">login</string><string name="PreferencePasswordKey">password</string>
<string name="PreferencePortKey">port</string>
@@ -28,12 +35,18 @@
<string name="PreferenceProxyTypeSocks5">SOCKS5</string>
<!-- SendIM class -->
+
<string name="SendIMSays"> says :\n</string>
+ <string name="SendIMYouSay">You say :\n</string>
<string name="SendIMToSendHint">Tip text here</string>
<string name="SendIMState">Is : </string>
<string name="SendIMFrom">and is speaking from : </string>
<string name="SendIMSmiley">Insert a smiley</string>
<string name="SendIMLoginHint">login</string>
<string name="SendIMNoStatusSet">No status set</string>
+
+ <!-- ChangeStatus class -->
+
+ <string name="ChangeStatusText">Type here your status message :</string>
</resources>
--- a/res/values/style.xml Tue Apr 21 21:52:03 2009 +0200
+++ b/res/values/style.xml Tue Apr 21 22:49:38 2009 +0200
@@ -6,7 +6,7 @@
<style name="customtheme.contactList">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:windowNoTitle">true</item>
- <item name="android:textColor">#FFFF00</item>
+ <item name="android:textColor">#000000</item>
<item name="android:typeface">sans</item>
<item name="android:textSize">18sp</item>
@@ -15,9 +15,17 @@
<style name="customtheme.jungle">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:windowNoTitle">true</item>
- <item name="android:textColor">#FFFF00</item>
+ <item name="android:textColor">#FFFFFF</item>
<item name="android:typeface">sans</item>
<item name="android:textSize">18sp</item>
</style>
+ <style name="customtheme.spinner">
+ <item name="android:windowBackground">@drawable/background</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:textColor">#FF0000</item>
+ <item name="android:typeface">sans</item>
+ <item name="android:textSize">18sp</item>
+ </style>
+
</resources>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemApplication.java Tue Apr 21 21:52:03 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java Tue Apr 21 22:49:38 2009 +0200
@@ -5,7 +5,6 @@
import java.util.LinkedList;
import java.util.List;
-
import android.app.Activity;
import android.app.Application;
import android.app.ProgressDialog;
@@ -13,15 +12,12 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
-import android.widget.Toast;
-
import com.beem.project.beem.service.aidl.IBeemConnectionListener;
import com.beem.project.beem.service.aidl.IXmppConnection;
import com.beem.project.beem.service.aidl.IXmppFacade;
@@ -95,8 +91,8 @@
mBeemApp.mActivity = activity;
mBeemApp.mProgressDialog = new ProgressDialog(activity);
mBeemApp.mProgressDialog.setTitle("Beem");
- mBeemApp.mProgressDialog.setIcon(R.drawable.logo);
- mBeemApp.mProgressDialog.setMessage("Connexion en cours");
+ mBeemApp.mProgressDialog.setIcon(R.drawable.signal);
+ mBeemApp.mProgressDialog.setMessage("Connecting...");
mBeemApp.mApplicationContext = activity.getApplication();
mBeemApp.mPrivateResources = activity.getResources();
mBeemApp.onCreate();
@@ -126,6 +122,15 @@
}
}
+ public synchronized void unbindBeemService() {
+
+ if (mIsConnected) {
+ mApplicationContext.unbindService(mServConn);
+ mIsConnected = false;
+ }
+
+ }
+
/**
* Get the facade to use to access the Beem service.
* @return the facade or null if the application is not connected to the beem service.
@@ -160,15 +165,15 @@
}
private class ConnectionRunnable implements Runnable {
- private String mErrorMsg;
-
+ private String mErrorMsg;
+
public ConnectionRunnable(String string) {
this.mErrorMsg = string;
}
@Override
public void run() {
- mBeemApp.mProgressDialog.setMessage(mErrorMsg);
+ mBeemApp.mProgressDialog.setMessage(mErrorMsg);
}
/**
@@ -206,7 +211,7 @@
@Override
public void connectionClosed() throws RemoteException {
// TODO Auto-generated method stub
- Log.e("BeemApp","test1");
+ Log.e("BeemApp", "test1");
}
@@ -215,8 +220,8 @@
*/
@Override
public void connectionClosedOnError() throws RemoteException {
- mBeemApp.mProgressDialog.setMessage("Connexion closed on error");
- Log.e(TAG,"onnectionClosedOnError");
+ mBeemApp.mProgressDialog.setMessage("Connection closed on error");
+ Log.e(TAG, "ConnectionClosedOnError");
// TODO afficher une notification et reafficher le progress dialog
}
@@ -252,7 +257,7 @@
@Override
public void reconnectionFailed() throws RemoteException {
// TODO Auto-generated method stub
- Log.e("BeemApp","test3");
+ Log.e("BeemApp", "test3");
}
--- a/src/com/beem/project/beem/service/BeemChatManager.java Tue Apr 21 21:52:03 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java Tue Apr 21 22:49:38 2009 +0200
@@ -141,9 +141,10 @@
public void chatCreated(Chat chat, boolean locally) {
IChat newchat = getChat(chat);
if (!locally) {
- chat.addMessageListener(mChatListener);
+ // chat.addMessageListener(mChatListener);
notifyNewChat(newchat);
}
+ chat.addMessageListener(mChatListener);
final int n = mRemoteChatCreationListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
@@ -162,7 +163,7 @@
private void notifyNewChat(IChat chat) {
try {
String text = chat.getParticipant().getJID();
- Notification notif = new Notification(com.beem.project.beem.R.drawable.logo, text, System
+ Notification notif = new Notification(com.beem.project.beem.R.drawable.signal, text, System
.currentTimeMillis());
notif.defaults = Notification.DEFAULT_ALL;
notif.flags = Notification.FLAG_AUTO_CANCEL;
--- a/src/com/beem/project/beem/service/PresenceAdapter.java Tue Apr 21 21:52:03 2009 +0200
+++ b/src/com/beem/project/beem/service/PresenceAdapter.java Tue Apr 21 22:49:38 2009 +0200
@@ -46,9 +46,4 @@
// TODO Auto-generated method stub
}
-
- public IBinder asBinder() {
- // TODO Auto-generated method stub
- return null;
- }
}
--- a/src/com/beem/project/beem/service/XmppFacade.java Tue Apr 21 21:52:03 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppFacade.java Tue Apr 21 22:49:38 2009 +0200
@@ -13,6 +13,7 @@
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppConnection;
import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.ui.ChangeStatus;
/**
* This class is a facade for the Beem Service.
@@ -96,14 +97,14 @@
Notification mStatusNotification;
String text = (msg == null ? "" : msg);
- mStatusNotification = new Notification(com.beem.project.beem.R.drawable.logo, text, System.currentTimeMillis());
+ mStatusNotification = new Notification(com.beem.project.beem.R.drawable.signal, text, System.currentTimeMillis());
mStatusNotification.defaults = Notification.DEFAULT_ALL;
mStatusNotification.flags = Notification.FLAG_NO_CLEAR;
// TODO
// mStatusNotification.contentView = ;
mStatusNotification.setLatestEventInfo(mBeemService, "Beem Status", text, PendingIntent.getActivity(
- mBeemService, 0, new Intent(), 0));
+ mBeemService, 0, new Intent(mBeemService,ChangeStatus.class), 0));
mBeemService.sendNotification(BeemService.NOTIFICATION_STATUS_ID, mStatusNotification);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java Tue Apr 21 22:49:38 2009 +0200
@@ -0,0 +1,141 @@
+package com.beem.project.beem.ui;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.RemoteException;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import com.beem.project.beem.BeemApplication;
+import com.beem.project.beem.BeemService;
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.Status;
+
+public class ChangeStatus extends Activity {
+
+ private TextView mTextStatus;
+ private Button mOk;
+ private Button mClear;
+ private Handler mHandler;
+ private BeemApplication mBeemApplication;
+ private IXmppFacade mService = null;
+ private Spinner mSpinner;
+ private static final String[] STATUS = { "Available for chat", "Available", "Busy", "Away", "Unavailable",
+ "Disconnected" };
+ private static final int DISCONNECTED_IDX = 5;
+ private static final int AVAILABLE_FOR_CHAT_IDX = 0;
+ private static final int AVAILABLE_IDX = 1;
+ private static final int BUSY_IDX = 2;
+ private static final int AWAY_IDX = 3;
+ private static final int UNAVAILABLE_IDX = 4;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.changestatus);
+
+ // Beem Application specific
+ mHandler = new Handler();
+ mBeemApplication = BeemApplication.getApplication(this);
+
+ mTextStatus = (TextView) findViewById(R.id.ChangeStatusText);
+ mOk = (Button) findViewById(R.id.ChangeStatusOk);
+ mClear = (Button) findViewById(R.id.ChangeStatusClear);
+ mOk.setOnClickListener(mOnClickOk);
+ mClear.setOnClickListener(mOnClickClear);
+
+ mSpinner = (Spinner) findViewById(R.id.ChangeStatusSpinner);
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, STATUS);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mSpinner.setAdapter(adapter);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mBeemApplication.startBeemService();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
+ @Override
+ public void run() {
+ mService = mBeemApplication.getXmppFacade();
+ }
+ });
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+// mBeemApplication.unbindBeemService();
+ }
+
+ private OnClickListener mOnClickOk = new OnClickListener() {
+ public void onClick(View v) {
+ if (v == mOk) {
+ String selected = (String) mSpinner.getSelectedItem();
+ if (selected != null) {
+ CharSequence msg = mTextStatus.getText();
+ int status = getStatusForService(selected);
+ if (status == Status.CONTACT_STATUS_DISCONNECT) {
+ stopService(new Intent(ChangeStatus.this, BeemService.class));
+ } else
+ try {
+ mService.changeStatus(status, msg.toString());
+
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ChangeStatus.this.finish();
+ }
+ } else if (v == mClear) {
+ mTextStatus.setText(null);
+ }
+
+ };
+ };
+
+ private OnClickListener mOnClickClear = new OnClickListener() {
+ public void onClick(View v) {
+ mTextStatus.setText(null);
+ };
+ };
+
+ private int getStatusForService(String item) {
+ int res = Status.CONTACT_STATUS_AVAILABLE;
+ for (int i = 0; i < ChangeStatus.STATUS.length; i++) {
+ String str = ChangeStatus.STATUS[i];
+ if (str.equals(item)) {
+ switch (i) {
+ case ChangeStatus.DISCONNECTED_IDX:
+ return Status.CONTACT_STATUS_DISCONNECT;
+ case ChangeStatus.AVAILABLE_FOR_CHAT_IDX:
+ return Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
+ case ChangeStatus.AVAILABLE_IDX:
+ return Status.CONTACT_STATUS_AVAILABLE;
+ case ChangeStatus.AWAY_IDX:
+ return Status.CONTACT_STATUS_AWAY;
+ case ChangeStatus.BUSY_IDX:
+ return Status.CONTACT_STATUS_BUSY;
+ case ChangeStatus.UNAVAILABLE_IDX:
+ return Status.CONTACT_STATUS_UNAVAILABLE;
+ default:
+ res = Status.CONTACT_STATUS_AVAILABLE;
+ break;
+ }
+ }
+ }
+ return res;
+ }
+}
--- a/src/com/beem/project/beem/ui/ContactList.java Tue Apr 21 21:52:03 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Tue Apr 21 22:49:38 2009 +0200
@@ -73,12 +73,19 @@
@Override
protected void onStart() {
super.onStart();
- mBeemApplication.startBeemService();
+ }
+
+ @Override
+ protected void onDestroy() {
+ // TODO Auto-generated method stub
+ super.onDestroy();
+ // mBeemApplication.unbindBeemService();
}
@Override
protected void onResume() {
super.onResume();
+ mBeemApplication.startBeemService();
/*
* @TODO: A ameliorer apres listener de nikita
*/
--- a/src/com/beem/project/beem/ui/SendIM.java Tue Apr 21 21:52:03 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java Tue Apr 21 22:49:38 2009 +0200
@@ -1,14 +1,11 @@
package com.beem.project.beem.ui;
-import java.util.ArrayList;
-
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
-import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
@@ -32,16 +29,14 @@
import com.beem.project.beem.service.aidl.IXmppFacade;
/**
- * This activity class provides the view for instant messaging
- * after selecting a correspondant.
- * @author barbu
+ * This activity class provides the view for instant messaging after selecting a correspondant.
+ * @author barbu
*/
-public class SendIM extends Activity implements OnClickListener,
- OnKeyListener {
+public class SendIM extends Activity implements OnClickListener, OnKeyListener {
private EditText mToSend;
- private ArrayList<String> mMessages = new ArrayList<String>();
- //private ArrayAdapter<String> mAdapter;
+ // private ArrayList<String> mMessages = new ArrayList<String>();
+ // private ArrayAdapter<String> mAdapter;
private SendIMDialogSmiley mSmyDialog;
private SharedPreferences mSet;
private SharedPreferences mGlobalSettings;
@@ -81,11 +76,10 @@
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);
- setListAdapter(mAdapter);*/
+ mGlobalSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+ /*
+ * mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist, mMessages); setListAdapter(mAdapter);
+ */
mToSend.setOnClickListener(this);
mToSend.setOnKeyListener(this);
@@ -93,9 +87,8 @@
mText = (TextView) findViewById(R.id.sendimlist);
mScrolling = (ScrollView) findViewById(R.id.sendimscroll);
}
-
- private void setViewHeader()
- {
+
+ private void setViewHeader() {
String status = mContact.getMsgState();
if (status == null)
status = getString(R.string.SendIMNoStatusSet);
@@ -107,39 +100,56 @@
@Override
public void onStart() {
super.onStart();
- //TODO cancel the notification if any
+ // TODO cancel the notification if any
if (mContact == null)
mContact = getIntent().getParcelableExtra("contact");
setViewHeader();
+ mService = mBeemApplication.getXmppFacade();
+
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
mBeemApplication.startBeemService();
- mService = mBeemApplication.getXmppFacade();
- try {
- mChatManager = mService.getChatManager();
- mChatManager.addChatCreationListener(mChatManagerListener);
- mChat = mChatManager.createChat(mContact, mMessageListener);
- String text = mChat.getLastMessages();
- if (! "".equals(text)) {
- mText.append(text);
- mChat.clearLastMessages();
+ mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
+
+ @Override
+ public void run() {
+ mService = mBeemApplication.getXmppFacade();
+ try {
+ mChatManager = mService.getChatManager();
+ mChatManager.addChatCreationListener(mChatManagerListener);
+ mChat = mChatManager.createChat(mContact, mMessageListener);
+ String text = mChat.getLastMessages();
+ if (!"".equals(text)) {
+ mText.append(text);
+ mChat.clearLastMessages();
+ }
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ });
+
}
@Override
protected void onDestroy() {
super.onDestroy();
- try {
- mChatManager.removeChatCreationListener(mChatManagerListener);
- mChatManager.destroyChat(mChat);
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ if (mChatManager != null) {
+ try {
+ mChatManager.removeChatCreationListener(mChatManagerListener);
+ mChatManager.destroyChat(mChat);
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
+// mBeemApplication.unbindBeemService();
}
-
+
/**
* Abstract method inherited from OnClickListener
*/
@@ -148,16 +158,13 @@
}
/**
- * This method send a message to the server over the XMPP connection and
- * display it on activity view TODO : Exception si la connexion se coupe
- * pendant la conversation
+ * This method send a message to the server over the XMPP connection and display it on activity view TODO :
+ * Exception si la connexion se coupe pendant la conversation
*/
private void sendText() {
if (mSpeak)
mSpeak = false;
String text = mToSend.getText().toString();
- String from = mGlobalSettings.getString(
- getString(R.string.PreferenceJID), "You");
if (!text.equals("")) {
Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
msg.setBody(text);
@@ -167,9 +174,8 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
- //mAdapter.add(from + getString(R.string.SendIMSays) + text);
if (!mSpeak)
- mText.append(from + getString(R.string.SendIMSays) + text + "\n");
+ mText.append(getString(R.string.SendIMYouSay) + text + "\n");
else
mText.append(text + "\n");
mToSend.setText(null);
@@ -196,9 +202,7 @@
/**
* Callback for menu creation.
- *
- * @param menu
- * the menu created
+ * @param menu the menu created
* @return true on success, false otherwise
*/
@Override
@@ -223,8 +227,7 @@
private class OnChatListener extends IChatManagerListener.Stub {
@Override
- public void chatCreated(IChat chat, boolean locally)
- throws RemoteException {
+ public void chatCreated(IChat chat, boolean locally) throws RemoteException {
Log.i("LOG", "chatCreated");
}
@@ -234,31 +237,29 @@
private class OnMessageListener extends IMessageListener.Stub {
@Override
- public void processMessage(IChat chat, Message msg)
- throws RemoteException {
+ public void processMessage(IChat chat, Message msg) throws RemoteException {
Log.i("LOG", "processMessage");
- /*mAdapter.add(mContact.getJID() + " "
- + getString(R.string.SendIMSays) + msg.getBody());*/
- if(chat!= mChat)
+ /*
+ * mAdapter.add(mContact.getJID() + " " + getString(R.string.SendIMSays) + msg.getBody());
+ */
+ if (chat != mChat)
return;
-
+
final Message m = msg;
mHandler.post(new Runnable() {
-
- @Override
- public void run() {
- if (m.getBody() != null)
- {
- if (!mSpeak)
- mText.append(m.getBody() + "\n");
- else
- mText.append(mContact.getJID() + " "
- + getString(R.string.SendIMSays) + m.getBody() + "\n");
- mSpeak = false;
- mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
- mToSend.requestFocus();
- }
- }
+
+ @Override
+ public void run() {
+ if (m.getBody() != null) {
+ if (!mSpeak)
+ mText.append(m.getBody() + "\n");
+ else
+ mText.append(mContact.getJID() + " " + getString(R.string.SendIMSays) + m.getBody() + "\n");
+ mSpeak = false;
+ mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
+ mToSend.requestFocus();
+ }
+ }
});
}
}