Merge
authorNikita Kozlov <nikita@mbdsys.com>
Tue, 18 Jan 2011 00:26:02 +0100
changeset 868 6c2c4bfa43d0
parent 843 237157f79737 (current diff)
parent 867 4c7ba996bae9 (diff)
child 988 d7ddcccdff8a
Merge
default.properties
res/values-fr/strings.xml
res/values/strings.xml
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/service/XmppConnectionAdapter.java
src/com/beem/project/beem/ui/ContactList.java
--- a/default.properties	Mon Jan 17 23:50:00 2011 +0100
+++ b/default.properties	Tue Jan 18 00:26:02 2011 +0100
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-9
+target=android-7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/chat_compact.xml	Tue Jan 18 00:26:02 2011 +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 Jan 18 00:26:02 2011 +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	Mon Jan 17 23:50:00 2011 +0100
+++ b/res/layout/preferences.xml	Tue Jan 18 00:26:02 2011 +0100
@@ -8,6 +8,9 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
 	android:shouldDisableView="true" android:selectable="true">
 	<PreferenceCategory android:title="@string/general_preferences">
+		<CheckBoxPreference android:id="@+id/settings_key_history"
+			android:title="@string/history" android:defaultValue="false"
+			android:key="settings_key_history" />
 		<PreferenceScreen android:key="contact_list"
 			android:title="@string/contact_list_preferences" android:summary="@string/contact_list_preferences_sum">
 			<CheckBoxPreference android:title="@string/CLP_hidden_contact"
@@ -23,15 +26,17 @@
 				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"
 				android:defaultValue="false" android:summary="@string/notification_enable_vibrate_sum"
 				android:key="notification_vibrate" />
-			<RingtonePreference
-				android:title="@string/notification_snd_title" android:key="notification_sound"
-				android:summary="@string/notification_snd_sum" android:ringtoneType="notification"
-				android:showDefault="true" />
+			<RingtonePreference android:title="@string/notification_snd_title"
+				android:key="notification_sound" android:summary="@string/notification_snd_sum"
+				android:ringtoneType="notification" android:showDefault="true" />
 		</PreferenceScreen>
 	</PreferenceCategory>
 	<PreferenceCategory android:title="@string/user_preferences">
@@ -70,7 +75,8 @@
 				<EditTextPreference android:singleLine="true"
 					android:dependency="proxy_use" android:name="port"
 					android:summary="@string/SettingsProxyPort" android:title="@string/settings_proxy_port"
-					android:key="proxy_port" android:numeric="signed" android:hint="@string/comments_proxy_port" />
+					android:key="proxy_port" android:numeric="signed"
+					android:hint="@string/comments_proxy_port" />
 			</PreferenceCategory>
 			<PreferenceCategory android:title="@string/proxy_user_settings">
 				<EditTextPreference android:singleLine="true"
@@ -83,11 +89,14 @@
 					android:title="@string/settings_proxy_password" android:key="proxy_password" />
 			</PreferenceCategory>
 		</PreferenceScreen>
+
 		<PreferenceScreen android:key="advanced"
 			android:title="@string/SettingsAdvanced" android:summary="@string/settings_advanced_sum">
 			<PreferenceCategory android:title="@string/settings_advanced_service_behaviour">
 				<CheckBoxPreference android:title="@string/settings_xmpp_use_tls"
 					android:defaultValue="false" android:key="settings_key_xmpp_tls_use" />
+				<CheckBoxPreference android:title="@string/settings_smack_debug"
+					android:defaultValue="false" android:key="smack_debug" />
 				<EditTextPreference android:singleLine="true"
 					android:title="@string/settings_reco_delay" android:name="Reconnect delay"
 					android:summary="@string/SettingsAdvancedRecoDelay" android:key="settings_key_reco_delay"
@@ -105,6 +114,9 @@
 				android:summary="@string/SettingsAdvancedPortOpt" android:title="@string/settings_xmpp_port"
 				android:defaultValue="5222" android:numeric="signed" android:key="settings_key_xmpp_port"
 				android:hint="@string/comments_xmpp_port" />
+			<CheckBoxPreference android:title="@string/settings_full_jid_login"
+				android:defaultValue="false" android:summary="@string/settings_full_jid_login_sum"
+				android:key="full_jid_login" />
 		</PreferenceScreen>
 	</PreferenceCategory>
 </PreferenceScreen>
