author | nikita@nikita-lab |
Sat, 20 Jun 2009 18:01:09 +0200 | |
changeset 251 | fae2a16a1f28 |
parent 243 | 644ead6eaf67 |
child 252 | f9bbba863298 |
permissions | -rw-r--r-- |
25 | 1 |
package com.beem.project.beem.ui; |
2 |
||
219
79ccbe331695
Les conversations sont retenues dans les chats du service.
Da Risk <darisk972@gmail.com>
parents:
188
diff
changeset
|
3 |
import java.util.List; |
79ccbe331695
Les conversations sont retenues dans les chats du service.
Da Risk <darisk972@gmail.com>
parents:
188
diff
changeset
|
4 |
|
251 | 5 |
import org.jivesoftware.smack.util.StringUtils; |
6 |
||
103
2320ab48e829
Bug d'affichage fixé et autre feature implementées
Philippe Lago <lago_p@epitech.net>
parents:
102
diff
changeset
|
7 |
import android.app.Activity; |
243
644ead6eaf67
Suppression beemapplication dans SendIM.
marseille@marseille-desktop
parents:
239
diff
changeset
|
8 |
import android.content.ComponentName; |
219
79ccbe331695
Les conversations sont retenues dans les chats du service.
Da Risk <darisk972@gmail.com>
parents:
188
diff
changeset
|
9 |
import android.content.Intent; |
243
644ead6eaf67
Suppression beemapplication dans SendIM.
marseille@marseille-desktop
parents:
239
diff
changeset
|
10 |
import android.content.ServiceConnection; |
43
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
11 |
import android.content.SharedPreferences; |
101
ccc48305bdeb
toujours le probleme du rafraichissement lors de la reception d'un message
Philippe Lago <lago_p@epitech.net>
parents:
84
diff
changeset
|
12 |
import android.graphics.drawable.Drawable; |
25 | 13 |
import android.os.Bundle; |
84
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
14 |
import android.os.Handler; |
243
644ead6eaf67
Suppression beemapplication dans SendIM.
marseille@marseille-desktop
parents:
239
diff
changeset
|
15 |
import android.os.IBinder; |
84
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
16 |
import android.os.RemoteException; |
52 | 17 |
import android.util.Log; |
43
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
18 |
import android.view.KeyEvent; |
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
19 |
import android.view.Menu; |
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
20 |
import android.view.MenuInflater; |
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
21 |
import android.view.MenuItem; |
25 | 22 |
import android.view.View; |
43
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
23 |
import android.view.View.OnClickListener; |
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
24 |
import android.view.View.OnKeyListener; |
25 | 25 |
import android.widget.EditText; |
143
6f6f5838aef9
skin skin skin joli pas beau
Philippe Lago <lago_p@epitech.net>
parents:
141
diff
changeset
|
26 |
import android.widget.ImageView; |
103
2320ab48e829
Bug d'affichage fixé et autre feature implementées
Philippe Lago <lago_p@epitech.net>
parents:
102
diff
changeset
|
27 |
import android.widget.ScrollView; |
101
ccc48305bdeb
toujours le probleme du rafraichissement lors de la reception d'un message
Philippe Lago <lago_p@epitech.net>
parents:
84
diff
changeset
|
28 |
import android.widget.TextView; |
25 | 29 |
|
243
644ead6eaf67
Suppression beemapplication dans SendIM.
marseille@marseille-desktop
parents:
239
diff
changeset
|
30 |
import com.beem.project.beem.BeemService; |
25 | 31 |
import com.beem.project.beem.R; |
52 | 32 |
import com.beem.project.beem.service.Contact; |
84
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
33 |
import com.beem.project.beem.service.Message; |
251 | 34 |
import com.beem.project.beem.service.PresenceAdapter; |
35 |
import com.beem.project.beem.service.aidl.IBeemRosterListener; |
|
84
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
36 |
import com.beem.project.beem.service.aidl.IChat; |
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
37 |
import com.beem.project.beem.service.aidl.IChatManager; |
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
38 |
import com.beem.project.beem.service.aidl.IChatManagerListener; |
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
39 |
import com.beem.project.beem.service.aidl.IMessageListener; |
251 | 40 |
import com.beem.project.beem.service.aidl.IRoster; |
84
9a4dbd7fe546
Super mercurial le retour du commit oublié apres le merge du pull -f -r19
Philippe Lago <lago_p@epitech.net>
parents:
62
diff
changeset
|
41 |
import com.beem.project.beem.service.aidl.IXmppFacade; |
25 | 42 |
|
43
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
43 |
/** |
127
395f1beb409f
deconnexion et fin du service presque ok
Da Risk <darisk972@gmail.com>
parents:
126
diff
changeset
|
44 |
* This activity class provides the view for instant messaging after selecting a correspondant. |
395f1beb409f
deconnexion et fin du service presque ok
Da Risk <darisk972@gmail.com>
parents:
126
diff
changeset
|
45 |
* @author barbu |
43
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
46 |
*/ |
4e7c6918b092
classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
Philippe Lago <lago_p@epitech.net>
parents:
27
diff
changeset
|
47 |
|
117
40a48262a670
Un petit skin pour l'im à travailler
Philippe Lago <lago_p@epitech.net>
parents:
110
diff
changeset
|
48 |
public class SendIM extends Activity implements OnClickListener, OnKeyListener { |
219
79ccbe331695
Les conversations sont retenues dans les chats du service.
Da Risk <darisk972@gmail.com>
parents:
188
diff
changeset
|
49 |
|
251 | 50 |
private static final String TAG = "SEND_IM"; |
51 |
private EditText mToSend; |
|
52 |
private SendIMDialogSmiley mSmyDialog; |
|
53 |
private SharedPreferences mSet; |
|
54 |
private Handler mHandler; |
|
55 |
private Contact mContact; |
|
56 |
private IChatManager mChatManager; |
|
57 |
private IChatManagerListener mChatManagerListener; |
|
58 |
private IMessageListener mMessageListener; |
|
59 |
private IChat mChat; |
|
60 |
private TextView mText; |
|
61 |
private TextView mLogin; |
|
62 |
private ScrollView mScrolling; |
|
63 |
private char mSpeak; |
|
212 | 64 |
|
251 | 65 |
private final ServiceConnection mServConn = new BeemServiceConnection(); |
66 |
private IXmppFacade xmppFacade; |
|
67 |
public IRoster mRoster; |
|
68 |
private TextView mStatusText; |
|
212 | 69 |
|
251 | 70 |
/** |
71 |
* Constructor. |
|
72 |
*/ |
|
73 |
public SendIM() { |
|
74 |
super(); |
|
212 | 75 |
} |
243
644ead6eaf67
Suppression beemapplication dans SendIM.
marseille@marseille-desktop
parents:
239
diff
changeset
|
76 |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
77 |
/** |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
78 |
* {@inheritDoc} |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
79 |
*/ |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
80 |
@Override |
251 | 81 |
public void onClick(View view) { |
82 |
sendText(); |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
83 |
} |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
84 |
|
251 | 85 |
/** |
86 |
* {@inheritDoc} |
|
87 |
*/ |
|
88 |
@Override |
|
89 |
protected void onCreate(Bundle saveBundle) { |
|
90 |
super.onCreate(saveBundle); |
|
91 |
mHandler = new Handler(); |
|
92 |
mChatManagerListener = new OnChatListener(); |
|
93 |
mMessageListener = new OnMessageListener(); |
|
94 |
setContentView(R.layout.sendim); |
|
95 |
mToSend = (EditText) findViewById(R.id.userText); |
|
96 |
mSet = getSharedPreferences("lol", MODE_PRIVATE); |
|
97 |
mSmyDialog = new SendIMDialogSmiley(this, mSet); |
|
98 |
mToSend.setOnClickListener(this); |
|
99 |
mToSend.setOnKeyListener(this); |
|
100 |
mLogin = (TextView) findViewById(R.id.sendimlogin); |
|
101 |
mContact = new Contact(getIntent().getData()); |
|
102 |
setViewHeader(); |
|
103 |
mText = (TextView) findViewById(R.id.sendimlist); |
|
104 |
mScrolling = (ScrollView) findViewById(R.id.sendimscroll); |
|
105 |
mStatusText = (TextView) findViewById(R.id.sendimstatus); |
|
106 |
} |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
107 |
|
251 | 108 |
/** |
109 |
* {@inheritDoc} |
|
110 |
*/ |
|
111 |
@Override |
|
112 |
public final boolean onCreateOptionsMenu(Menu menu) { |
|
113 |
super.onCreateOptionsMenu(menu); |
|
114 |
MenuInflater inflater = getMenuInflater(); |
|
115 |
inflater.inflate(R.menu.sendimmenu, menu); |
|
116 |
return true; |
|
117 |
} |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
118 |
|
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
119 |
/** |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
120 |
* {@inheritDoc} |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
121 |
*/ |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
122 |
@Override |
251 | 123 |
protected void onDestroy() { |
124 |
super.onDestroy(); |
|
125 |
if (mChatManager != null) { |
|
126 |
try { |
|
127 |
mChatManager.removeChatCreationListener(mChatManagerListener); |
|
128 |
// TODO trouver quand detruire le chat |
|
129 |
// mChatManager.destroyChat(mChat); |
|
130 |
} catch (RemoteException e) { |
|
131 |
Log.e(TAG, "mchat manager and SendIM destroy", e); |
|
132 |
} |
|
133 |
} |
|
134 |
} |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
135 |
|
251 | 136 |
/** |
137 |
* {@inheritDoc} |
|
138 |
*/ |
|
139 |
@Override |
|
140 |
public boolean onKey(View v, int keyCode, KeyEvent event) { |
|
141 |
if (event.getAction() == KeyEvent.ACTION_DOWN) { |
|
142 |
switch (keyCode) { |
|
143 |
case KeyEvent.KEYCODE_DPAD_CENTER: |
|
144 |
case KeyEvent.KEYCODE_ENTER: |
|
145 |
sendText(); |
|
146 |
return true; |
|
147 |
default: |
|
148 |
return false; |
|
149 |
} |
|
150 |
} |
|
151 |
return false; |
|
152 |
} |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
153 |
|
251 | 154 |
/** |
155 |
* {@inheritDoc} |
|
156 |
*/ |
|
157 |
@Override |
|
158 |
protected void onNewIntent(Intent intent) { |
|
159 |
super.onNewIntent(intent); |
|
160 |
mContact = new Contact(intent.getData()); |
|
161 |
setViewHeader(); |
|
162 |
} |
|
163 |
||
164 |
/** |
|
165 |
* {@inheritDoc} |
|
166 |
*/ |
|
167 |
@Override |
|
168 |
public final boolean onOptionsItemSelected(MenuItem item) { |
|
169 |
switch (item.getItemId()) { |
|
170 |
case R.id.sendim_smiley: |
|
171 |
mSmyDialog.show(); |
|
172 |
return true; |
|
173 |
default: |
|
174 |
return false; |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
175 |
} |
251 | 176 |
} |
177 |
||
178 |
/** |
|
179 |
* {@inheritDoc} |
|
180 |
*/ |
|
181 |
@Override |
|
182 |
protected void onPause() { |
|
183 |
super.onPause(); |
|
184 |
try { |
|
185 |
mChat.setOpen(false); |
|
186 |
} catch (RemoteException e) { |
|
187 |
Log.d(TAG, "Error while closing chat", e); |
|
188 |
} |
|
189 |
unbindService(mServConn); |
|
190 |
} |
|
191 |
||
192 |
/** |
|
193 |
* {@inheritDoc} |
|
194 |
*/ |
|
195 |
@Override |
|
196 |
protected void onResume() { |
|
197 |
super.onResume(); |
|
198 |
bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); |
|
199 |
mScrolling.fullScroll(ScrollView.FOCUS_DOWN); |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
200 |
} |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
201 |
|
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
202 |
/** |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
203 |
* {@inheritDoc} |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
204 |
*/ |
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
205 |
@Override |
251 | 206 |
protected void onStart() { |
207 |
super.onStart(); |
|
208 |
// TODO cancel the notification if any |
|
209 |
if (mContact == null) |
|
210 |
mContact = getIntent().getParcelableExtra("contact"); |
|
211 |
setViewHeader(); |
|
212 |
||
213 |
} |
|
214 |
||
215 |
private class BeemServiceConnection implements ServiceConnection { |
|
216 |
||
217 |
@Override |
|
218 |
public void onServiceConnected(ComponentName name, IBinder service) { |
|
219 |
xmppFacade = IXmppFacade.Stub.asInterface(service); |
|
220 |
try { |
|
221 |
if (mChatManager == null) { |
|
222 |
mChatManager = xmppFacade.getChatManager(); |
|
223 |
mChatManager.addChatCreationListener(mChatManagerListener); |
|
224 |
} |
|
225 |
switchChat(mContact); |
|
226 |
} catch (RemoteException e) { |
|
227 |
Log.e(TAG, "Error during chat manager creation", e); |
|
228 |
} |
|
229 |
try { |
|
230 |
mRoster = xmppFacade.getRoster(); |
|
231 |
if (mRoster != null) { |
|
232 |
mRoster.addRosterListener(new BeemRosterListener()); |
|
233 |
mContact.setStatus(mRoster.getPresence(mContact.getJID())); |
|
234 |
mStatusText.setText(mContact.getMsgState()); |
|
235 |
} |
|
236 |
} catch (RemoteException e) { |
|
237 |
e.printStackTrace(); |
|
238 |
} |
|
239 |
} |
|
240 |
||
241 |
@Override |
|
242 |
public void onServiceDisconnected(ComponentName name) { |
|
243 |
xmppFacade = null; |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
/** |
|
248 |
* Send a message to the contact over the XMPP connection. Also display it on activity view. TODO : Gerer |
|
249 |
* l'exception si la connexion se coupe pendant la conversation |
|
250 |
*/ |
|
251 |
private void sendText() { |
|
252 |
String text = mToSend.getText().toString(); |
|
253 |
if (!text.equals("")) { |
|
254 |
Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT); |
|
255 |
msg.setBody(text); |
|
256 |
try { |
|
257 |
// TODO: PAs connecter au serveur BING grosse Error ! INTERDICTION ! |
|
258 |
mChat.sendMessage(msg); |
|
259 |
if (mSpeak != 1) |
|
260 |
mText.append(getString(R.string.SendIMYouSay) + text + '\n'); |
|
261 |
else |
|
262 |
mText.append(text + "\n"); |
|
263 |
mToSend.setText(null); |
|
264 |
mScrolling.fullScroll(ScrollView.FOCUS_DOWN); |
|
265 |
mToSend.requestFocus(); |
|
266 |
mSpeak = 1; |
|
267 |
} catch (RemoteException e) { |
|
268 |
// TODO Auto-generated catch block |
|
269 |
e.printStackTrace(); |
|
270 |
} |
|
271 |
} |
|
272 |
} |
|
273 |
||
274 |
/** |
|
275 |
* Set the header information in the window. |
|
276 |
*/ |
|
277 |
private void setViewHeader() { |
|
278 |
Drawable avatar = getResources().getDrawable(R.drawable.avatar); |
|
279 |
ImageView imgV = (ImageView) findViewById(R.id.sendimavatar); |
|
280 |
imgV.setImageDrawable(avatar); |
|
281 |
mLogin = (TextView) findViewById(R.id.sendimlogin); |
|
282 |
mLogin.setText(mContact.getJID()); |
|
283 |
TextView status = (TextView) findViewById(R.id.sendimstatus); |
|
284 |
status.setTextSize(12); |
|
285 |
mLogin.setTextColor(getResources().getColor(R.color.white)); |
|
286 |
String statmsg = mContact.getMsgState(); |
|
287 |
if (statmsg != null) |
|
288 |
status.setText(statmsg); |
|
289 |
} |
|
290 |
||
291 |
/** |
|
292 |
* Show the message history. |
|
293 |
* @param messages list of message to display |
|
294 |
*/ |
|
295 |
private void showMessageList(List<Message> messages) { |
|
296 |
mText.setText(""); |
|
297 |
mSpeak = 0; |
|
298 |
for (Message message : messages) { |
|
299 |
String from = message.getFrom(); |
|
300 |
if (from == null) { |
|
301 |
if (mSpeak != 1) |
|
302 |
mText.append(getString(R.string.SendIMYouSay)); |
|
303 |
mSpeak = 1; |
|
304 |
} else { |
|
305 |
if (mSpeak != 2) { |
|
306 |
String str = String.format(getString(R.string.SendIMSays), from); |
|
307 |
mText.append(str); |
|
308 |
} |
|
309 |
mSpeak = 2; |
|
310 |
} |
|
311 |
mText.append(message.getBody() + '\n'); |
|
312 |
} |
|
313 |
mScrolling.fullScroll(ScrollView.FOCUS_DOWN); |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
314 |
} |
251 | 315 |
|
316 |
/** |
|
317 |
* Change the correspondant of the chat. |
|
318 |
* @param newContact New contact to chat with |
|
319 |
* @throws RemoteException if an errors occurs in the connection with the service |
|
320 |
*/ |
|
321 |
private void switchChat(Contact newContact) throws RemoteException { |
|
322 |
if (mChat != null) |
|
323 |
mChat.setOpen(false); |
|
324 |
mChat = mChatManager.createChat(newContact, mMessageListener); |
|
325 |
showMessageList(mChat.getMessages()); |
|
326 |
mChat.setOpen(true); |
|
327 |
mContact = newContact; |
|
328 |
mToSend.requestFocus(); |
|
329 |
} |
|
330 |
||
331 |
/** |
|
332 |
* Listener for chat creation. (maybe not necessary) |
|
333 |
* @author darisk |
|
334 |
*/ |
|
335 |
private class OnChatListener extends IChatManagerListener.Stub { |
|
336 |
/** |
|
337 |
* {@inheritDoc} |
|
338 |
*/ |
|
339 |
@Override |
|
340 |
public void chatCreated(IChat chat, boolean locally) throws RemoteException { |
|
341 |
Log.i("LOG", "chatCreated"); |
|
342 |
} |
|
343 |
||
344 |
} |
|
345 |
private class BeemRosterListener extends IBeemRosterListener.Stub { |
|
346 |
||
347 |
@Override |
|
348 |
public void onEntriesAdded(List<String> addresses) |
|
349 |
throws RemoteException { |
|
350 |
// TODO Auto-generated method stub |
|
351 |
||
352 |
} |
|
353 |
||
354 |
@Override |
|
355 |
public void onEntriesDeleted(List<String> addresses) |
|
356 |
throws RemoteException { |
|
357 |
// TODO Auto-generated method stub |
|
358 |
||
359 |
} |
|
360 |
||
361 |
@Override |
|
362 |
public void onEntriesUpdated(List<String> addresses) |
|
363 |
throws RemoteException { |
|
364 |
// TODO Auto-generated method stub |
|
365 |
||
366 |
} |
|
367 |
||
368 |
@Override |
|
369 |
public void onPresenceChanged(PresenceAdapter presence) |
|
370 |
throws RemoteException { |
|
371 |
mContact.setStatus(mRoster.getPresence(StringUtils.parseBareAddress(presence.getFrom()))); |
|
372 |
mHandler.post(new RunnableChange()); |
|
373 |
} |
|
374 |
||
375 |
private class RunnableChange implements Runnable { |
|
376 |
@Override |
|
377 |
public void run() { |
|
378 |
mStatusText.setText(mContact.getMsgState()); |
|
379 |
} |
|
380 |
} |
|
381 |
||
382 |
} |
|
383 |
||
384 |
/** |
|
385 |
* Listener for new chat messages. |
|
386 |
* @author darisk |
|
387 |
*/ |
|
388 |
private class OnMessageListener extends IMessageListener.Stub { |
|
389 |
||
390 |
/** |
|
391 |
* {@inheritDoc} |
|
392 |
*/ |
|
393 |
@Override |
|
394 |
public void processMessage(IChat chat, Message msg) throws RemoteException { |
|
395 |
||
396 |
if (chat != mChat) |
|
397 |
return; |
|
398 |
final Message m = msg; |
|
399 |
mHandler.post(new Runnable() { |
|
400 |
||
401 |
@Override |
|
402 |
public void run() { |
|
403 |
if (m.getBody() != null) { |
|
404 |
if (mSpeak == 2) |
|
405 |
mText.append(m.getBody() + "\n"); |
|
406 |
else { |
|
407 |
String str = String.format(getString(R.string.SendIMSays), m.getFrom()); |
|
408 |
mText.append(str); |
|
409 |
mText.append(m.getBody() + "\n"); |
|
410 |
} |
|
411 |
mScrolling.fullScroll(ScrollView.FOCUS_DOWN); |
|
412 |
mToSend.requestFocus(); |
|
413 |
mSpeak = 2; |
|
414 |
} |
|
415 |
} |
|
416 |
}); |
|
417 |
} |
|
418 |
||
419 |
/** |
|
420 |
* {@inheritDoc} |
|
421 |
*/ |
|
422 |
@Override |
|
423 |
public void stateChanged(IChat chat) throws RemoteException { |
|
424 |
// TODO: a integrer dans l'ui |
|
425 |
// Log.d(TAG, "state changed"); |
|
426 |
} |
|
427 |
} |
|
236
23647e075321
Re arrangemetn de certains fichiers !!
marseille@marseille-desktop
parents:
233
diff
changeset
|
428 |
|
25 | 429 |
} |