--- a/AndroidManifest.xml Sun Jan 24 04:57:37 2010 +0100
+++ b/AndroidManifest.xml Sun Feb 14 17:25:38 2010 +0100
@@ -98,4 +98,6 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
<uses-sdk android:minSdkVersion="3" />
+<supports-screens android:largeScreens="true"
+ android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" />
</manifest>
--- a/default.properties Sun Jan 24 04:57:37 2010 +0100
+++ b/default.properties Sun Feb 14 17:25:38 2010 +0100
@@ -10,5 +10,5 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
-target=android-4
+target=android-7
apk-configurations=
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/chat_msg_row.xml Sun Feb 14 17:25:38 2010 +0100
@@ -0,0 +1,22 @@
+<?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="wrap_content"
+ >
+
+ <TextView android:id="@+id/chatmessagename"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="16sp"
+ android:textColor="#FFFFFF"
+ android:textStyle="bold"
+ android:paddingBottom="1dp"
+ />
+ <TextView android:id="@+id/chatmessagetext"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:autoLink="all"
+ />
+</LinearLayout>
+
--- a/res/layout/contactlist.xml Sun Jan 24 04:57:37 2010 +0100
+++ b/res/layout/contactlist.xml Sun Feb 14 17:25:38 2010 +0100
@@ -2,19 +2,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
- <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/contactlist_banner" android:layout_width="fill_parent"
- android:layout_height="42px" android:spacing="42px"
- android:unselectedAlpha="0.4" android:background="#222222" />
- <View android:layout_width="fill_parent" android:layout_height="2dp"
- android:fadingEdge="horizontal" android:background="#555555" />
+ <ViewStub android:id="@+id/contactlist_stub" android:inflatedId="@+id/contactlist_groupstub" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:layout="@layout/contactlist_groupstub"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="horizontal"
android:padding="2px">
- <ListView android:id="@+id/contactlist"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:transcriptMode="disabled" />
- <!-- normal should be better -->
+ <ListView android:id="@+id/contactlist" android:layout_width="fill_parent"
+ android:layout_height="fill_parent" android:transcriptMode="disabled" />
</LinearLayout>
-
</LinearLayout>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/contactlist_groupstub.xml Sun Feb 14 17:25:38 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/contactlist_groupstub" android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+ <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/contactlist_banner" android:layout_width="fill_parent"
+ android:layout_height="42px" android:spacing="42px"
+ android:unselectedAlpha="0.4" android:background="#222222" />
+ <View android:layout_width="fill_parent" android:layout_height="2dp"
+ android:fadingEdge="horizontal" android:background="#555555" />
+</LinearLayout>
--- a/res/layout/preferences.xml Sun Jan 24 04:57:37 2010 +0100
+++ b/res/layout/preferences.xml Sun Feb 14 17:25:38 2010 +0100
@@ -7,6 +7,9 @@
<CheckBoxPreference android:title="@string/CLP_hidden_contact"
android:defaultValue="false" android:summary="@string/CLP_hidden_contact_sum"
android:key="settings_key_hidden_contact" />
+ <CheckBoxPreference android:title="@string/CLP_hide_groups"
+ android:defaultValue="false" android:summary="@string/CLP_hide_groups_sum"
+ android:key="settings_key_hide_groups" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/user_preferences">
@@ -30,9 +33,6 @@
android:summary="@string/SettingsPrioritySummary"
android:numeric="signed"
android:defaultValue="0" />
- <CheckBoxPreference android:title="@string/SettingsCheckboxText"
- android:defaultValue="false" android:summary="@string/SettingsGmail"
- android:key="settings_key_gmail" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/network_preferences">
--- a/res/values-fr/strings.xml Sun Jan 24 04:57:37 2010 +0100
+++ b/res/values-fr/strings.xml Sun Feb 14 17:25:38 2010 +0100
@@ -162,7 +162,7 @@
<string name="login_menu_create_account">Créer un compte</string>
<string name="login_menu_settings">Paramètres</string>
<string name="login_menu_about">A propos</string>
- <string name="login_about_title">A propos</string>
+ <string name="login_about_title">Beem %s - A propos</string>
<string name="login_about_msg">
Beem est un EPITECH Innovative Project. Rencontrez
nous sur http://www.beem-project.com !
@@ -204,8 +204,11 @@
<string name="contact_list_preferences">Liste d\'ami(e)s</string>
<string name="contact_list_preferences_sum">Une série d\'options d\'affichage de votre liste
d\'ami(e)s</string>
- <string name="CLP_hidden_contact">Caché(e)s</string>
- <string name="CLP_hidden_contact_sum">Cochez cette option pour cacher les ami(e)s déconnecté(e)s</string>
+
+ <string name="CLP_hide_groups">Cachez les groupes</string>
+ <string name="CLP_hide_groups_sum">Cochez cette option pour cacher les groupes</string>
+ <string name="CLP_hidden_contact">Cachez les contacts</string>
+ <string name="CLP_hidden_contact_sum">Cochez cette option pour cacher les contacts déconnectés</string>
<!-- EditSettings Activity Account tab -->
<string name="settings_account_username">Nom d\'utilisateur</string>
@@ -275,6 +278,7 @@
<string name="chat_input_default_value">Saisissez votre message</string>
<string name="chat_name">Beem - Chat</string>
<string name="chat_self">Moi</string>
+ <string name="chat_error">Erreur</string>
<string name="chat_send_message">Envoyer</string>
<string name="chat_menu_contacts_list">Liste de contacts</string>
<string name="chat_menu_change_chat">Changer de conversation</string>
@@ -303,4 +307,33 @@
<string name="privacy_list_delete_dialog_no">Non</string>
<string name="UpdateButton">Mettre à jour</string>
+
+ <!-- Error messages -->
+
+ <string name="error_login_authentication">Erreur lors de l\'authenfitication, mauvais login ou password</string>
+
+ <string name="interna_server_error">Erreur survenu sur le serveur</string>
+ <string name="bad_request">bad-request</string>
+ <string name="forbidden">forbidden</string>
+ <string name="item_not_found">item-not-found</string>
+ <string name="conflict">conflict</string>
+ <string name="feature_not_implemented">feature-not-implemented</string>
+ <string name="gone">gone</string>
+ <string name="jid_malformed">jid-malformed</string>
+ <string name="no_acceptable">no-acceptable</string>
+ <string name="not_allowed">not-allowed</string>
+ <string name="not_authorized">not-authorized</string>
+ <string name="payment_required">payment-required</string>
+ <string name="recipient_unavailable">recipient-unavailable</string>
+ <string name="redirect">redirect</string>
+ <string name="registration_required">registration-required</string>
+ <string name="remote_server_not_found">Serveur non trouvé</string>
+ <string name="remote_server_timeout">Pas de réponse du serveur</string>
+ <string name="remote_server_error">Erreur survenu sur le serveur</string>
+ <string name="resource_constraint">resource-constraint</string>
+ <string name="service_unavailable">service-unavailable</string>
+ <string name="subscription_required">subscription-required</string>
+ <string name="undefined_condition">undefined-condition</string>
+ <string name="unexpected_condition">unexpected-condition</string>
+ <string name="request_timeout">request-timeout</string>
</resources>
--- a/res/values/strings.xml Sun Jan 24 04:57:37 2010 +0100
+++ b/res/values/strings.xml Sun Feb 14 17:25:38 2010 +0100
@@ -151,7 +151,7 @@
<string name="login_menu_create_account">Create an account</string>
<string name="login_menu_settings">Settings</string>
<string name="login_menu_about">About</string>
- <string name="login_about_title">About</string>
+ <string name="login_about_title">Beem %s - About</string>
<string name="login_about_msg">
Beem is an EPITECH Innovative Project. Visit us at
http://www.beem-project.com !
@@ -194,7 +194,10 @@
<string name="contact_list_preferences">Buddy list</string>
<string name="contact_list_preferences_sum">A set of display options for your buddy list
</string>
- <string name="CLP_hidden_contact">Hidden</string>
+
+ <string name="CLP_hide_groups">Hide groups</string>
+ <string name="CLP_hide_groups_sum">Check this option to hide groups</string>
+ <string name="CLP_hidden_contact">Hide buddies</string>
<string name="CLP_hidden_contact_sum">Check this option to hide unconnected buddies
</string>
@@ -259,6 +262,7 @@
<string name="chat_name">Beem - Chat</string>
<string name="chat_input_default_value">Type your message</string>
<string name="chat_self">Me</string>
+ <string name="chat_error">Error</string>
<string name="chat_send_message">Send</string>
<string name="chat_menu_contacts_list">Contacts list</string>
<string name="chat_menu_change_chat">Switch chat</string>
@@ -287,4 +291,33 @@
<string name="privacy_list_delete_dialog_no">No</string>
<string name="UpdateButton">Update</string>
+
+ <!-- Error messages -->
+
+ <string name="error_login_authentication">Error during authentication, bad login or password.</string>
+
+ <string name="interna_server_error">Remote server error</string>
+ <string name="bad_request">bad-request</string>
+ <string name="forbidden">forbidden</string>
+ <string name="item_not_found">item-not-found</string>
+ <string name="conflict">conflict</string>
+ <string name="feature_not_implemented">feature-not-implemented</string>
+ <string name="gone">gone</string>
+ <string name="jid_malformed">jid-malformed</string>
+ <string name="no_acceptable">no-acceptable</string>
+ <string name="not_allowed">not-allowed</string>
+ <string name="not_authorized">not-authorized</string>
+ <string name="payment_required">payment-required</string>
+ <string name="recipient_unavailable">recipient-unavailable</string>
+ <string name="redirect">redirect</string>
+ <string name="registration_required">registration-required</string>
+ <string name="remote_server_not_found">Remote server not found</string>
+ <string name="remote_server_timeout">No server response</string>
+ <string name="remote_server_error">Remote server error</string>
+ <string name="resource_constraint">resource-constraint</string>
+ <string name="service_unavailable">service-unavailable</string>
+ <string name="subscription_required">subscription-required</string>
+ <string name="undefined_condition">undefined-condition</string>
+ <string name="unexpected_condition">unexpected-condition</string>
+ <string name="request_timeout">request-timeout</string>
</resources>
--- a/src/com/beem/project/beem/BeemService.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/BeemService.java Sun Feb 14 17:25:38 2010 +0100
@@ -53,30 +53,6 @@
import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smack.proxy.ProxyInfo.ProxyType;
import org.jivesoftware.smack.util.StringUtils;
-import org.jivesoftware.smackx.GroupChatInvitation;
-import org.jivesoftware.smackx.PrivateDataManager;
-import org.jivesoftware.smackx.packet.ChatStateExtension;
-import org.jivesoftware.smackx.packet.LastActivity;
-import org.jivesoftware.smackx.packet.OfflineMessageInfo;
-import org.jivesoftware.smackx.packet.OfflineMessageRequest;
-import org.jivesoftware.smackx.packet.SharedGroupsInfo;
-import org.jivesoftware.smackx.provider.AdHocCommandDataProvider;
-import org.jivesoftware.smackx.provider.BytestreamsProvider;
-import org.jivesoftware.smackx.provider.DataFormProvider;
-import org.jivesoftware.smackx.provider.DelayInformationProvider;
-import org.jivesoftware.smackx.provider.DiscoverInfoProvider;
-import org.jivesoftware.smackx.provider.DiscoverItemsProvider;
-import org.jivesoftware.smackx.provider.IBBProviders;
-import org.jivesoftware.smackx.provider.MUCAdminProvider;
-import org.jivesoftware.smackx.provider.MUCOwnerProvider;
-import org.jivesoftware.smackx.provider.MUCUserProvider;
-import org.jivesoftware.smackx.provider.MessageEventProvider;
-import org.jivesoftware.smackx.provider.MultipleAddressesProvider;
-import org.jivesoftware.smackx.provider.RosterExchangeProvider;
-import org.jivesoftware.smackx.provider.StreamInitiationProvider;
-import org.jivesoftware.smackx.provider.VCardProvider;
-import org.jivesoftware.smackx.provider.XHTMLExtensionProvider;
-import org.jivesoftware.smackx.search.UserSearch;
import android.app.Notification;
import android.app.NotificationManager;
@@ -138,7 +114,7 @@
* Initialise la configuration de la connexion.
*/
private void initConnectionConfig() {
- java.security.Security.addProvider(new com.sun.security.sasl.Provider());
+ //java.security.Security.addProvider(new com.sun.security.sasl.Provider());
mUseProxy = mSettings.getBoolean("settings_key_proxy_use", false);
if (mUseProxy) {
String stype = mSettings.getString("settings_key_proxy_type", "HTTP");
@@ -148,17 +124,14 @@
int pport = Integer.parseInt(mSettings.getString("settings_key_proxy_port", "1080"));
ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass);
- Log.d("Proxy", "type " + type);
- if (mService != null)
- mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService, mProxyInfo);
- else
- mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mProxyInfo);
} else {
- if (mService != null)
- mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService);
- else
- mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort);
+ mProxyInfo = ProxyInfo.forNoProxy();
}
+ if (mSettings.getBoolean("settings_key_specific_server", false))
+ mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService, mProxyInfo);
+ else
+ mConnectionConfiguration = new ConnectionConfiguration(mService, mProxyInfo);
+
if (mSettings.getBoolean("settings_key_xmpp_tls_use", false)
|| mSettings.getBoolean("settings_key_gmail", false)) {
mConnectionConfiguration.setSecurityMode(SecurityMode.required);
@@ -206,10 +179,12 @@
if (mSettings.getBoolean("settings_key_specific_server", false)) {
mHost = mSettings.getString("settings_key_xmpp_server", "");
- mPort = Integer.parseInt(mSettings.getString("settings_key_xmpp_port", "5222"));
+ if ("".equals(mHost))
+ mHost = StringUtils.parseServer(tmpJid);
+ String tmpPort = mSettings.getString("settings_key_xmpp_port", "5222");
+ mPort = ("".equals(tmpPort)) ? DEFAULT_XMPP_PORT : Integer.parseInt(tmpPort) ;
}
- if (mSettings.getBoolean("settings_key_gmail", false)) {
- mHost = "talk.google.com";
+ if ("gmail.com".equals(mService) || "googlemail.com".equals(mService)) {
mLogin = tmpJid;
}
@@ -309,6 +284,10 @@
* @param pm The ProviderManager.
*/
private void configure(ProviderManager pm) {
+ // Privacy
+ pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
+
+ /*
// Private Data Storage
pm.addIQProvider("query", "jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());
// Time
@@ -375,8 +354,7 @@
pm.addIQProvider("open", "http://jabber.org/protocol/ibb", new IBBProviders.Open());
pm.addIQProvider("close", "http://jabber.org/protocol/ibb", new IBBProviders.Close());
pm.addExtensionProvider("data", "http://jabber.org/protocol/ibb", new IBBProviders.Data());
- // Privacy
- pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
+
pm.addIQProvider("command", COMMAND_NAMESPACE, new AdHocCommandDataProvider());
pm.addExtensionProvider("malformed-action", COMMAND_NAMESPACE,
new AdHocCommandDataProvider.MalformedActionError());
@@ -388,6 +366,7 @@
new AdHocCommandDataProvider.BadSessionIDError());
pm.addExtensionProvider("session-expired", COMMAND_NAMESPACE,
new AdHocCommandDataProvider.SessionExpiredError());
+ */
}
}
--- a/src/com/beem/project/beem/service/BeemChatManager.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/service/BeemChatManager.java Sun Feb 14 17:25:38 2010 +0100
@@ -222,9 +222,10 @@
return result;
}
Chat c = mAdaptee.createChat(key, null);
- result = new ChatAdapter(c);
+ // maybe a little probleme of thread synchronization
+ // if so use an HashTable instead of a HashMap for mChats
+ result = getChat(c);
result.addMessageListener(listener);
- mChats.put(key, result);
return result;
}
--- a/src/com/beem/project/beem/service/Message.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/service/Message.java Sun Feb 14 17:25:38 2010 +0100
@@ -47,7 +47,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import android.util.Log;
/**
* This class represents a instant message.
@@ -135,7 +134,7 @@
mType = MSG_TYPE_ERROR;
break;
default:
- Log.w("BEEM_MESSAGE", "type de message non gerer" + smackMsg.getType());
+ mType = MSG_TYPE_NORMAL;
break;
}
this.mFrom = smackMsg.getFrom();
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sun Feb 14 17:25:38 2010 +0100
@@ -171,10 +171,18 @@
return true;
} catch (XMPPException e) {
Log.e(TAG, "Error while connecting", e);
- if (!"".equals(e.getMessage()))
- mErrorMsg = e.getMessage();
- else
- mErrorMsg = e.toString();
+ try {
+ //TODO NIKITA DOES SOME SHIT !!! Fix this monstruosity
+ String str = mService.getResources().getString(
+ mService.getResources().getIdentifier(
+ e.getXMPPError().getCondition().replace("-", "_"), "string", "com.beem.project.beem"));
+ mErrorMsg = str;
+ } catch(NullPointerException e2) {
+ if (!"".equals(e.getMessage()))
+ mErrorMsg = e.getMessage();
+ else
+ mErrorMsg = e.toString();
+ }
}
return false;
}
@@ -211,15 +219,12 @@
mService.resetStatus();
mService.initJingle(mAdaptee);
- // triggerAsynchronousConnectEvent();
+ // triggerAsynchronousConnectEvent();
changeStatus(Status.CONTACT_STATUS_AVAILABLE, mService.getServicePreference().getString("status_text", ""));
return true;
} catch (XMPPException e) {
Log.e(TAG, "Error while connecting", e);
- if (!"".equals(e.getMessage()))
- mErrorMsg = e.getMessage();
- else
- mErrorMsg = e.toString();
+ mErrorMsg = mService.getString(R.string.error_login_authentication);
return false;
}
}
--- a/src/com/beem/project/beem/ui/ChangeStatus.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java Sun Feb 14 17:25:38 2010 +0100
@@ -180,7 +180,7 @@
* @return the status index from status the settings.
*/
private int getPreferenceStatusIndex() {
- return mSettings.getInt("PreferenceStatus", 0);
+ return mSettings.getInt(getString(R.string.PreferenceStatus), AVAILABLE_IDX);
}
/**
@@ -276,24 +276,26 @@
int status = getStatusForService((String) mSpinner.getSelectedItem());
Editor edit = mSettings.edit();
edit.putString(getString(R.string.PreferenceStatusText), msg);
- edit.putInt(getString(R.string.PreferenceStatus), mSpinner.getSelectedItemPosition());
- edit.commit();
if (status == Status.CONTACT_STATUS_DISCONNECT) {
stopService(new Intent(ChangeStatus.this, BeemService.class));
+ edit.putInt(getString(R.string.PreferenceStatus), AVAILABLE_IDX);
} else {
try {
mXmppFacade.changeStatus(status, msg.toString());
+ edit.putInt(getString(R.string.PreferenceStatus), mSpinner.getSelectedItemPosition());
} catch (RemoteException e) {
e.printStackTrace();
}
mToast.show();
}
+ edit.commit();
}
ChangeStatus.this.finish();
} else if (v == mClear) {
mStatusMessageEditText.setText(null);
} else if (v == mContact) {
startActivity(new Intent(ChangeStatus.this, ContactList.class));
+ ChangeStatus.this.finish();
}
}
}
--- a/src/com/beem/project/beem/ui/Chat.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java Sun Feb 14 17:25:38 2010 +0100
@@ -53,7 +53,6 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
@@ -61,7 +60,6 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
-import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -69,6 +67,7 @@
import android.text.util.Linkify;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -80,7 +79,6 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
-import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
@@ -344,30 +342,47 @@
* @throws RemoteException If a Binder remote-invocation error occurred.
*/
private void playRegisteredTranscript() throws RemoteException {
- String fromBareJid = null;
- String fromName = null;
- List<Message> chatMessages = mChat.getMessages();
mListMessages.clear();
+ List<MessageText> msgList = convertMessagesList(mChat.getMessages());
+ mListMessages.addAll(msgList);
mMessagesListAdapter.notifyDataSetChanged();
+ }
+
+ /**
+ * Convert a list of Mesage coming from the service to a list of MessageText that can be displayed in UI.
+ * @param chatMessages the list of Message
+ * @return a list of message that can be displayed.
+ */
+ private List<MessageText> convertMessagesList(List<Message> chatMessages) {
+ List<MessageText> result = new ArrayList<MessageText>(chatMessages.size());
+ String remoteName = mContact.getName();
+ String localName = getString(R.string.chat_self);
MessageText lastMessage = null;
for (Message m : chatMessages) {
- fromBareJid = StringUtils.parseBareAddress(m.getFrom());
- fromName = mContact.getName();
- if (fromBareJid == null) {
- fromBareJid = getString(R.string.chat_self);
- fromName = getString(R.string.chat_self);
- }
- if (m.getBody() != null) {
- if (lastMessage == null || !lastMessage.getBareJid().equals(fromBareJid)) {
- lastMessage = new MessageText(fromBareJid, fromName, m.getBody());
- mListMessages.add(lastMessage);
- } else {
- lastMessage.setMessage(lastMessage.getMessage().concat("\n" + m.getBody()));
+ String name = remoteName;
+ String fromBareJid = StringUtils.parseBareAddress(m.getFrom());
+ if (m.getType() == Message.MSG_TYPE_ERROR) {
+ lastMessage = null;
+ result.add(new MessageText(fromBareJid, name, m.getBody(), true));
+ continue;
+ } else if (m.getType() == Message.MSG_TYPE_CHAT) {
+ if (fromBareJid == null) { //nofrom or from == yours
+ name = localName;
+ fromBareJid = "";
+ }
+
+ if (m.getBody() != null) {
+ if (lastMessage == null || ! fromBareJid.equals(lastMessage.getBareJid())) {
+ lastMessage = new MessageText(fromBareJid, name, m.getBody());
+ result.add(lastMessage);
+ } else {
+ lastMessage.setMessage(lastMessage.getMessage().concat("\n" + m.getBody()));
+ }
}
}
}
- mMessagesListAdapter.notifyDataSetChanged();
+ return result;
}
/**
@@ -387,7 +402,7 @@
public void onServiceConnected(ComponentName name, IBinder service) {
mXmppFacade = IXmppFacade.Stub.asInterface(service);
try {
- if ((mRoster = mXmppFacade.getRoster()) != null )
+ if ((mRoster = mXmppFacade.getRoster()) != null)
mRoster.addRosterListener(mBeemRosterListener);
mContact = new Contact(getIntent().getData());
if ((mChatManager = mXmppFacade.getChatManager()) != null)
@@ -485,8 +500,10 @@
@Override
public void run() {
- //TODO gerer les messages de types error
- if (msg.getBody() != null && msg.getType() != Message.MSG_TYPE_ERROR) {
+ if (msg.getType() == Message.MSG_TYPE_ERROR) {
+ 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;
@@ -521,7 +538,6 @@
// Check for a contact status message update
if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
- Log.d(TAG, "Setting status message - " + mContact.getMsgState());
mContactStatusMsgTextView.setText(mContact.getMsgState());
Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
}
@@ -567,6 +583,7 @@
* Returns the number of messages contained in the messages list.
* @return The number of messages contained in the messages list.
*/
+ @Override
public int getCount() {
return mListMessages.size();
}
@@ -576,8 +593,9 @@
* @param position The position of the requested item.
* @return The item from the messages list at the requested position.
*/
+ @Override
public Object getItem(int position) {
- return position;
+ return mListMessages.get(position);
}
/**
@@ -585,6 +603,7 @@
* @param position The position of the requested item.
* @return The id of an item from the messages list at the requested position.
*/
+ @Override
public long getItemId(int position) {
return position;
}
@@ -597,27 +616,26 @@
* @return A View corresponding to the data at the specified position.
*/
public View getView(int position, View convertView, ViewGroup parent) {
- MessageView sv;
+ View sv;
if (convertView == null) {
- sv = new MessageView(Chat.this, mListMessages.get(position).getName(), mListMessages.get(position)
- .getMessage());
+ LayoutInflater inflater = Chat.this.getLayoutInflater();
+ sv = inflater.inflate(R.layout.chat_msg_row, null);
} else {
- sv = (MessageView) convertView;
- sv.setName(mListMessages.get(position).getName());
- sv.setMessage(mListMessages.get(position).getMessage());
+ sv = convertView;
}
-
- //TODO Put this in the xml layout
- sv.setPadding(2, 2, 2, 4);
-
- sv.mName.setTextSize(16);
- sv.mName.setTextColor(Color.WHITE);
- sv.mName.setTypeface(Typeface.DEFAULT_BOLD);
-
- sv.mMessage.setLinkTextColor(Color.WHITE);
- sv.mMessage.setPadding(0, 4, 0, 4);
- Linkify.addLinks(sv.mMessage, Linkify.WEB_URLS);
-
+ 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());
+ if (msg.isError()) {
+ String err = getString(R.string.chat_error);
+ msgName.setText(err);
+ msgName.setTextColor(Color.RED);
+ msgName.setError(err);
+ }
return sv;
}
}
@@ -630,6 +648,7 @@
private String mBareJid;
private String mName;
private String mMessage;
+ private boolean mIsError;
/**
* Constructor.
@@ -641,6 +660,21 @@
mBareJid = bareJid;
mName = name;
mMessage = message;
+ mIsError = false;
+ }
+
+ /**
+ * Constructor.
+ * @param bareJid A String containing the bare JID of the message's author.
+ * @param name A String containing the name of the message's author.
+ * @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) {
+ mBareJid = bareJid;
+ mName = name;
+ mMessage = message;
+ mIsError = isError;
}
/**
@@ -692,54 +726,13 @@
public void setMessage(String message) {
mMessage = message;
}
- }
-
- /**
- * We will use a MessageView to display each message.
- * TODO : put this in an xml file
- */
- private class MessageView extends LinearLayout {
- private final TextView mName;
- private final TextView mMessage;
/**
- * Constructor.
- * @param context The context of the MessageView
- * @param name A String containing the message's author.
- * @param message A String containing the message.
+ * Get the message type.
+ * @return true if the message is an error message.
*/
- public MessageView(final Context context, final String name, final String message) {
- super(context);
-
- this.setOrientation(VERTICAL);
-
- mName = new TextView(context);
- mName.setText(name);
- addView(mName,
- new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
- android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
-
- mMessage = new TextView(context);
- mMessage.setText(message);
- addView(mMessage,
- new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
- android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
- }
-
- /**
- * Convenience method to set the title of a MessageView.
- * @param name A String containing the message's author.
- */
- public void setName(String name) {
- mName.setText(name);
- }
-
- /**
- * Convenience method to set the dialogue of a MessageView.
- * @param message A String containing the message.
- */
- public void setMessage(String message) {
- mMessage.setText(message);
+ public boolean isError() {
+ return mIsError;
}
}
@@ -781,16 +774,10 @@
if (lastMessage != null && lastMessage.getName().equals(self)) {
lastMessage.setMessage(lastMessage.getMessage().concat("\n" + inputContent));
- mListMessages.set(mListMessages.size() - 1, lastMessage);
} else
mListMessages.add(new MessageText(self, self, inputContent));
mMessagesListAdapter.notifyDataSetChanged();
mInputField.setText(null);
}
}
-
- @Override
- protected void finalize() {
- Log.e("CHATFIN", "FINALIZE");
- }
}
--- a/src/com/beem/project/beem/ui/ContactList.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java Sun Feb 14 17:25:38 2010 +0100
@@ -59,6 +59,7 @@
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.graphics.BitmapFactory;
+import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -72,14 +73,15 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
+import android.widget.LinearLayout;
+import android.widget.ListView;
import android.widget.TextView;
-import android.widget.ListView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
-import android.graphics.drawable.BitmapDrawable;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
@@ -243,7 +245,7 @@
break;
default:
result = super.onContextItemSelected(item);
- break;
+ break;
}
return result;
}
@@ -290,8 +292,11 @@
if (mXmppFacade == null)
bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
else {
+ if (!mSettings.getBoolean("settings_key_hide_groups", false))
+ buildBanner();
+ else
+ hideGroups();
buildContactList();
- buildBanner();
}
}
@@ -386,6 +391,12 @@
* buildBanner.
*/
private void buildBanner() {
+
+ ViewStub stub = (ViewStub) findViewById(R.id.contactlist_stub);
+ if (stub != null)
+ stub.inflate();
+ else
+ ((LinearLayout) findViewById(R.id.contactlist_groupstub)).setVisibility(View.VISIBLE);
Gallery g = (Gallery) findViewById(R.id.contactlist_banner);
g.setOnItemClickListener(new OnItemClickGroupName());
g.setAdapter(mAdapterBanner);
@@ -793,7 +804,10 @@
}
mContactOnGroup.put(getString(R.string.contact_list_all_contact), tmpContactList);
mCurGroup = getString(R.string.contact_list_all_contact);
- buildBanner();
+ if (!mSettings.getBoolean("settings_key_hide_groups", false))
+ buildBanner();
+ else
+ hideGroups();
buildContactList();
}
} catch (RemoteException e) {
@@ -821,4 +835,10 @@
protected void finalize() {
Log.e(TAG, "FINALIZE");
}
+
+ private void hideGroups() {
+ ViewStub stub = (ViewStub) findViewById(R.id.contactlist_stub);
+ if (stub == null)
+ ((LinearLayout) findViewById(R.id.contactlist_groupstub)).setVisibility(View.GONE);
+ }
}
--- a/src/com/beem/project/beem/ui/Login.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/ui/Login.java Sun Feb 14 17:25:38 2010 +0100
@@ -47,6 +47,8 @@
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageInfo;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -169,7 +171,16 @@
*/
private void createAboutDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.login_about_title).setMessage(R.string.login_about_msg).setCancelable(false);
+ String versionname;
+ try {
+ PackageManager pm = getPackageManager();
+ PackageInfo pi = pm.getPackageInfo("com.beem.project.beem", 0);
+ versionname = pi.versionName;
+ } catch (PackageManager.NameNotFoundException e) {
+ versionname = "";
+ }
+ String title = getString(R.string.login_about_title, versionname);
+ builder.setTitle(title).setMessage(R.string.login_about_msg).setCancelable(false);
builder.setNeutralButton(R.string.login_about_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
--- a/src/com/beem/project/beem/ui/LoginAnim.java Sun Jan 24 04:57:37 2010 +0100
+++ b/src/com/beem/project/beem/ui/LoginAnim.java Sun Feb 14 17:25:38 2010 +0100
@@ -209,7 +209,6 @@
@Override
protected void onProgressUpdate(Integer ... values) {
- Log.d(TAG, "onProgress " + values[0]);
mLoginState.setText(getResources().getStringArray(R.array.loganim_state)[values[0]]);
}