--- a/res/values-fr/strings.xml	Mon Jan 17 23:50:00 2011 +0100
+++ b/res/values-fr/strings.xml	Tue Jan 18 00:26:02 2011 +0100
@@ -86,7 +86,7 @@
 	<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>
-	<string name="settings_account_username">Nom d\'utilisateur</string>
+	<string name="settings_account_username">Nom d\'utilisateur (JID)</string>
 	<string name="login_username_info_default">beem@beem-project.com</string>
 	<string name="settings_account_password">Mot de passe</string>
 	<string name="settings_account_server">Serveur</string>
@@ -117,6 +117,14 @@
 	<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>
+	<string name="history">Historique</string>
+	<string name="history_mount">Il vous faut avoir une SDcard utilisable en écriture pour activer l\'historique</string>
+	<string name="history_on_off">Activer la l\'historique des messages</string>
+	<string name="settings_smack_debug">Activer le debugger XMPP</string>
+	<string name="settings_full_jid_login">Utiliser le JID entier en tant que login</string>
+	<string name="settings_full_jid_login_sum">Nécessaire pour certains serveurs (Google Talk)</string>
 	
 	<!-- Subscription class -->
 	<string name="SubscriptAccept">Inscription acceptée</string>
--- a/res/values/strings.xml	Mon Jan 17 23:50:00 2011 +0100
+++ b/res/values/strings.xml	Tue Jan 18 00:26:02 2011 +0100
@@ -86,7 +86,7 @@
 	<string name="CLP_hidden_contact">Hide buddies</string>
 	<string name="CLP_hidden_contact_sum">Check this option to hide unconnected buddies
 	</string>
-	<string name="settings_account_username">Username</string>
+	<string name="settings_account_username">Username (JID)</string>
 	<string name="login_username_info_default">beem@beem-project.com</string>
 	<string name="settings_account_password">Password</string>
 	<string name="settings_account_server">Server</string>
@@ -117,8 +117,15 @@
 	<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>
+	<string name="history">History</string>
+	<string name="history_mount">You need to have SDcard mounted and writable to enable history</string>
+	<string name="history_on_off">Enable history messages</string>
+	<string name="settings_smack_debug">Enable XMPPP debug</string>
+	<string name="settings_full_jid_login">Use my full JID as username</string>
+	<string name="settings_full_jid_login_sum">Need by some server such as Google Talk</string>
 
-	
 	<!-- Subscription class -->
 	<string name="SubscriptAccept">Subscription accepted</string>
 	<string name="SubscriptError">Subscription error</string>
--- a/src/com/beem/project/beem/BeemApplication.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/BeemApplication.java	Tue Jan 18 00:26:02 2011 +0100
@@ -83,6 +83,10 @@
     public static final String NOTIFICATION_VIBRATE_KEY = "notification_vibrate";
     /** Preference key for notification sound. */
     public static final String NOTIFICATION_SOUND_KEY = "notification_sound";
+    /** Preference key for smack debugging. */
+    public static final String SMACK_DEBUG_KEY = "smack_debug";
+    /** Preference key for full Jid for login. */
+    public static final String FULL_JID_LOGIN_KEY = "full_jid_login";
 
     //TODO add the other one
 
--- a/src/com/beem/project/beem/BeemService.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/BeemService.java	Tue Jan 18 00:26:02 2011 +0100
@@ -48,7 +48,6 @@
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
 import org.jivesoftware.smack.Roster.SubscriptionMode;
-import org.jivesoftware.smack.provider.PrivacyProvider;
 import org.jivesoftware.smack.provider.ProviderManager;
 import org.jivesoftware.smackx.provider.DelayInfoProvider;
 import org.jivesoftware.smackx.provider.DiscoverInfoProvider;
@@ -156,7 +155,8 @@
 	    || mSettings.getBoolean("settings_key_gmail", false)) {
 	    mConnectionConfiguration.setSecurityMode(SecurityMode.required);
 	}
-	mConnectionConfiguration.setDebuggerEnabled(false);
+	if (mSettings.getBoolean(BeemApplication.SMACK_DEBUG_KEY, false))
+	    mConnectionConfiguration.setDebuggerEnabled(true);
 	mConnectionConfiguration.setSendPresence(true);
 	// maybe not the universal path, but it works on most devices (Samsung Galaxy, Google Nexus One)
 	mConnectionConfiguration.setTruststoreType("BKS");
