# HG changeset patch # User Nikita Kozlov # Date 1268505151 -3600 # Node ID 8ca359035c84e02a3b8c819680921320a777142e # Parent bc47c8518bfde1b3ffee805658d8714871f426a3# Parent 2850c2c88d9aac40d980c7dd6cd7e6995e19deb3 merge diff -r bc47c8518bfd -r 8ca359035c84 res/layout/chat.xml --- a/res/layout/chat.xml Sat Mar 13 19:32:08 2010 +0100 +++ b/res/layout/chat.xml Sat Mar 13 19:32:31 2010 +0100 @@ -20,6 +20,9 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:autoLink="all" android:textSize="12sp" android:textColor="#FFFFFF" android:textColorLink="#FFFFFF" /> + Mauvais formulaire Contact déjà ajouté - - Beem - Chat - - %s dit :\n%s\n - Vous dites :\n%s\n - %s\n - Tapez votre texte ici - Est : - Erreur : %s\n - et est en train de parler depuis : - Insérer un sourire - Nom d\'utilisateur - Aucun statut défini - Beem - Changer mon statut Mon statut @@ -291,6 +277,10 @@ Conversations en cours Fermer cette conversation Aucune conversation en cours + est en train d\'écrire un message + a quitté la conversation + prête attention à la conversation + fait quelque chose d\'autre Disponible Disponible pour discuter diff -r bc47c8518bfd -r 8ca359035c84 res/values/strings.xml --- a/res/values/strings.xml Sat Mar 13 19:32:08 2010 +0100 +++ b/res/values/strings.xml Sat Mar 13 19:32:31 2010 +0100 @@ -55,20 +55,6 @@ Bad form Contact already exist - - Beem - Chat - - %s says :\n%s\n - You say :\n%s\n - %s\n - Tip text here - Is : - Error : %s\n - and is speaking from : - Insert a smiley - login - No status set - Beem - Change my status My status @@ -277,6 +263,10 @@ Opened chats Close this chat No more active chats + is composing a message + has left the conversation + pays attention to the conversation + is doing another thing Available Available to chat diff -r bc47c8518bfd -r 8ca359035c84 src/com/beem/project/beem/service/ChatAdapter.java --- a/src/com/beem/project/beem/service/ChatAdapter.java Sat Mar 13 19:32:08 2010 +0100 +++ b/src/com/beem/project/beem/service/ChatAdapter.java Sat Mar 13 19:32:31 2010 +0100 @@ -49,7 +49,6 @@ import org.jivesoftware.smack.Chat; import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.MessageListener; import org.jivesoftware.smackx.ChatStateListener; import org.jivesoftware.smackx.ChatState; @@ -197,7 +196,7 @@ /** * Listener. */ - private class MsgListener implements MessageListener, ChatStateListener { + private class MsgListener implements ChatStateListener { /** * Constructor. */ diff -r bc47c8518bfd -r 8ca359035c84 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat Mar 13 19:32:08 2010 +0100 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat Mar 13 19:32:31 2010 +0100 @@ -101,9 +101,11 @@ private int mPreviousMode; private String mPreviousStatus; private PrivacyListManagerAdapter mPrivacyListManager; + private ChatStateManager mChatStateManager; private final BeemService mService; private BeemApplication mApplication; - private final RemoteCallbackList mRemoteConnListeners = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteConnListeners = + new RemoteCallbackList(); private final SubscribePacketListener mSubscribePacketListener = new SubscribePacketListener(); private final ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter(); @@ -207,7 +209,6 @@ this.initFeatures(); // pour declarer les features xmpp qu'on // supporte - ChatStateManager.getInstance(mAdaptee); PacketFilter filter = new PacketFilter() { @@ -388,6 +389,7 @@ sdm = new ServiceDiscoveryManager(mAdaptee); sdm.addFeature("http://jabber.org/protocol/disco#info"); sdm.addFeature("jabber:iq:privacy"); + mChatStateManager = ChatStateManager.getInstance(mAdaptee); } /** diff -r bc47c8518bfd -r 8ca359035c84 src/com/beem/project/beem/service/aidl/IMessageListener.aidl --- a/src/com/beem/project/beem/service/aidl/IMessageListener.aidl Sat Mar 13 19:32:08 2010 +0100 +++ b/src/com/beem/project/beem/service/aidl/IMessageListener.aidl Sat Mar 13 19:32:31 2010 +0100 @@ -48,10 +48,17 @@ interface IMessageListener { + /** + * This method is executed when a chat receive a message. + * @param chat the chat receiving the message. + * @param msg the message received in the chat. + */ void processMessage(in IChat chat, in Message msg); /** - * le chatState se trouve dans le IChat - */ + * This method is executed when a new ChatState is received by the chat. + * You can use IChat.getState() in order to get the new state. + * @param chat the chat changed. + */ void stateChanged(in IChat chat); } diff -r bc47c8518bfd -r 8ca359035c84 src/com/beem/project/beem/ui/Chat.java --- a/src/com/beem/project/beem/ui/Chat.java Sat Mar 13 19:32:08 2010 +0100 +++ b/src/com/beem/project/beem/ui/Chat.java Sat Mar 13 19:32:31 2010 +0100 @@ -114,6 +114,7 @@ private TextView mContactNameTextView; private TextView mContactStatusMsgTextView; + private TextView mContactChatState; private ImageView mContactStatusIcon; private ListView mMessagesListView; private EditText mInputField; @@ -152,6 +153,7 @@ // UI mContactNameTextView = (TextView) findViewById(R.id.chat_contact_name); mContactStatusMsgTextView = (TextView) findViewById(R.id.chat_contact_status_msg); + mContactChatState = (TextView) findViewById(R.id.chat_contact_chat_state); mContactStatusIcon = (ImageView) findViewById(R.id.chat_contact_status_icon); mMessagesListView = (ListView) findViewById(R.id.chat_messages); mMessagesListView.setAdapter(mMessagesListAdapter); @@ -519,8 +521,9 @@ mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), true)); mMessagesListAdapter.notifyDataSetChanged(); } else if (msg.getBody() != null) { - MessageText lastMessage = mListMessages.size() != 0 ? mListMessages.get(mListMessages - .size() - 1) : null; + MessageText lastMessage = null; + if (mListMessages.size() != 0) + lastMessage = mListMessages.get(mListMessages.size() - 1); if (lastMessage != null && lastMessage.getBareJid().equals(fromBareJid)) { lastMessage.setMessage(lastMessage.getMessage().concat("\n" + msg.getBody())); @@ -539,7 +542,26 @@ */ @Override public void stateChanged(IChat chat) throws RemoteException { - //TODO + final String state = chat.getState(); + mHandler.post(new Runnable() { + @Override + public void run() { + String text = null; + if ("active".equals(state)) { + text = Chat.this.getString(R.string.chat_state_active); + } else if ("composing".equals(state)) { + text = Chat.this.getString(R.string.chat_state_composing); + } else if ("gone".equals(state)) { + text = Chat.this.getString(R.string.chat_state_gone); + } else if ("inactive".equals(state)) { + text = Chat.this.getString(R.string.chat_state_inactive); + } else if ("paused".equals(state)) { + text = Chat.this.getString(R.string.chat_state_active); + } + mContactChatState.setText(text); + } + }); + } } @@ -789,7 +811,9 @@ } final String self = getString(R.string.chat_self); - MessageText lastMessage = mListMessages.size() != 0 ? mListMessages.get(mListMessages.size() - 1) : null; + MessageText lastMessage = null; + if (mListMessages.size() != 0) + lastMessage = mListMessages.get(mListMessages.size() - 1); if (lastMessage != null && lastMessage.getName().equals(self)) { lastMessage.setMessage(lastMessage.getMessage().concat("\n" + inputContent));