--- 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
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:orientation="vertical">
+ <View android:layout_width="fill_parent" android:layout_height="2dp"
+ android:fadingEdge="horizontal" android:background="#222222" />
+ <ListView android:id="@+id/chat_messages"
+ android:layout_width="fill_parent" android:layout_height="0dip"
+ android:layout_weight="1" android:transcriptMode="normal"
+ android:stackFromBottom="true"
+ android:fadingEdge="none" android:padding="4px"
+ android:fastScrollEnabled="true" android:smoothScrollbar="false"
+ android:focusable="true"/>
+ <LinearLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:orientation="horizontal"
+ android:background="#222222" android:padding="8px">
+ <EditText android:id="@+id/chat_input" android:layout_width="0dip"
+ android:layout_height="fill_parent" android:layout_weight="1"
+ android:maxLines="5"
+ android:inputType="textShortMessage|textAutoCorrect|textMultiLine"
+ android:imeOptions="actionSend" android:cursorVisible="true"
+ android:hint="@string/chat_input_default_value" />
+ <Button android:id="@+id/chat_send_message"
+ android:layout_width="wrap_content" android:layout_height="fill_parent"
+ android:text="@string/chat_send_message" />
+ </LinearLayout>
+</LinearLayout>
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:id="@+id/chatmessagedate"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:autoLink="none" android:layout_marginRight="4dp" />
+ <TextView android:id="@+id/chatmessagename"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:textSize="14sp" android:textColor="#FFFFFF" android:textStyle="bold"
+ android:layout_toRightOf="@id/chatmessagedate" android:layout_marginRight="4dp" />
+ <TextView android:id="@+id/chatmessagetext"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/chatmessagename" android:autoLink="all" />
+</RelativeLayout>
+
--- 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" />
+ <CheckBoxPreference android:title="@string/settings_chat_compact"
+ android:defaultValue="false" android:summary="@string/settings_chat_compact_sum"
+ android:key="settings_chat_compact_key" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/notification_preferences">
<CheckBoxPreference android:title="@string/notification_enable_vibrate_title"
--- a/res/values-fr/strings.xml Sun Dec 26 17:58:14 2010 +0100
+++ b/res/values-fr/strings.xml Tue Dec 28 01:56:11 2010 +0100
@@ -117,6 +117,8 @@
<string name="notification_enable_vibrate_sum">Activer le vibreur pour les messages entrants</string>
<string name="notification_snd_title">Sonnerie des messages</string>
<string name="notification_snd_sum">Configurer la sonnerie des messages entrants</string>
+ <string name="settings_chat_compact">Chat compact</string>
+ <string name="settings_chat_compact_sum">Activer la fenetre Chat compact</string>
<!-- Subscription class -->
<string name="SubscriptAccept">Inscription acceptée</string>
--- 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 @@
<string name="notification_enable_vibrate_sum">Enable vibrate on incoming messages</string>
<string name="notification_snd_title">Message ringtone</string>
<string name="notification_snd_sum">Set your incoming message ringtone</string>
-
+ <string name="settings_chat_compact">Chat compact</string>
+ <string name="settings_chat_compact_sum">Set the chat windows compact</string>
<!-- Subscription class -->
<string name="SubscriptAccept">Subscription accepted</string>
--- 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<Integer, Bitmap> mStatusIconsMap = new HashMap<Integer, Bitmap>();
private final List<MessageText> mListMessages = new ArrayList<MessageText>();
@@ -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;