@@ -206,11 +206,12 @@
 	if (mSettings.getBoolean("settings_key_specific_server", false)) {
 	    mHost = mSettings.getString("settings_key_xmpp_server", "");
 	    if ("".equals(mHost))
-		mHost = StringUtils.parseServer(tmpJid);
+		mHost = mService;
 	    String tmpPort = mSettings.getString("settings_key_xmpp_port", "5222");
 	    mPort = ("".equals(tmpPort)) ? DEFAULT_XMPP_PORT : Integer.parseInt(tmpPort);
 	}
-	if ("gmail.com".equals(mService) || "googlemail.com".equals(mService))  {
+	if (mSettings.getBoolean(BeemApplication.FULL_JID_LOGIN_KEY, false) ||
+	    "gmail.com".equals(mService) || "googlemail.com".equals(mService))  {
 	    mLogin = tmpJid;
 	}
 
@@ -232,7 +233,6 @@
     @Override
     public void onDestroy() {
 	super.onDestroy();
-	resetStatus();
 	mNotificationManager.cancelAll();
 	unregisterReceiver(mReceiver);
 	mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
@@ -334,7 +334,7 @@
 	pm.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
 
 	// Privacy
-	pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
+	//pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
 	// Delayed Delivery only the new version
 	pm.addExtensionProvider("delay", "urn:xmpp:delay", new DelayInfoProvider());
 
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Tue Jan 18 00:26:02 2011 +0100
@@ -61,8 +61,8 @@
 import android.preference.PreferenceManager;
 import android.util.Log;
 
+import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.BeemService;
-import com.beem.project.beem.R;
 import com.beem.project.beem.service.aidl.IChat;
 import com.beem.project.beem.service.aidl.IChatManager;
 import com.beem.project.beem.service.aidl.IChatManagerListener;
@@ -173,6 +173,12 @@
 	    return mChats.get(key);
 	}
 	ChatAdapter res = new ChatAdapter(chat);
+	boolean history = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getBoolean(
+	    "settings_key_history", false);
+	String accountUser = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString(
+	    BeemApplication.ACCOUNT_USERNAME_KEY, "");
+	res.setHisory(history);
+	res.setAccountUser(accountUser);
 	Log.d(TAG, "getChat put " + key);
 	mChats.put(key, res);
 	return res;
@@ -256,7 +262,7 @@
 	private PendingIntent makeChatIntent(IChat chat) {
 	    Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class);
 	    chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP
-		    | Intent.FLAG_ACTIVITY_NEW_TASK);
+		| Intent.FLAG_ACTIVITY_NEW_TASK);
 	    try {
 		chatIntent.setData(chat.getParticipant().toUri());
 	    } catch (RemoteException e) {
@@ -270,17 +276,17 @@
 	/**
 	 * Set a notification of a new chat.
 	 * @param chat The chat to access by the notification
+	 * @param msgBody the body of the new message
 	 */
-	private void notifyNewChat(IChat chat) {
+	private void notifyNewChat(IChat chat, String msgBody) {
 	    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService);
 	    try {
 		CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID())
-		.getName();
+		    .getName();
 		Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System
 		    .currentTimeMillis());
 		notification.flags = Notification.FLAG_AUTO_CANCEL;
-		notification.setLatestEventInfo(mService, tickerText, mService
-		    .getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat));
+		notification.setLatestEventInfo(mService, tickerText, msgBody, makeChatIntent(chat));
 		mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification);
 	    } catch (RemoteException e) {
 		Log.e(TAG, e.getMessage());
@@ -293,11 +299,12 @@
 	@Override
 	public void processMessage(final IChat chat, Message message) {
 	    try {
-		if (!chat.isOpen() && message.getBody() != null) {
+		String body = message.getBody();
+		if (!chat.isOpen() && body != null) {
 		    if (chat instanceof ChatAdapter) {
 			mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat);
 		    }
-		    notifyNewChat(chat);
+		    notifyNewChat(chat, body);
 		}
 	    } catch (RemoteException e) {
 		Log.e(TAG, e.getMessage());
@@ -305,6 +312,7 @@
 	}
 
 	@Override
-	public void stateChanged(final IChat chat) { }
+	public void stateChanged(final IChat chat) {
+	}
     }
 }
