Merge default tip
authorNikita Kozlov <nikita@mbdsys.com>
Tue, 18 Jan 2011 00:26:02 +0100
changeset 8686c2c4bfa43d0
parent 843 237157f79737
parent 867 4c7ba996bae9
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
     1.1 --- a/default.properties	Mon Jan 17 23:50:00 2011 +0100
     1.2 +++ b/default.properties	Tue Jan 18 00:26:02 2011 +0100
     1.3 @@ -8,4 +8,4 @@
     1.4  # project structure.
     1.5  
     1.6  # Project target.
     1.7 -target=android-9
     1.8 +target=android-7
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/res/layout/chat_compact.xml	Tue Jan 18 00:26:02 2011 +0100
     2.3 @@ -0,0 +1,27 @@
     2.4 +<?xml version="1.0" encoding="utf-8"?>
     2.5 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2.6 +	android:layout_width="fill_parent" android:layout_height="fill_parent"
     2.7 +	android:orientation="vertical">
     2.8 +	<View android:layout_width="fill_parent" android:layout_height="2dp"
     2.9 +		android:fadingEdge="horizontal" android:background="#222222" />
    2.10 +	<ListView android:id="@+id/chat_messages"
    2.11 +		android:layout_width="fill_parent" android:layout_height="0dip"
    2.12 +		android:layout_weight="1" android:transcriptMode="normal"
    2.13 +		android:stackFromBottom="true"
    2.14 +		android:fadingEdge="none" android:padding="4px"
    2.15 +		android:fastScrollEnabled="true" android:smoothScrollbar="false"
    2.16 +		android:focusable="true"/>
    2.17 +	<LinearLayout android:layout_width="fill_parent"
    2.18 +		android:layout_height="wrap_content" android:orientation="horizontal"
    2.19 +		android:background="#222222" android:padding="8px">
    2.20 +		<EditText android:id="@+id/chat_input" android:layout_width="0dip"
    2.21 +			android:layout_height="fill_parent" android:layout_weight="1"
    2.22 +			android:maxLines="5"
    2.23 +			android:inputType="textShortMessage|textAutoCorrect|textMultiLine"
    2.24 +			android:imeOptions="actionSend" android:cursorVisible="true"
    2.25 +			android:hint="@string/chat_input_default_value" />
    2.26 +		<Button android:id="@+id/chat_send_message"
    2.27 +			android:layout_width="wrap_content" android:layout_height="fill_parent"
    2.28 +			android:text="@string/chat_send_message" />
    2.29 +	</LinearLayout>
    2.30 +</LinearLayout>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/res/layout/chat_msg_row_compact.xml	Tue Jan 18 00:26:02 2011 +0100
     3.3 @@ -0,0 +1,16 @@
     3.4 +<?xml version="1.0" encoding="utf-8"?>
     3.5 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3.6 +	android:orientation="vertical" android:layout_width="fill_parent"
     3.7 +	android:layout_height="wrap_content">
     3.8 +	<TextView android:id="@+id/chatmessagedate"
     3.9 +		android:layout_width="wrap_content" android:layout_height="wrap_content"
    3.10 +		android:autoLink="none" android:layout_marginRight="4dp" />
    3.11 +	<TextView android:id="@+id/chatmessagename"
    3.12 +		android:layout_width="wrap_content" android:layout_height="wrap_content"
    3.13 +		android:textSize="14sp" android:textColor="#FFFFFF" android:textStyle="bold"
    3.14 +		android:layout_toRightOf="@id/chatmessagedate" android:layout_marginRight="4dp" />
    3.15 +	<TextView android:id="@+id/chatmessagetext"
    3.16 +		android:layout_width="wrap_content" android:layout_height="wrap_content"
    3.17 +		android:layout_toRightOf="@id/chatmessagename" android:autoLink="all" />
    3.18 +</RelativeLayout>
    3.19 +
     4.1 --- a/res/layout/preferences.xml	Mon Jan 17 23:50:00 2011 +0100
     4.2 +++ b/res/layout/preferences.xml	Tue Jan 18 00:26:02 2011 +0100
     4.3 @@ -8,6 +8,9 @@
     4.4  <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
     4.5  	android:shouldDisableView="true" android:selectable="true">
     4.6  	<PreferenceCategory android:title="@string/general_preferences">
     4.7 +		<CheckBoxPreference android:id="@+id/settings_key_history"
     4.8 +			android:title="@string/history" android:defaultValue="false"
     4.9 +			android:key="settings_key_history" />
    4.10  		<PreferenceScreen android:key="contact_list"
    4.11  			android:title="@string/contact_list_preferences" android:summary="@string/contact_list_preferences_sum">
    4.12  			<CheckBoxPreference android:title="@string/CLP_hidden_contact"
    4.13 @@ -23,15 +26,17 @@
    4.14  				android:singleLine="true" android:summary="@string/away_message_sum"
    4.15  				android:title="@string/away_message_title" android:key="settings_away_message"
    4.16  				android:hint="@string/away_message_hint" />
    4.17 +			<CheckBoxPreference android:title="@string/settings_chat_compact"
    4.18 +				android:defaultValue="false" android:summary="@string/settings_chat_compact_sum"
    4.19 +				android:key="settings_chat_compact_key" />
    4.20  		</PreferenceScreen>
    4.21  		<PreferenceScreen android:title="@string/notification_preferences">
    4.22  			<CheckBoxPreference android:title="@string/notification_enable_vibrate_title"
    4.23  				android:defaultValue="false" android:summary="@string/notification_enable_vibrate_sum"
    4.24  				android:key="notification_vibrate" />
    4.25 -			<RingtonePreference
    4.26 -				android:title="@string/notification_snd_title" android:key="notification_sound"
    4.27 -				android:summary="@string/notification_snd_sum" android:ringtoneType="notification"
    4.28 -				android:showDefault="true" />
    4.29 +			<RingtonePreference android:title="@string/notification_snd_title"
    4.30 +				android:key="notification_sound" android:summary="@string/notification_snd_sum"
    4.31 +				android:ringtoneType="notification" android:showDefault="true" />
    4.32  		</PreferenceScreen>
    4.33  	</PreferenceCategory>
    4.34  	<PreferenceCategory android:title="@string/user_preferences">
    4.35 @@ -70,7 +75,8 @@
    4.36  				<EditTextPreference android:singleLine="true"
    4.37  					android:dependency="proxy_use" android:name="port"
    4.38  					android:summary="@string/SettingsProxyPort" android:title="@string/settings_proxy_port"
    4.39 -					android:key="proxy_port" android:numeric="signed" android:hint="@string/comments_proxy_port" />
    4.40 +					android:key="proxy_port" android:numeric="signed"
    4.41 +					android:hint="@string/comments_proxy_port" />
    4.42  			</PreferenceCategory>
    4.43  			<PreferenceCategory android:title="@string/proxy_user_settings">
    4.44  				<EditTextPreference android:singleLine="true"
    4.45 @@ -83,11 +89,14 @@
    4.46  					android:title="@string/settings_proxy_password" android:key="proxy_password" />
    4.47  			</PreferenceCategory>
    4.48  		</PreferenceScreen>
    4.49 +
    4.50  		<PreferenceScreen android:key="advanced"
    4.51  			android:title="@string/SettingsAdvanced" android:summary="@string/settings_advanced_sum">
    4.52  			<PreferenceCategory android:title="@string/settings_advanced_service_behaviour">
    4.53  				<CheckBoxPreference android:title="@string/settings_xmpp_use_tls"
    4.54  					android:defaultValue="false" android:key="settings_key_xmpp_tls_use" />
    4.55 +				<CheckBoxPreference android:title="@string/settings_smack_debug"
    4.56 +					android:defaultValue="false" android:key="smack_debug" />
    4.57  				<EditTextPreference android:singleLine="true"
    4.58  					android:title="@string/settings_reco_delay" android:name="Reconnect delay"
    4.59  					android:summary="@string/SettingsAdvancedRecoDelay" android:key="settings_key_reco_delay"
    4.60 @@ -105,6 +114,9 @@
    4.61  				android:summary="@string/SettingsAdvancedPortOpt" android:title="@string/settings_xmpp_port"
    4.62  				android:defaultValue="5222" android:numeric="signed" android:key="settings_key_xmpp_port"
    4.63  				android:hint="@string/comments_xmpp_port" />
    4.64 +			<CheckBoxPreference android:title="@string/settings_full_jid_login"
    4.65 +				android:defaultValue="false" android:summary="@string/settings_full_jid_login_sum"
    4.66 +				android:key="full_jid_login" />
    4.67  		</PreferenceScreen>
    4.68  	</PreferenceCategory>
    4.69  </PreferenceScreen>
     5.1 --- a/res/values-fr/strings.xml	Mon Jan 17 23:50:00 2011 +0100
     5.2 +++ b/res/values-fr/strings.xml	Tue Jan 18 00:26:02 2011 +0100
     5.3 @@ -86,7 +86,7 @@
     5.4  	<string name="CLP_hide_groups_sum">Cochez cette option pour cacher les groupes</string>
     5.5  	<string name="CLP_hidden_contact">Cachez les contacts</string>
     5.6  	<string name="CLP_hidden_contact_sum">Cochez cette option pour cacher les contacts déconnectés</string>
     5.7 -	<string name="settings_account_username">Nom d\'utilisateur</string>
     5.8 +	<string name="settings_account_username">Nom d\'utilisateur (JID)</string>
     5.9  	<string name="login_username_info_default">beem@beem-project.com</string>
    5.10  	<string name="settings_account_password">Mot de passe</string>
    5.11  	<string name="settings_account_server">Serveur</string>
    5.12 @@ -117,6 +117,14 @@
    5.13  	<string name="notification_enable_vibrate_sum">Activer le vibreur pour les messages entrants</string>
    5.14  	<string name="notification_snd_title">Sonnerie des messages</string>
    5.15  	<string name="notification_snd_sum">Configurer la sonnerie des messages entrants</string>
    5.16 +	<string name="settings_chat_compact">Chat compact</string>
    5.17 +	<string name="settings_chat_compact_sum">Activer la fenetre Chat compact</string>
    5.18 +	<string name="history">Historique</string>
    5.19 +	<string name="history_mount">Il vous faut avoir une SDcard utilisable en écriture pour activer l\'historique</string>
    5.20 +	<string name="history_on_off">Activer la l\'historique des messages</string>
    5.21 +	<string name="settings_smack_debug">Activer le debugger XMPP</string>
    5.22 +	<string name="settings_full_jid_login">Utiliser le JID entier en tant que login</string>
    5.23 +	<string name="settings_full_jid_login_sum">Nécessaire pour certains serveurs (Google Talk)</string>
    5.24  	
    5.25  	<!-- Subscription class -->
    5.26  	<string name="SubscriptAccept">Inscription acceptée</string>
     6.1 --- a/res/values/strings.xml	Mon Jan 17 23:50:00 2011 +0100
     6.2 +++ b/res/values/strings.xml	Tue Jan 18 00:26:02 2011 +0100
     6.3 @@ -86,7 +86,7 @@
     6.4  	<string name="CLP_hidden_contact">Hide buddies</string>
     6.5  	<string name="CLP_hidden_contact_sum">Check this option to hide unconnected buddies
     6.6  	</string>
     6.7 -	<string name="settings_account_username">Username</string>
     6.8 +	<string name="settings_account_username">Username (JID)</string>
     6.9  	<string name="login_username_info_default">beem@beem-project.com</string>
    6.10  	<string name="settings_account_password">Password</string>
    6.11  	<string name="settings_account_server">Server</string>
    6.12 @@ -117,8 +117,15 @@
    6.13  	<string name="notification_enable_vibrate_sum">Enable vibrate on incoming messages</string>
    6.14  	<string name="notification_snd_title">Message ringtone</string>
    6.15  	<string name="notification_snd_sum">Set your incoming message ringtone</string>
    6.16 +	<string name="settings_chat_compact">Chat compact</string>
    6.17 +	<string name="settings_chat_compact_sum">Set the chat windows compact</string>
    6.18 +	<string name="history">History</string>
    6.19 +	<string name="history_mount">You need to have SDcard mounted and writable to enable history</string>
    6.20 +	<string name="history_on_off">Enable history messages</string>
    6.21 +	<string name="settings_smack_debug">Enable XMPPP debug</string>
    6.22 +	<string name="settings_full_jid_login">Use my full JID as username</string>
    6.23 +	<string name="settings_full_jid_login_sum">Need by some server such as Google Talk</string>
    6.24  
    6.25 -	
    6.26  	<!-- Subscription class -->
    6.27  	<string name="SubscriptAccept">Subscription accepted</string>
    6.28  	<string name="SubscriptError">Subscription error</string>
     7.1 --- a/src/com/beem/project/beem/BeemApplication.java	Mon Jan 17 23:50:00 2011 +0100
     7.2 +++ b/src/com/beem/project/beem/BeemApplication.java	Tue Jan 18 00:26:02 2011 +0100
     7.3 @@ -83,6 +83,10 @@
     7.4      public static final String NOTIFICATION_VIBRATE_KEY = "notification_vibrate";
     7.5      /** Preference key for notification sound. */
     7.6      public static final String NOTIFICATION_SOUND_KEY = "notification_sound";
     7.7 +    /** Preference key for smack debugging. */
     7.8 +    public static final String SMACK_DEBUG_KEY = "smack_debug";
     7.9 +    /** Preference key for full Jid for login. */
    7.10 +    public static final String FULL_JID_LOGIN_KEY = "full_jid_login";
    7.11  
    7.12      //TODO add the other one
    7.13  
     8.1 --- a/src/com/beem/project/beem/BeemService.java	Mon Jan 17 23:50:00 2011 +0100
     8.2 +++ b/src/com/beem/project/beem/BeemService.java	Tue Jan 18 00:26:02 2011 +0100
     8.3 @@ -48,7 +48,6 @@
     8.4  import org.jivesoftware.smack.XMPPConnection;
     8.5  import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
     8.6  import org.jivesoftware.smack.Roster.SubscriptionMode;
     8.7 -import org.jivesoftware.smack.provider.PrivacyProvider;
     8.8  import org.jivesoftware.smack.provider.ProviderManager;
     8.9  import org.jivesoftware.smackx.provider.DelayInfoProvider;
    8.10  import org.jivesoftware.smackx.provider.DiscoverInfoProvider;
    8.11 @@ -156,7 +155,8 @@
    8.12  	    || mSettings.getBoolean("settings_key_gmail", false)) {
    8.13  	    mConnectionConfiguration.setSecurityMode(SecurityMode.required);
    8.14  	}
    8.15 -	mConnectionConfiguration.setDebuggerEnabled(false);
    8.16 +	if (mSettings.getBoolean(BeemApplication.SMACK_DEBUG_KEY, false))
    8.17 +	    mConnectionConfiguration.setDebuggerEnabled(true);
    8.18  	mConnectionConfiguration.setSendPresence(true);
    8.19  	// maybe not the universal path, but it works on most devices (Samsung Galaxy, Google Nexus One)
    8.20  	mConnectionConfiguration.setTruststoreType("BKS");
    8.21 @@ -206,11 +206,12 @@
    8.22  	if (mSettings.getBoolean("settings_key_specific_server", false)) {
    8.23  	    mHost = mSettings.getString("settings_key_xmpp_server", "");
    8.24  	    if ("".equals(mHost))
    8.25 -		mHost = StringUtils.parseServer(tmpJid);
    8.26 +		mHost = mService;
    8.27  	    String tmpPort = mSettings.getString("settings_key_xmpp_port", "5222");
    8.28  	    mPort = ("".equals(tmpPort)) ? DEFAULT_XMPP_PORT : Integer.parseInt(tmpPort);
    8.29  	}
    8.30 -	if ("gmail.com".equals(mService) || "googlemail.com".equals(mService))  {
    8.31 +	if (mSettings.getBoolean(BeemApplication.FULL_JID_LOGIN_KEY, false) ||
    8.32 +	    "gmail.com".equals(mService) || "googlemail.com".equals(mService))  {
    8.33  	    mLogin = tmpJid;
    8.34  	}
    8.35  
    8.36 @@ -232,7 +233,6 @@
    8.37      @Override
    8.38      public void onDestroy() {
    8.39  	super.onDestroy();
    8.40 -	resetStatus();
    8.41  	mNotificationManager.cancelAll();
    8.42  	unregisterReceiver(mReceiver);
    8.43  	mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
    8.44 @@ -334,7 +334,7 @@
    8.45  	pm.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
    8.46  
    8.47  	// Privacy
    8.48 -	pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
    8.49 +	//pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
    8.50  	// Delayed Delivery only the new version
    8.51  	pm.addExtensionProvider("delay", "urn:xmpp:delay", new DelayInfoProvider());
    8.52  
     9.1 --- a/src/com/beem/project/beem/service/BeemChatManager.java	Mon Jan 17 23:50:00 2011 +0100
     9.2 +++ b/src/com/beem/project/beem/service/BeemChatManager.java	Tue Jan 18 00:26:02 2011 +0100
     9.3 @@ -61,8 +61,8 @@
     9.4  import android.preference.PreferenceManager;
     9.5  import android.util.Log;
     9.6  
     9.7 +import com.beem.project.beem.BeemApplication;
     9.8  import com.beem.project.beem.BeemService;
     9.9 -import com.beem.project.beem.R;
    9.10  import com.beem.project.beem.service.aidl.IChat;
    9.11  import com.beem.project.beem.service.aidl.IChatManager;
    9.12  import com.beem.project.beem.service.aidl.IChatManagerListener;
    9.13 @@ -173,6 +173,12 @@
    9.14  	    return mChats.get(key);
    9.15  	}
    9.16  	ChatAdapter res = new ChatAdapter(chat);
    9.17 +	boolean history = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getBoolean(
    9.18 +	    "settings_key_history", false);
    9.19 +	String accountUser = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString(
    9.20 +	    BeemApplication.ACCOUNT_USERNAME_KEY, "");
    9.21 +	res.setHisory(history);
    9.22 +	res.setAccountUser(accountUser);
    9.23  	Log.d(TAG, "getChat put " + key);
    9.24  	mChats.put(key, res);
    9.25  	return res;
    9.26 @@ -256,7 +262,7 @@
    9.27  	private PendingIntent makeChatIntent(IChat chat) {
    9.28  	    Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class);
    9.29  	    chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP
    9.30 -		    | Intent.FLAG_ACTIVITY_NEW_TASK);
    9.31 +		| Intent.FLAG_ACTIVITY_NEW_TASK);
    9.32  	    try {
    9.33  		chatIntent.setData(chat.getParticipant().toUri());
    9.34  	    } catch (RemoteException e) {
    9.35 @@ -270,17 +276,17 @@
    9.36  	/**
    9.37  	 * Set a notification of a new chat.
    9.38  	 * @param chat The chat to access by the notification
    9.39 +	 * @param msgBody the body of the new message
    9.40  	 */
    9.41 -	private void notifyNewChat(IChat chat) {
    9.42 +	private void notifyNewChat(IChat chat, String msgBody) {
    9.43  	    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService);
    9.44  	    try {
    9.45  		CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID())
    9.46 -		.getName();
    9.47 +		    .getName();
    9.48  		Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System
    9.49  		    .currentTimeMillis());
    9.50  		notification.flags = Notification.FLAG_AUTO_CANCEL;
    9.51 -		notification.setLatestEventInfo(mService, tickerText, mService
    9.52 -		    .getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat));
    9.53 +		notification.setLatestEventInfo(mService, tickerText, msgBody, makeChatIntent(chat));
    9.54  		mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification);
    9.55  	    } catch (RemoteException e) {
    9.56  		Log.e(TAG, e.getMessage());
    9.57 @@ -293,11 +299,12 @@
    9.58  	@Override
    9.59  	public void processMessage(final IChat chat, Message message) {
    9.60  	    try {
    9.61 -		if (!chat.isOpen() && message.getBody() != null) {
    9.62 +		String body = message.getBody();
    9.63 +		if (!chat.isOpen() && body != null) {
    9.64  		    if (chat instanceof ChatAdapter) {
    9.65  			mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat);
    9.66  		    }
    9.67 -		    notifyNewChat(chat);
    9.68 +		    notifyNewChat(chat, body);
    9.69  		}
    9.70  	    } catch (RemoteException e) {
    9.71  		Log.e(TAG, e.getMessage());
    9.72 @@ -305,6 +312,7 @@
    9.73  	}
    9.74  
    9.75  	@Override
    9.76 -	public void stateChanged(final IChat chat) { }
    9.77 +	public void stateChanged(final IChat chat) {
    9.78 +	}
    9.79      }
    9.80  }
    10.1 --- a/src/com/beem/project/beem/service/ChatAdapter.java	Mon Jan 17 23:50:00 2011 +0100
    10.2 +++ b/src/com/beem/project/beem/service/ChatAdapter.java	Tue Jan 18 00:26:02 2011 +0100
    10.3 @@ -43,15 +43,20 @@
    10.4  */
    10.5  package com.beem.project.beem.service;
    10.6  
    10.7 +import java.io.File;
    10.8 +import java.io.FileWriter;
    10.9 +import java.io.IOException;
   10.10  import java.util.Collections;
   10.11  import java.util.LinkedList;
   10.12  import java.util.List;
   10.13  
   10.14  import org.jivesoftware.smack.Chat;
   10.15  import org.jivesoftware.smack.XMPPException;
   10.16 +import org.jivesoftware.smack.util.StringUtils;
   10.17 +import org.jivesoftware.smackx.ChatState;
   10.18  import org.jivesoftware.smackx.ChatStateListener;
   10.19 -import org.jivesoftware.smackx.ChatState;
   10.20  
   10.21 +import android.os.Environment;
   10.22  import android.os.RemoteCallbackList;
   10.23  import android.os.RemoteException;
   10.24  import android.util.Log;
   10.25 @@ -74,6 +79,8 @@
   10.26      private final List<Message> mMessages;
   10.27      private final RemoteCallbackList<IMessageListener> mRemoteListeners = new RemoteCallbackList<IMessageListener>();
   10.28      private final MsgListener mMsgListener = new MsgListener();
   10.29 +    private boolean mIsHisory;
   10.30 +    private String mAccountUser;
   10.31  
   10.32      /**
   10.33       * Constructor.
   10.34 @@ -115,6 +122,8 @@
   10.35  	    // TODO Auto-generated catch block
   10.36  	    e.printStackTrace();
   10.37  	}
   10.38 +	//TODO replace me
   10.39 +	saveHistory(message, mAccountUser);
   10.40      }
   10.41  
   10.42      /**
   10.43 @@ -192,6 +201,69 @@
   10.44  	if (mMessages.size() == HISTORY_MAX_SIZE)
   10.45  	    mMessages.remove(0);
   10.46  	mMessages.add(msg);
   10.47 +	if (!"".equals(msg.getBody()) && msg.getBody() != null) {
   10.48 +	    saveHistory(msg, msg.getFrom());
   10.49 +	}
   10.50 +    }
   10.51 +
   10.52 +    /**
   10.53 +     * Save message in SDCard.
   10.54 +     * @param msg the message receive
   10.55 +     * @param contactName the name of the contact
   10.56 +     */
   10.57 +    public void saveHistory(Message msg, String contactName) {
   10.58 +    	String state = Environment.getExternalStorageState();
   10.59 +    	if (mIsHisory && Environment.MEDIA_MOUNTED.equals(state)) {
   10.60 +    	    File path = new File(Environment.getExternalStorageDirectory(), "beem");
   10.61 +    	    File filepath;
   10.62 +    	    if (msg.getFrom() == contactName)
   10.63 +    		filepath = new File(path, StringUtils.parseBareAddress(contactName));
   10.64 +    	    else
   10.65 +    		filepath = new File(path, StringUtils.parseBareAddress(msg.getTo()));
   10.66 +    	    path.mkdirs();
   10.67 +    	    try {
   10.68 +    	    	FileWriter file = new FileWriter(filepath, true);
   10.69 +    		String log = msg.getTimestamp() + " " + contactName + " " + msg.getBody()
   10.70 +    			+ System.getProperty("line.separator");
   10.71 +    		file.write(log);
   10.72 +    		file.close();
   10.73 +    		Log.i(TAG, log);
   10.74 +    	    } catch (IOException e) {
   10.75 +    	    	e.printStackTrace();
   10.76 +    	    }
   10.77 +    	}
   10.78 +    }
   10.79 +
   10.80 +    /**
   10.81 +     * set History state.
   10.82 +     * @param isHisory history state
   10.83 +     */
   10.84 +    public void setHisory(boolean isHisory) {
   10.85 +	this.mIsHisory = isHisory;
   10.86 +    }
   10.87 +
   10.88 +    /**
   10.89 +     * get History state.
   10.90 +     * @return mIsHistory
   10.91 +     */
   10.92 +    public boolean getHisory() {
   10.93 +	return mIsHisory;
   10.94 +    }
   10.95 +
   10.96 +    /**
   10.97 +     * Set Account user name.
   10.98 +     * @param accountUser user name
   10.99 +     */
  10.100 +    public void setAccountUser(String accountUser) {
  10.101 +	mAccountUser = accountUser;
  10.102 +    }
  10.103 +
  10.104 +    /**
  10.105 +     * get Account user name.
  10.106 +     * @return mAccountUser
  10.107 +     */
  10.108 +    public String getAccountUser() {
  10.109 +	return mAccountUser;
  10.110      }
  10.111  
  10.112      /**
  10.113 @@ -201,11 +273,12 @@
  10.114  	/**
  10.115  	 * Constructor.
  10.116  	 */
  10.117 -	public MsgListener() { }
  10.118 +	public MsgListener() {
  10.119 +	}
  10.120  
  10.121  	@Override
  10.122  	public void processMessage(Chat chat, org.jivesoftware.smack.packet.Message message) {
  10.123 -	    Message  msg = new Message(message);
  10.124 +	    Message msg = new Message(message);
  10.125  	    //TODO add que les message pas de type errors
  10.126  	    ChatAdapter.this.addMessage(msg);
  10.127  	    final int n = mRemoteListeners.beginBroadcast();
  10.128 @@ -241,4 +314,3 @@
  10.129  	}
  10.130      }
  10.131  }
  10.132 -
    11.1 --- a/src/com/beem/project/beem/service/Contact.java	Mon Jan 17 23:50:00 2011 +0100
    11.2 +++ b/src/com/beem/project/beem/service/Contact.java	Tue Jan 18 00:26:02 2011 +0100
    11.3 @@ -140,6 +140,28 @@
    11.4      }
    11.5  
    11.6      /**
    11.7 +     * Make an xmpp uri for a spcific jid.
    11.8 +     *
    11.9 +     * @param jid the jid to represent as an uri
   11.10 +     * @return an uri representing this jid.
   11.11 +     */
   11.12 +    public static Uri makeXmppUri(String jid) {
   11.13 +	StringBuilder build = new StringBuilder("xmpp:");
   11.14 +	String name = StringUtils.parseName(jid);
   11.15 +	build.append(name);
   11.16 +	if (!"".equals(name))
   11.17 +	    build.append('@');
   11.18 +	build.append(StringUtils.parseServer(jid));
   11.19 +	String resource = StringUtils.parseResource(jid);
   11.20 +	if (!"".equals(resource)) {
   11.21 +	    build.append('/');
   11.22 +	    build.append(resource);
   11.23 +	}
   11.24 +	Uri u = Uri.parse(build.toString());
   11.25 +	return u;
   11.26 +    }
   11.27 +
   11.28 +    /**
   11.29       * {@inheritDoc}
   11.30       */
   11.31      @Override
   11.32 @@ -387,14 +409,7 @@
   11.33       * @return the URI
   11.34       */
   11.35      public Uri toUri() {
   11.36 -	StringBuilder build = new StringBuilder("xmpp:");
   11.37 -	String name = StringUtils.parseName(mJID);
   11.38 -	build.append(name);
   11.39 -	if (!"".equals(name))
   11.40 -	    build.append('@');
   11.41 -	build.append(StringUtils.parseServer(mJID));
   11.42 -	Uri u = Uri.parse(build.toString());
   11.43 -	return u;
   11.44 +	return makeXmppUri(mJID);
   11.45      }
   11.46  
   11.47      /**
    12.1 --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Mon Jan 17 23:50:00 2011 +0100
    12.2 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Tue Jan 18 00:26:02 2011 +0100
    12.3 @@ -115,6 +115,7 @@
    12.4      private BeemApplication mApplication;
    12.5      private AvatarManager mAvatarManager;
    12.6      private PepSubManager mPepManager;
    12.7 +    private SharedPreferences mPref;
    12.8      private final RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners =
    12.9  	new RemoteCallbackList<IBeemConnectionListener>();
   12.10      private final SubscribePacketListener mSubscribePacketListener = new SubscribePacketListener();
   12.11 @@ -163,13 +164,13 @@
   12.12  	if (ctx instanceof BeemApplication) {
   12.13  	    mApplication = (BeemApplication) ctx;
   12.14  	}
   12.15 -	SharedPreferences pref = mService.getServicePreference();
   12.16 +	mPref = mService.getServicePreference();
   12.17  	try {
   12.18 -	    mPreviousPriority = Integer.parseInt(pref.getString("settings_key_priority", "0"));
   12.19 -	    mResource = pref.getString("settings_key_resource", "BEEM");
   12.20 +	    mPreviousPriority = Integer.parseInt(mPref.getString("settings_key_priority", "0"));
   12.21  	} catch (NumberFormatException ex) {
   12.22  	    mPreviousPriority = 0;
   12.23  	}
   12.24 +	mResource = mPref.getString("settings_key_resource", "BEEM");
   12.25      }
   12.26  
   12.27      /**
   12.28 @@ -237,14 +238,17 @@
   12.29  
   12.30  	    mAdaptee.login(mLogin, mPassword, mResource);
   12.31  	    mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService);
   12.32 -	    mPrivacyListManager = new PrivacyListManagerAdapter(PrivacyListManager.getInstanceFor(mAdaptee));
   12.33 -	    mService.resetStatus();
   12.34 +	    //nikita: I commented this line because of the logs provided in http://www.beem-project.com/issues/321
   12.35 +	    //Also, since the privacylistmanager isn't finished and used, it will be safer to not initialize it
   12.36 +	    //mPrivacyListManager = new PrivacyListManagerAdapter(PrivacyListManager.getInstanceFor(mAdaptee));
   12.37  	    mService.initJingle(mAdaptee);
   12.38  	    discoverServerFeatures();
   12.39  
   12.40  	    mRoster = new RosterAdapter(mAdaptee.getRoster(), mService, mAvatarManager);
   12.41  	    mApplication.setConnected(true);
   12.42 -	    changeStatus(Status.CONTACT_STATUS_AVAILABLE, mService.getServicePreference().getString("status_text", ""));
   12.43 +	    int mode = mPref.getInt(BeemApplication.STATUS_KEY, 0);
   12.44 +	    String status = mPref.getString(BeemApplication.STATUS_TEXT_KEY, "");
   12.45 +	    changeStatus(mode, status);
   12.46  	    return true;
   12.47  	} catch (XMPPException e) {
   12.48  	    Log.e(TAG, "Error while connecting", e);
   12.49 @@ -458,7 +462,7 @@
   12.50  	    sdm = new ServiceDiscoveryManager(mAdaptee);
   12.51  
   12.52  	sdm.addFeature("http://jabber.org/protocol/disco#info");
   12.53 -	sdm.addFeature("jabber:iq:privacy");
   12.54 +	//nikita: must be uncommented when the feature will be enabled
   12.55  	sdm.addFeature("urn:xmpp:jingle:1");
   12.56  	sdm.addFeature("urn:xmpp:jingle:apps:rtp:1");
   12.57  	sdm.addFeature("urn:xmpp:jingle:apps:rtp:audio");
   12.58 @@ -697,7 +701,7 @@
   12.59  		R.string.AcceptContactRequest, from), System.currentTimeMillis());
   12.60  	    notification.flags = Notification.FLAG_AUTO_CANCEL;
   12.61  	    Intent intent = new Intent(mService, Subscription.class);
   12.62 -	    intent.putExtra("from", from);
   12.63 +	    intent.setData(Contact.makeXmppUri(from));
   12.64  	    notification.setLatestEventInfo(mService, from, mService
   12.65  		.getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0,
   12.66  		    intent, PendingIntent.FLAG_ONE_SHOT));
    13.1 --- a/src/com/beem/project/beem/ui/ChangeStatus.java	Mon Jan 17 23:50:00 2011 +0100
    13.2 +++ b/src/com/beem/project/beem/ui/ChangeStatus.java	Tue Jan 18 00:26:02 2011 +0100
    13.3 @@ -55,7 +55,6 @@
    13.4  import android.os.IBinder;
    13.5  import android.os.RemoteException;
    13.6  import android.preference.PreferenceManager;
    13.7 -import android.util.Log;
    13.8  import android.view.View;
    13.9  import android.view.View.OnClickListener;
   13.10  import android.widget.ArrayAdapter;
   13.11 @@ -163,7 +162,6 @@
   13.12      @Override
   13.13      protected void onPause() {
   13.14  	super.onPause();
   13.15 -	Log.d("TAG", "pause");
   13.16  	unbindService(mServConn);
   13.17      }
   13.18  
    14.1 --- a/src/com/beem/project/beem/ui/Chat.java	Mon Jan 17 23:50:00 2011 +0100
    14.2 +++ b/src/com/beem/project/beem/ui/Chat.java	Tue Jan 18 00:26:02 2011 +0100
    14.3 @@ -50,6 +50,7 @@
    14.4  import java.util.List;
    14.5  import java.util.Map;
    14.6  
    14.7 +import org.jivesoftware.smack.packet.Presence.Mode;
    14.8  import org.jivesoftware.smack.util.StringUtils;
    14.9  
   14.10  import android.app.Activity;
   14.11 @@ -58,15 +59,17 @@
   14.12  import android.content.Intent;
   14.13  import android.content.IntentFilter;
   14.14  import android.content.ServiceConnection;
   14.15 +import android.content.SharedPreferences;
   14.16 +import android.graphics.drawable.Drawable;
   14.17 +import android.graphics.drawable.LayerDrawable;
   14.18  import android.graphics.Bitmap;
   14.19  import android.graphics.BitmapFactory;
   14.20  import android.graphics.Color;
   14.21 -import android.graphics.drawable.Drawable;
   14.22 -import android.graphics.drawable.LayerDrawable;
   14.23  import android.os.Bundle;
   14.24  import android.os.Handler;
   14.25  import android.os.IBinder;
   14.26  import android.os.RemoteException;
   14.27 +import android.preference.PreferenceManager;
   14.28  import android.text.util.Linkify;
   14.29  import android.util.Log;
   14.30  import android.view.KeyEvent;
   14.31 @@ -75,9 +78,9 @@
   14.32  import android.view.MenuInflater;
   14.33  import android.view.MenuItem;
   14.34  import android.view.View;
   14.35 +import android.view.ViewGroup;
   14.36  import android.view.View.OnClickListener;
   14.37  import android.view.View.OnKeyListener;
   14.38 -import android.view.ViewGroup;
   14.39  import android.widget.BaseAdapter;
   14.40  import android.widget.Button;
   14.41  import android.widget.EditText;
   14.42 @@ -122,10 +125,10 @@
   14.43      private TextView mContactStatusMsgTextView;
   14.44      private TextView mContactChatState;
   14.45      private ImageView mContactStatusIcon;
   14.46 +    private LayerDrawable mAvatarStatusDrawable;
   14.47      private ListView mMessagesListView;
   14.48      private EditText mInputField;
   14.49      private Button mSendButton;
   14.50 -    private LayerDrawable mAvatarStatusDrawable;
   14.51      private final Map<Integer, Bitmap> mStatusIconsMap = new HashMap<Integer, Bitmap>();
   14.52  
   14.53      private final List<MessageText> mListMessages = new ArrayList<MessageText>();
   14.54 @@ -141,6 +144,7 @@
   14.55      private final BeemRosterListener mBeemRosterListener = new BeemRosterListener();
   14.56      private IXmppFacade mXmppFacade;
   14.57      private boolean mBinded;
   14.58 +    private boolean mCompact;
   14.59  
   14.60      /**
   14.61       * Constructor.
   14.62 @@ -155,16 +159,21 @@
   14.63      @Override
   14.64      protected void onCreate(Bundle savedBundle) {
   14.65  	super.onCreate(savedBundle);
   14.66 -	setContentView(R.layout.chat);
   14.67  	this.registerReceiver(mBroadcastReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
   14.68 -
   14.69 +	SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
   14.70 +	mCompact = settings.getBoolean("settings_chat_compact_key", false);
   14.71  	// UI
   14.72 -	mContactNameTextView = (TextView) findViewById(R.id.chat_contact_name);
   14.73 -	mContactStatusMsgTextView = (TextView) findViewById(R.id.chat_contact_status_msg);
   14.74 -	mContactChatState = (TextView) findViewById(R.id.chat_contact_chat_state);
   14.75 -	mContactStatusIcon = (ImageView) findViewById(R.id.chat_contact_status_icon);
   14.76 -	mAvatarStatusDrawable = (LayerDrawable) mContactStatusIcon.getDrawable();
   14.77 -	mAvatarStatusDrawable.setLayerInset(1, 36, 36, 0, 0);
   14.78 +	if (!mCompact) {
   14.79 +	    setContentView(R.layout.chat);
   14.80 +	    mContactNameTextView = (TextView) findViewById(R.id.chat_contact_name);
   14.81 +	    mContactStatusMsgTextView = (TextView) findViewById(R.id.chat_contact_status_msg);
   14.82 +	    mContactChatState = (TextView) findViewById(R.id.chat_contact_chat_state);
   14.83 +	    mContactStatusIcon = (ImageView) findViewById(R.id.chat_contact_status_icon);
   14.84 +	    mAvatarStatusDrawable = (LayerDrawable) mContactStatusIcon.getDrawable();
   14.85 +	    mAvatarStatusDrawable.setLayerInset(1, 36, 36, 0, 0);
   14.86 +	} else {
   14.87 +	    setContentView(R.layout.chat_compact);
   14.88 +	}
   14.89  	mMessagesListView = (ListView) findViewById(R.id.chat_messages);
   14.90  	mMessagesListView.setAdapter(mMessagesListAdapter);
   14.91  	mInputField = (EditText) findViewById(R.id.chat_input);
   14.92 @@ -177,7 +186,6 @@
   14.93  		sendMessage();
   14.94  	    }
   14.95  	});
   14.96 -
   14.97  	prepareIconsStatus();
   14.98      }
   14.99  
  14.100 @@ -498,7 +506,8 @@
  14.101  		    @Override
  14.102  		    public void run() {
  14.103  			if (msg.getType() == Message.MSG_TYPE_ERROR) {
  14.104 -			    mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), true, msg.getTimestamp()));
  14.105 +			    mListMessages.add(new MessageText(fromBareJid, mContact.getName(),
  14.106 +				msg.getBody(), true, msg.getTimestamp()));
  14.107  			    mMessagesListAdapter.notifyDataSetChanged();
  14.108  			} else if (msg.getBody() != null) {
  14.109  			    MessageText lastMessage = null;
  14.110 @@ -510,7 +519,8 @@
  14.111  				lastMessage.setTimestamp(msg.getTimestamp());
  14.112  				mListMessages.set(mListMessages.size() - 1, lastMessage);
  14.113  			    } else if (msg.getBody() != null)
  14.114 -				mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), false, msg.getTimestamp()));
  14.115 +				mListMessages.add(new MessageText(fromBareJid, mContact.getName(),
  14.116 +				    msg.getBody(), false, msg.getTimestamp()));
  14.117  			    mMessagesListAdapter.notifyDataSetChanged();
  14.118  			}
  14.119  		    }
  14.120 @@ -539,7 +549,8 @@
  14.121  		    } else if ("paused".equals(state)) {
  14.122  			text = Chat.this.getString(R.string.chat_state_active);
  14.123  		    }
  14.124 -		    mContactChatState.setText(text);
  14.125 +		    if (!mCompact)
  14.126 +			mContactChatState.setText(text);
  14.127  		}
  14.128  	    });
  14.129  
  14.130 @@ -555,20 +566,28 @@
  14.131  	String res = mContact.getSelectedRes();
  14.132  	if (!"".equals(res))
  14.133  	    name += "(" + res + ")";
  14.134 -	if (!(mContactNameTextView.getText().toString().equals(name)))
  14.135 -	    mContactNameTextView.setText(name);
  14.136 -
  14.137 -	// Check for a contact status message update
  14.138 -	if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
  14.139 -	    mContactStatusMsgTextView.setText(mContact.getMsgState());
  14.140 -	    Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
  14.141 +	if (!mCompact) {
  14.142 +	    if (!(mContactNameTextView.getText().toString().equals(name)))
  14.143 +		mContactNameTextView.setText(name);
  14.144 +	    //Check for a contact status message update
  14.145 +	    if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
  14.146 +		mContactStatusMsgTextView.setText(mContact.getMsgState());
  14.147 +		Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
  14.148 +	    }
  14.149 +	} else {
  14.150 +	    Mode m = Status.getPresenceModeFromStatus(mContact.getStatus());
  14.151 +	    setTitle(getString(R.string.chat_name) + " " + mContact.getName() + " (" + m.name() + ")");
  14.152  	}
  14.153      }
  14.154  
  14.155 +
  14.156 +
  14.157      /**
  14.158       * Update the contact status icon.
  14.159       */
  14.160      private void updateContactStatusIcon() {
  14.161 +	if (mCompact)
  14.162 +	    return;
  14.163  	Drawable avatar = getAvatarDrawable(mContact.getAvatarId());
  14.164  	mAvatarStatusDrawable.setDrawableByLayerId(R.id.avatar, avatar);
  14.165  	mContactStatusIcon.setImageLevel(mContact.getStatus());
  14.166 @@ -594,7 +613,7 @@
  14.167  	if (avatarDrawable == null)
  14.168  	    avatarDrawable = getResources().getDrawable(R.drawable.beem_launcher_icon_silver);
  14.169  	return avatarDrawable;
  14.170 -    }
  14.171 +     }
  14.172  
  14.173      /**
  14.174       * Prepare the status icons map.
  14.175 @@ -665,26 +684,35 @@
  14.176  	    View sv;
  14.177  	    if (convertView == null) {
  14.178  		LayoutInflater inflater = Chat.this.getLayoutInflater();
  14.179 -		sv = inflater.inflate(R.layout.chat_msg_row, null);
  14.180 +		if (!mCompact)
  14.181 +		    sv = inflater.inflate(R.layout.chat_msg_row, null);
  14.182 +		else
  14.183 +		    sv = inflater.inflate(R.layout.chat_msg_row_compact, null);
  14.184  	    } else {
  14.185  		sv = convertView;
  14.186  	    }
  14.187 +	    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
  14.188  	    MessageText msg = mListMessages.get(position);
  14.189 -	    TextView msgName = (TextView) sv.findViewById(R.id.chatmessagename);
  14.190 -	    msgName.setText(msg.getName());
  14.191 -	    msgName.setTextColor(Color.WHITE);
  14.192 -	    msgName.setError(null);
  14.193 -	    TextView msgText = (TextView) sv.findViewById(R.id.chatmessagetext);
  14.194 -	    msgText.setText(msg.getMessage());
  14.195 -	    TextView msgDate = (TextView) sv.findViewById(R.id.chatmessagedate);
  14.196 -	    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
  14.197 -	    String date = df.format(msg.getTimestamp());
  14.198 -	    msgDate.setText(date);
  14.199 -	    if (msg.isError()) {
  14.200 -		String err = getString(R.string.chat_error);
  14.201 -		msgName.setText(err);
  14.202 -		msgName.setTextColor(Color.RED);
  14.203 -		msgName.setError(err);
  14.204 +	    if (!mCompact) {
  14.205 +		TextView msgName = (TextView) sv.findViewById(R.id.chatmessagename);
  14.206 +		msgName.setText(msg.getName());
  14.207 +		msgName.setTextColor(Color.WHITE);
  14.208 +		msgName.setError(null);
  14.209 +		TextView msgText = (TextView) sv.findViewById(R.id.chatmessagetext);
  14.210 +		msgText.setText(msg.getMessage());
  14.211 +		TextView msgDate = (TextView) sv.findViewById(R.id.chatmessagedate);
  14.212 +		String date = df.format(msg.getTimestamp());
  14.213 +		msgDate.setText(date);
  14.214 +		if (msg.isError()) {
  14.215 +		    String err = getString(R.string.chat_error);
  14.216 +		    msgName.setText(err);
  14.217 +		    msgName.setTextColor(Color.RED);
  14.218 +		    msgName.setError(err);
  14.219 +		}
  14.220 +	    } else {
  14.221 +		String str = "(" + df.format(msg.getTimestamp()) + ") " + msg.getName() + " : " + msg.getMessage();
  14.222 +		TextView msgText = (TextView) sv.findViewById(R.id.chatmessagetext);
  14.223 +		msgText.setText(str);
  14.224  	    }
  14.225  	    return sv;
  14.226  	}
  14.227 @@ -721,7 +749,8 @@
  14.228  	 * @param message A String containing the message.
  14.229  	 * @param isError if the message is an error message.
  14.230  	 */
  14.231 -	public MessageText(final String bareJid, final String name, final String message, final boolean isError) {
  14.232 +	public MessageText(final String bareJid, final String name, final String message,
  14.233 +	    final boolean isError) {
  14.234  	    mBareJid = bareJid;
  14.235  	    mName = name;
  14.236  	    mMessage = message;
  14.237 @@ -736,7 +765,8 @@
  14.238  	 * @param isError if the message is an error message.
  14.239  	 * @param date the time of the message.
  14.240  	 */
  14.241 -	public MessageText(final String bareJid, final String name, final String message, final boolean isError, Date date) {
  14.242 +	public MessageText(final String bareJid, final String name, final String message,
  14.243 +	    final boolean isError, Date date) {
  14.244  	    mBareJid = bareJid;
  14.245  	    mName = name;
  14.246  	    mMessage = message;
  14.247 @@ -804,7 +834,6 @@
  14.248  
  14.249  	/**
  14.250  	 * Set the Date of the message.
  14.251 -	 *
  14.252  	 * @param date date of the message.
  14.253  	 */
  14.254  	public void setTimestamp(Date date) {
  14.255 @@ -813,7 +842,6 @@
  14.256  
  14.257  	/**
  14.258  	 * Get the Date of the message.
  14.259 -	 *
  14.260  	 * @return if it is a delayed message get the date the message was sended.
  14.261  	 */
  14.262  	public Date getTimestamp() {
    15.1 --- a/src/com/beem/project/beem/ui/ContactList.java	Mon Jan 17 23:50:00 2011 +0100
    15.2 +++ b/src/com/beem/project/beem/ui/ContactList.java	Tue Jan 18 00:26:02 2011 +0100
    15.3 @@ -683,10 +683,12 @@
    15.4  		 private Drawable getAvatarStatusDrawable(String avatarId) {
    15.5  			 Drawable avatarDrawable = null;
    15.6  			 try {
    15.7 -				 byte[] avatar = mXmppFacade.getAvatar(avatarId);
    15.8 -				 if (avatar != null) {
    15.9 -					 ByteArrayInputStream in = new ByteArrayInputStream(avatar);
   15.10 -					 avatarDrawable = Drawable.createFromStream(in, avatarId);
   15.11 +		if (mXmppFacade != null) {
   15.12 +		    byte[] avatar = mXmppFacade.getAvatar(avatarId);
   15.13 +		    if (avatar != null) {
   15.14 +			ByteArrayInputStream in = new ByteArrayInputStream(avatar);
   15.15 +			avatarDrawable = Drawable.createFromStream(in, avatarId);
   15.16 +		    }
   15.17  				 }
   15.18  			 } catch (RemoteException e) {
   15.19  				 Log.e(TAG, "Error while setting the avatar", e);
    16.1 --- a/src/com/beem/project/beem/ui/Settings.java	Mon Jan 17 23:50:00 2011 +0100
    16.2 +++ b/src/com/beem/project/beem/ui/Settings.java	Tue Jan 18 00:26:02 2011 +0100
    16.3 @@ -46,6 +46,8 @@
    16.4  import android.content.ComponentName;
    16.5  import android.content.Intent;
    16.6  import android.os.Bundle;
    16.7 +import android.os.Environment;
    16.8 +import android.preference.CheckBoxPreference;
    16.9  import android.preference.PreferenceActivity;
   16.10  import android.view.Menu;
   16.11  import android.view.MenuInflater;
   16.12 @@ -74,6 +76,15 @@
   16.13      public void onCreate(Bundle savedInstanceState) {
   16.14  	super.onCreate(savedInstanceState);
   16.15  	addPreferencesFromResource(R.layout.preferences);
   16.16 +	CheckBoxPreference history = (CheckBoxPreference) findPreference("settings_key_history");
   16.17 +	String state = Environment.getExternalStorageState();
   16.18 +	if (!Environment.MEDIA_MOUNTED.equals(state)) {
   16.19 +	    history.setSelectable(false);
   16.20 +	    history.setSummary(R.string.history_mount);
   16.21 +	} else {
   16.22 +	    history.setSelectable(true);
   16.23 +	    history.setSummary(R.string.history_on_off);
   16.24 +	}
   16.25      }
   16.26  
   16.27      /**
    17.1 --- a/src/com/beem/project/beem/ui/Subscription.java	Mon Jan 17 23:50:00 2011 +0100
    17.2 +++ b/src/com/beem/project/beem/ui/Subscription.java	Tue Jan 18 00:26:02 2011 +0100
    17.3 @@ -54,6 +54,7 @@
    17.4  import android.os.Bundle;
    17.5  import android.os.IBinder;
    17.6  import android.os.RemoteException;
    17.7 +import android.util.Log;
    17.8  import android.view.View;
    17.9  import android.view.View.OnClickListener;
   17.10  import android.widget.TextView;
   17.11 @@ -63,6 +64,7 @@
   17.12  import com.beem.project.beem.R;
   17.13  import com.beem.project.beem.service.PresenceAdapter;
   17.14  import com.beem.project.beem.service.aidl.IXmppFacade;
   17.15 +import com.beem.project.beem.service.Contact;
   17.16  import com.beem.project.beem.utils.BeemBroadcastReceiver;
   17.17  
   17.18  /**
   17.19 @@ -72,6 +74,7 @@
   17.20  public class Subscription extends Activity {
   17.21  
   17.22      private static final Intent SERVICE_INTENT = new Intent();
   17.23 +    private static final String TAG = Subscription.class.getSimpleName();
   17.24      private IXmppFacade mService;
   17.25      private String mContact;
   17.26      private ServiceConnection mServConn = new BeemServiceConnection();
   17.27 @@ -97,7 +100,8 @@
   17.28  	setContentView(R.layout.subscription);
   17.29  	findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener);
   17.30  	findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener);
   17.31 -	mContact = getIntent().getStringExtra("from");
   17.32 +	Contact c = new Contact(getIntent().getData());
   17.33 +	mContact = c.getJID();
   17.34  	TextView tv = (TextView) findViewById(R.id.SubscriptionText);
   17.35  	String str = String.format(getString(R.string.SubscriptText), mContact);
   17.36  	tv.setText(str);
   17.37 @@ -132,6 +136,20 @@
   17.38      }
   17.39  
   17.40      /**
   17.41 +     * Send the presence stanza.
   17.42 +     *
   17.43 +     * @param p presence stanza
   17.44 +     */
   17.45 +    private void sendPresence(Presence p) {
   17.46 +	PresenceAdapter preAdapt = new PresenceAdapter(p);
   17.47 +	try {
   17.48 +	    mService.sendPresencePacket(preAdapt);
   17.49 +	} catch (RemoteException e) {
   17.50 +	    Log.e(TAG, "Error while sending subscription response", e);
   17.51 +	}
   17.52 +    }
   17.53 +
   17.54 +    /**
   17.55       * Event simple click on buttons.
   17.56       */
   17.57      private class MyOnClickListener implements OnClickListener {
   17.58 @@ -144,29 +162,25 @@
   17.59  
   17.60  	@Override
   17.61  	public void onClick(View v) {
   17.62 +	    Presence presence = null;
   17.63  	    switch (v.getId()) {
   17.64  		case R.id.SubscriptionAccept:
   17.65 -		    Presence presence = new Presence(Type.subscribed);
   17.66 -		    presence.setTo(mContact);
   17.67 -		    PresenceAdapter preAdapt = new PresenceAdapter(presence);
   17.68 -		    try {
   17.69 -			mService.sendPresencePacket(preAdapt);
   17.70 -			Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), Toast.LENGTH_SHORT)
   17.71 +		    presence = new Presence(Type.subscribed);
   17.72 +		    Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), Toast.LENGTH_SHORT)
   17.73  			    .show();
   17.74 -			finish();
   17.75 -		    } catch (RemoteException e) {
   17.76 -			Toast.makeText(Subscription.this, getString(R.string.SubscriptError), Toast.LENGTH_SHORT)
   17.77 -			    .show();
   17.78 -			e.printStackTrace();
   17.79 -		    }
   17.80  		    break;
   17.81  		case R.id.SubscriptionRefuse:
   17.82 +		    presence = new Presence(Type.unsubscribed);
   17.83  		    Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused), Toast.LENGTH_SHORT).show();
   17.84 -		    finish();
   17.85  		    break;
   17.86  		default:
   17.87  		    Toast.makeText(Subscription.this, getString(R.string.SubscriptError), Toast.LENGTH_SHORT).show();
   17.88  	    }
   17.89 +	    if (presence != null) {
   17.90 +		presence.setTo(mContact);
   17.91 +		sendPresence(presence);
   17.92 +	    }
   17.93 +	    finish();
   17.94  	}
   17.95      };
   17.96