# HG changeset patch
# User "Vincent Veronis"
# Date 1293497771 -3600
# Node ID 117ea85f0fe6e3b481b1f80db3f9673b16a2c5d5
# Parent 0d5d1d7735ca594b14d02a47b1315b1fb3ef60d3# Parent f179ba8098f1a39d51437317b4cbabb2d41bf221
Merge
diff -r 0d5d1d7735ca -r 117ea85f0fe6 default.properties
--- a/default.properties Sun Dec 26 17:58:14 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-7
diff -r 0d5d1d7735ca -r 117ea85f0fe6 res/layout/chat_compact.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/chat_compact.xml Tue Dec 28 01:56:11 2010 +0100
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
diff -r 0d5d1d7735ca -r 117ea85f0fe6 res/layout/chat_msg_row_compact.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/chat_msg_row_compact.xml Tue Dec 28 01:56:11 2010 +0100
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff -r 0d5d1d7735ca -r 117ea85f0fe6 res/layout/preferences.xml
--- a/res/layout/preferences.xml Sun Dec 26 17:58:14 2010 +0100
+++ b/res/layout/preferences.xml Tue Dec 28 01:56:11 2010 +0100
@@ -23,6 +23,9 @@
android:singleLine="true" android:summary="@string/away_message_sum"
android:title="@string/away_message_title" android:key="settings_away_message"
android:hint="@string/away_message_hint" />
+
Activer le vibreur pour les messages entrants
Sonnerie des messages
Configurer la sonnerie des messages entrants
+ Chat compact
+ Activer la fenetre Chat compact
Inscription acceptée
diff -r 0d5d1d7735ca -r 117ea85f0fe6 res/values/strings.xml
--- a/res/values/strings.xml Sun Dec 26 17:58:14 2010 +0100
+++ b/res/values/strings.xml Tue Dec 28 01:56:11 2010 +0100
@@ -117,7 +117,8 @@
Enable vibrate on incoming messages
Message ringtone
Set your incoming message ringtone
-
+ Chat compact
+ Set the chat windows compact
Subscription accepted
diff -r 0d5d1d7735ca -r 117ea85f0fe6 src/com/beem/project/beem/ui/Chat.java
--- a/src/com/beem/project/beem/ui/Chat.java Sun Dec 26 17:58:14 2010 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java Tue Dec 28 01:56:11 2010 +0100
@@ -50,6 +50,7 @@
import java.util.List;
import java.util.Map;
+import org.jivesoftware.smack.packet.Presence.Mode;
import org.jivesoftware.smack.util.StringUtils;
import android.app.Activity;
@@ -58,15 +59,15 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
+import android.preference.PreferenceManager;
import android.text.util.Linkify;
import android.util.Log;
import android.view.KeyEvent;
@@ -75,9 +76,9 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
-import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
@@ -85,8 +86,6 @@
import android.widget.ListView;
import android.widget.TextView;
-import java.io.ByteArrayInputStream;
-
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
import com.beem.project.beem.service.Message;
@@ -125,7 +124,6 @@
private ListView mMessagesListView;
private EditText mInputField;
private Button mSendButton;
- private LayerDrawable mAvatarStatusDrawable;
private final Map mStatusIconsMap = new HashMap();
private final List mListMessages = new ArrayList();
@@ -141,6 +139,7 @@
private final BeemRosterListener mBeemRosterListener = new BeemRosterListener();
private IXmppFacade mXmppFacade;
private boolean mBinded;
+ private boolean mCompact;
/**
* Constructor.
@@ -155,16 +154,19 @@
@Override
protected void onCreate(Bundle savedBundle) {
super.onCreate(savedBundle);
- setContentView(R.layout.chat);
this.registerReceiver(mBroadcastReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
-
+ SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
+ mCompact = settings.getBoolean("settings_chat_compact_key", false);
// 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);
- mAvatarStatusDrawable = (LayerDrawable) mContactStatusIcon.getDrawable();
- mAvatarStatusDrawable.setLayerInset(1, 36, 36, 0, 0);
+ if (!mCompact) {
+ setContentView(R.layout.chat);
+ 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);
+ } else {
+ setContentView(R.layout.chat_compact);
+ }
mMessagesListView = (ListView) findViewById(R.id.chat_messages);
mMessagesListView.setAdapter(mMessagesListAdapter);
mInputField = (EditText) findViewById(R.id.chat_input);
@@ -498,7 +500,8 @@
@Override
public void run() {
if (msg.getType() == Message.MSG_TYPE_ERROR) {
- mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), true, msg.getTimestamp()));
+ mListMessages.add(new MessageText(fromBareJid, mContact.getName(),
+ msg.getBody(), true, msg.getTimestamp()));
mMessagesListAdapter.notifyDataSetChanged();
} else if (msg.getBody() != null) {
MessageText lastMessage = null;
@@ -510,7 +513,8 @@
lastMessage.setTimestamp(msg.getTimestamp());
mListMessages.set(mListMessages.size() - 1, lastMessage);
} else if (msg.getBody() != null)
- mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), false, msg.getTimestamp()));
+ mListMessages.add(new MessageText(fromBareJid, mContact.getName(),
+ msg.getBody(), false, msg.getTimestamp()));
mMessagesListAdapter.notifyDataSetChanged();
}
}
@@ -539,7 +543,8 @@
} else if ("paused".equals(state)) {
text = Chat.this.getString(R.string.chat_state_active);
}
- mContactChatState.setText(text);
+ if (!mCompact)
+ mContactChatState.setText(text);
}
});
@@ -555,13 +560,17 @@
String res = mContact.getSelectedRes();
if (!"".equals(res))
name += "(" + res + ")";
- if (!(mContactNameTextView.getText().toString().equals(name)))
- mContactNameTextView.setText(name);
-
- // Check for a contact status message update
- if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
- mContactStatusMsgTextView.setText(mContact.getMsgState());
- Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
+ if (!mCompact) {
+ if (!(mContactNameTextView.getText().toString().equals(name)))
+ mContactNameTextView.setText(name);
+ //Check for a contact status message update
+ if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
+ mContactStatusMsgTextView.setText(mContact.getMsgState());
+ Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
+ }
+ } else {
+ Mode m = Status.getPresenceModeFromStatus(mContact.getStatus());
+ setTitle(getString(R.string.chat_name) + " " + mContact.getName() + " (" + m.name() + ")");
}
}
@@ -569,31 +578,8 @@
* Update the contact status icon.
*/
private void updateContactStatusIcon() {
- Drawable avatar = getAvatarDrawable(mContact.getAvatarId());
- mAvatarStatusDrawable.setDrawableByLayerId(R.id.avatar, avatar);
- mContactStatusIcon.setImageLevel(mContact.getStatus());
- }
-
- /**
- * Get a Drawable containing the avatar icon.
- *
- * @param avatarId the avatar id to retrieve or null to get default
- * @return a Drawable
- */
- private Drawable getAvatarDrawable(String avatarId) {
- Drawable avatarDrawable = null;
- try {
- byte[] avatar = mXmppFacade.getAvatar(avatarId);
- if (avatar != null) {
- ByteArrayInputStream in = new ByteArrayInputStream(avatar);
- avatarDrawable = Drawable.createFromStream(in, avatarId);
- }
- } catch (RemoteException e) {
- Log.e(TAG, "Error while setting the avatar", e);
- }
- if (avatarDrawable == null)
- avatarDrawable = getResources().getDrawable(R.drawable.beem_launcher_icon_silver);
- return avatarDrawable;
+ if (!mCompact)
+ mContactStatusIcon.setImageLevel(mContact.getStatus());
}
/**
@@ -665,26 +651,35 @@
View sv;
if (convertView == null) {
LayoutInflater inflater = Chat.this.getLayoutInflater();
- sv = inflater.inflate(R.layout.chat_msg_row, null);
+ if (!mCompact)
+ sv = inflater.inflate(R.layout.chat_msg_row, null);
+ else
+ sv = inflater.inflate(R.layout.chat_msg_row_compact, null);
} else {
sv = convertView;
}
+ DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
MessageText msg = mListMessages.get(position);
- TextView msgName = (TextView) sv.findViewById(R.id.chatmessagename);
- msgName.setText(msg.getName());
- msgName.setTextColor(Color.WHITE);
- msgName.setError(null);
- TextView msgText = (TextView) sv.findViewById(R.id.chatmessagetext);
- msgText.setText(msg.getMessage());
- TextView msgDate = (TextView) sv.findViewById(R.id.chatmessagedate);
- DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
- String date = df.format(msg.getTimestamp());
- msgDate.setText(date);
- if (msg.isError()) {
- String err = getString(R.string.chat_error);
- msgName.setText(err);
- msgName.setTextColor(Color.RED);
- msgName.setError(err);
+ if (!mCompact) {
+ TextView msgName = (TextView) sv.findViewById(R.id.chatmessagename);
+ msgName.setText(msg.getName());
+ msgName.setTextColor(Color.WHITE);
+ msgName.setError(null);
+ TextView msgText = (TextView) sv.findViewById(R.id.chatmessagetext);
+ msgText.setText(msg.getMessage());
+ TextView msgDate = (TextView) sv.findViewById(R.id.chatmessagedate);
+ String date = df.format(msg.getTimestamp());
+ msgDate.setText(date);
+ if (msg.isError()) {
+ String err = getString(R.string.chat_error);
+ msgName.setText(err);
+ msgName.setTextColor(Color.RED);
+ msgName.setError(err);
+ }
+ } else {
+ String str = "(" + df.format(msg.getTimestamp()) + ") " + msg.getName() + " : " + msg.getMessage();
+ TextView msgText = (TextView) sv.findViewById(R.id.chatmessagetext);
+ msgText.setText(str);
}
return sv;
}
@@ -721,7 +716,8 @@
* @param message A String containing the message.
* @param isError if the message is an error message.
*/
- public MessageText(final String bareJid, final String name, final String message, final boolean isError) {
+ public MessageText(final String bareJid, final String name, final String message,
+ final boolean isError) {
mBareJid = bareJid;
mName = name;
mMessage = message;
@@ -736,7 +732,8 @@
* @param isError if the message is an error message.
* @param date the time of the message.
*/
- public MessageText(final String bareJid, final String name, final String message, final boolean isError, Date date) {
+ public MessageText(final String bareJid, final String name, final String message,
+ final boolean isError, Date date) {
mBareJid = bareJid;
mName = name;
mMessage = message;