--- a/src/com/beem/project/beem/service/ChatAdapter.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/service/ChatAdapter.java	Tue Jan 18 00:26:02 2011 +0100
@@ -43,15 +43,20 @@
 */
 package com.beem.project.beem.service;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
 import org.jivesoftware.smack.Chat;
 import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smackx.ChatStateListener;
+import org.jivesoftware.smack.util.StringUtils;
 import org.jivesoftware.smackx.ChatState;
+import org.jivesoftware.smackx.ChatStateListener;
 
+import android.os.Environment;
 import android.os.RemoteCallbackList;
 import android.os.RemoteException;
 import android.util.Log;
@@ -74,6 +79,8 @@
     private final List<Message> mMessages;
     private final RemoteCallbackList<IMessageListener> mRemoteListeners = new RemoteCallbackList<IMessageListener>();
     private final MsgListener mMsgListener = new MsgListener();
+    private boolean mIsHisory;
+    private String mAccountUser;
 
     /**
      * Constructor.
@@ -115,6 +122,8 @@
 	    // TODO Auto-generated catch block
 	    e.printStackTrace();
 	}
+	//TODO replace me
+	saveHistory(message, mAccountUser);
     }
 
     /**
@@ -192,6 +201,69 @@
 	if (mMessages.size() == HISTORY_MAX_SIZE)
 	    mMessages.remove(0);
 	mMessages.add(msg);
+	if (!"".equals(msg.getBody()) && msg.getBody() != null) {
+	    saveHistory(msg, msg.getFrom());
+	}
+    }
+
+    /**
+     * Save message in SDCard.
+     * @param msg the message receive
+     * @param contactName the name of the contact
+     */
+    public void saveHistory(Message msg, String contactName) {
+    	String state = Environment.getExternalStorageState();
+    	if (mIsHisory && Environment.MEDIA_MOUNTED.equals(state)) {
+    	    File path = new File(Environment.getExternalStorageDirectory(), "beem");
+    	    File filepath;
+    	    if (msg.getFrom() == contactName)
+    		filepath = new File(path, StringUtils.parseBareAddress(contactName));
+    	    else
+    		filepath = new File(path, StringUtils.parseBareAddress(msg.getTo()));
+    	    path.mkdirs();
+    	    try {
+    	    	FileWriter file = new FileWriter(filepath, true);
+    		String log = msg.getTimestamp() + " " + contactName + " " + msg.getBody()
+    			+ System.getProperty("line.separator");
+    		file.write(log);
+    		file.close();
+    		Log.i(TAG, log);
+    	    } catch (IOException e) {
+    	    	e.printStackTrace();
+    	    }
+    	}
+    }
+
+    /**
+     * set History state.
+     * @param isHisory history state
+     */
+    public void setHisory(boolean isHisory) {
+	this.mIsHisory = isHisory;
+    }
+
+    /**
+     * get History state.
+     * @return mIsHistory
+     */
+    public boolean getHisory() {
+	return mIsHisory;
+    }
+
+    /**
+     * Set Account user name.
+     * @param accountUser user name
+     */
+    public void setAccountUser(String accountUser) {
+	mAccountUser = accountUser;
+    }
+
+    /**
+     * get Account user name.
+     * @return mAccountUser
+     */
+    public String getAccountUser() {
+	return mAccountUser;
     }
 
     /**
@@ -201,11 +273,12 @@
 	/**
 	 * Constructor.
 	 */
-	public MsgListener() { }
+	public MsgListener() {
+	}
 
 	@Override
 	public void processMessage(Chat chat, org.jivesoftware.smack.packet.Message message) {
-	    Message  msg = new Message(message);
+	    Message msg = new Message(message);
 	    //TODO add que les message pas de type errors
 	    ChatAdapter.this.addMessage(msg);
 	    final int n = mRemoteListeners.beginBroadcast();
@@ -241,4 +314,3 @@
 	}
     }
 }
-
--- a/src/com/beem/project/beem/service/Contact.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/service/Contact.java	Tue Jan 18 00:26:02 2011 +0100
@@ -140,6 +140,28 @@
     }
 
     /**
+     * Make an xmpp uri for a spcific jid.
+     *
+     * @param jid the jid to represent as an uri
+     * @return an uri representing this jid.
+     */
+    public static Uri makeXmppUri(String jid) {
+	StringBuilder build = new StringBuilder("xmpp:");
+	String name = StringUtils.parseName(jid);
+	build.append(name);
+	if (!"".equals(name))
+	    build.append('@');
+	build.append(StringUtils.parseServer(jid));
+	String resource = StringUtils.parseResource(jid);
+	if (!"".equals(resource)) {
+	    build.append('/');
+	    build.append(resource);
+	}
+	Uri u = Uri.parse(build.toString());
+	return u;
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -387,14 +409,7 @@
      * @return the URI
      */
     public Uri toUri() {
-	StringBuilder build = new StringBuilder("xmpp:");
-	String name = StringUtils.parseName(mJID);
-	build.append(name);
-	if (!"".equals(name))
-	    build.append('@');
-	build.append(StringUtils.parseServer(mJID));
-	Uri u = Uri.parse(build.toString());
-	return u;
+	return makeXmppUri(mJID);
     }
 
     /**
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Tue Jan 18 00:26:02 2011 +0100
@@ -115,6 +115,7 @@
     private BeemApplication mApplication;
     private AvatarManager mAvatarManager;
     private PepSubManager mPepManager;
+    private SharedPreferences mPref;
     private final RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners =
 	new RemoteCallbackList<IBeemConnectionListener>();
     private final SubscribePacketListener mSubscribePacketListener = new SubscribePacketListener();
@@ -163,13 +164,13 @@
 	if (ctx instanceof BeemApplication) {
 	    mApplication = (BeemApplication) ctx;
 	}
-	SharedPreferences pref = mService.getServicePreference();
+	mPref = mService.getServicePreference();
 	try {
-	    mPreviousPriority = Integer.parseInt(pref.getString("settings_key_priority", "0"));
-	    mResource = pref.getString("settings_key_resource", "BEEM");
+	    mPreviousPriority = Integer.parseInt(mPref.getString("settings_key_priority", "0"));
 	} catch (NumberFormatException ex) {
 	    mPreviousPriority = 0;
 	}
+	mResource = mPref.getString("settings_key_resource", "BEEM");
     }
 
     /**
@@ -237,14 +238,17 @@
 
 	    mAdaptee.login(mLogin, mPassword, mResource);
 	    mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService);
-	    mPrivacyListManager = new PrivacyListManagerAdapter(PrivacyListManager.getInstanceFor(mAdaptee));
-	    mService.resetStatus();
+	    //nikita: I commented this line because of the logs provided in http://www.beem-project.com/issues/321
+	    //Also, since the privacylistmanager isn't finished and used, it will be safer to not initialize it
+	    //mPrivacyListManager = new PrivacyListManagerAdapter(PrivacyListManager.getInstanceFor(mAdaptee));
 	    mService.initJingle(mAdaptee);
 	    discoverServerFeatures();
 
 	    mRoster = new RosterAdapter(mAdaptee.getRoster(), mService, mAvatarManager);
 	    mApplication.setConnected(true);
-	    changeStatus(Status.CONTACT_STATUS_AVAILABLE, mService.getServicePreference().getString("status_text", ""));
+	    int mode = mPref.getInt(BeemApplication.STATUS_KEY, 0);
+	    String status = mPref.getString(BeemApplication.STATUS_TEXT_KEY, "");
+	    changeStatus(mode, status);
 	    return true;
 	} catch (XMPPException e) {
 	    Log.e(TAG, "Error while connecting", e);
@@ -458,7 +462,7 @@
 	    sdm = new ServiceDiscoveryManager(mAdaptee);
 
 	sdm.addFeature("http://jabber.org/protocol/disco#info");
-	sdm.addFeature("jabber:iq:privacy");
+	//nikita: must be uncommented when the feature will be enabled
 	sdm.addFeature("urn:xmpp:jingle:1");
 	sdm.addFeature("urn:xmpp:jingle:apps:rtp:1");
 	sdm.addFeature("urn:xmpp:jingle:apps:rtp:audio");
@@ -697,7 +701,7 @@
 		R.string.AcceptContactRequest, from), System.currentTimeMillis());
 	    notification.flags = Notification.FLAG_AUTO_CANCEL;
 	    Intent intent = new Intent(mService, Subscription.class);
-	    intent.putExtra("from", from);
+	    intent.setData(Contact.makeXmppUri(from));
 	    notification.setLatestEventInfo(mService, from, mService
 		.getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0,
 		    intent, PendingIntent.FLAG_ONE_SHOT));
--- a/src/com/beem/project/beem/ui/ChangeStatus.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java	Tue Jan 18 00:26:02 2011 +0100
@@ -55,7 +55,6 @@
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.preference.PreferenceManager;
-import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.ArrayAdapter;
@@ -163,7 +162,6 @@
     @Override
     protected void onPause() {
 	super.onPause();
-	Log.d("TAG", "pause");
 	unbindService(mServConn);
     }
 
--- a/src/com/beem/project/beem/ui/Chat.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java	Tue Jan 18 00:26:02 2011 +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,17 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
 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 +78,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;
@@ -122,10 +125,10 @@
     private TextView mContactStatusMsgTextView;
     private TextView mContactChatState;
     private ImageView mContactStatusIcon;
+    private LayerDrawable mAvatarStatusDrawable;
     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 +144,7 @@
     private final BeemRosterListener mBeemRosterListener = new BeemRosterListener();
     private IXmppFacade mXmppFacade;
     private boolean mBinded;
+    private boolean mCompact;
 
     /**
      * Constructor.
@@ -155,16 +159,21 @@
     @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);
+	    mAvatarStatusDrawable = (LayerDrawable) mContactStatusIcon.getDrawable();
+	    mAvatarStatusDrawable.setLayerInset(1, 36, 36, 0, 0);
+	} else {
+	    setContentView(R.layout.chat_compact);
+	}
 	mMessagesListView = (ListView) findViewById(R.id.chat_messages);
 	mMessagesListView.setAdapter(mMessagesListAdapter);
 	mInputField = (EditText) findViewById(R.id.chat_input);
@@ -177,7 +186,6 @@
 		sendMessage();
 	    }
 	});
-
 	prepareIconsStatus();
     }
 
@@ -498,7 +506,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 +519,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 +549,8 @@
 		    } else if ("paused".equals(state)) {
 			text = Chat.this.getString(R.string.chat_state_active);
 		    }
-		    mContactChatState.setText(text);
+		    if (!mCompact)
+			mContactChatState.setText(text);
 		}
 	    });
 
@@ -555,20 +566,28 @@
 	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() + ")");
 	}
     }
 
+
+
     /**
      * Update the contact status icon.
      */
     private void updateContactStatusIcon() {
+	if (mCompact)
+	    return;
 	Drawable avatar = getAvatarDrawable(mContact.getAvatarId());
 	mAvatarStatusDrawable.setDrawableByLayerId(R.id.avatar, avatar);
 	mContactStatusIcon.setImageLevel(mContact.getStatus());
@@ -594,7 +613,7 @@
 	if (avatarDrawable == null)
 	    avatarDrawable = getResources().getDrawable(R.drawable.beem_launcher_icon_silver);
 	return avatarDrawable;
-    }
+     }
 
     /**
      * Prepare the status icons map.
@@ -665,26 +684,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 +749,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 +765,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;
@@ -804,7 +834,6 @@
 
 	/**
 	 * Set the Date of the message.
-	 *
 	 * @param date date of the message.
 	 */
 	public void setTimestamp(Date date) {
@@ -813,7 +842,6 @@
 
 	/**
 	 * Get the Date of the message.
-	 *
 	 * @return if it is a delayed message get the date the message was sended.
 	 */
 	public Date getTimestamp() {
--- a/src/com/beem/project/beem/ui/ContactList.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java	Tue Jan 18 00:26:02 2011 +0100
@@ -683,10 +683,12 @@
 		 private Drawable getAvatarStatusDrawable(String avatarId) {
 			 Drawable avatarDrawable = null;
 			 try {
-				 byte[] avatar = mXmppFacade.getAvatar(avatarId);
-				 if (avatar != null) {
-					 ByteArrayInputStream in = new ByteArrayInputStream(avatar);
-					 avatarDrawable = Drawable.createFromStream(in, avatarId);
+		if (mXmppFacade != null) {
+		    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);
--- a/src/com/beem/project/beem/ui/Settings.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/ui/Settings.java	Tue Jan 18 00:26:02 2011 +0100
@@ -46,6 +46,8 @@
 import android.content.ComponentName;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.Environment;
+import android.preference.CheckBoxPreference;
 import android.preference.PreferenceActivity;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -74,6 +76,15 @@
     public void onCreate(Bundle savedInstanceState) {
 	super.onCreate(savedInstanceState);
 	addPreferencesFromResource(R.layout.preferences);
+	CheckBoxPreference history = (CheckBoxPreference) findPreference("settings_key_history");
+	String state = Environment.getExternalStorageState();
+	if (!Environment.MEDIA_MOUNTED.equals(state)) {
+	    history.setSelectable(false);
+	    history.setSummary(R.string.history_mount);
+	} else {
+	    history.setSelectable(true);
+	    history.setSummary(R.string.history_on_off);
+	}
     }
 
     /**
--- a/src/com/beem/project/beem/ui/Subscription.java	Mon Jan 17 23:50:00 2011 +0100
+++ b/src/com/beem/project/beem/ui/Subscription.java	Tue Jan 18 00:26:02 2011 +0100
@@ -54,6 +54,7 @@
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
+import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.TextView;
@@ -63,6 +64,7 @@
 import com.beem.project.beem.R;
 import com.beem.project.beem.service.PresenceAdapter;
 import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.service.Contact;
 import com.beem.project.beem.utils.BeemBroadcastReceiver;
 
 /**
@@ -72,6 +74,7 @@
 public class Subscription extends Activity {
 
     private static final Intent SERVICE_INTENT = new Intent();
+    private static final String TAG = Subscription.class.getSimpleName();
     private IXmppFacade mService;
     private String mContact;
     private ServiceConnection mServConn = new BeemServiceConnection();
@@ -97,7 +100,8 @@
 	setContentView(R.layout.subscription);
 	findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener);
 	findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener);
-	mContact = getIntent().getStringExtra("from");
+	Contact c = new Contact(getIntent().getData());
+	mContact = c.getJID();
 	TextView tv = (TextView) findViewById(R.id.SubscriptionText);
 	String str = String.format(getString(R.string.SubscriptText), mContact);
 	tv.setText(str);
@@ -132,6 +136,20 @@
     }
 
     /**
+     * Send the presence stanza.
+     *
+     * @param p presence stanza
+     */
+    private void sendPresence(Presence p) {
+	PresenceAdapter preAdapt = new PresenceAdapter(p);
+	try {
+	    mService.sendPresencePacket(preAdapt);
+	} catch (RemoteException e) {
+	    Log.e(TAG, "Error while sending subscription response", e);
+	}
+    }
+
+    /**
      * Event simple click on buttons.
      */
     private class MyOnClickListener implements OnClickListener {
@@ -144,29 +162,25 @@
 
 	@Override
 	public void onClick(View v) {
+	    Presence presence = null;
 	    switch (v.getId()) {
 		case R.id.SubscriptionAccept:
-		    Presence presence = new Presence(Type.subscribed);
-		    presence.setTo(mContact);
-		    PresenceAdapter preAdapt = new PresenceAdapter(presence);
-		    try {
-			mService.sendPresencePacket(preAdapt);
-			Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), Toast.LENGTH_SHORT)
+		    presence = new Presence(Type.subscribed);
+		    Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), Toast.LENGTH_SHORT)
 			    .show();
-			finish();
-		    } catch (RemoteException e) {
-			Toast.makeText(Subscription.this, getString(R.string.SubscriptError), Toast.LENGTH_SHORT)
-			    .show();
-			e.printStackTrace();
-		    }
 		    break;
 		case R.id.SubscriptionRefuse:
+		    presence = new Presence(Type.unsubscribed);
 		    Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused), Toast.LENGTH_SHORT).show();
-		    finish();
 		    break;
 		default:
 		    Toast.makeText(Subscription.this, getString(R.string.SubscriptError), Toast.LENGTH_SHORT).show();
 	    }
+	    if (presence != null) {
+		presence.setTo(mContact);
+		sendPresence(presence);
+	    }
+	    finish();
 	}
     };