Merge
authorDa Risk <darisk972@gmail.com>
Tue, 22 Dec 2009 15:56:54 +0100
changeset 598 8d54817f081f
parent 597 aa75a44fdffe (current diff)
parent 595 cb584be7932a (diff)
child 599 cdadf4e39f99
Merge
--- a/res/layout/contactlist.xml	Tue Dec 22 15:56:03 2009 +0100
+++ b/res/layout/contactlist.xml	Tue Dec 22 15:56:54 2009 +0100
@@ -11,8 +11,10 @@
 	<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" />
+		<ListView android:id="@+id/contactlist"
+		    android:layout_width="fill_parent" android:layout_height="fill_parent"
+		    android:transcriptMode="alwaysScroll" />
+		<!-- normal should be better -->
 	</LinearLayout>
 
 </LinearLayout>
--- a/src/com/beem/project/beem/BeemService.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/BeemService.java	Tue Dec 22 15:56:54 2009 +0100
@@ -107,6 +107,7 @@
 
     private static final String TAG = "BeemService";
     private static final int DEFAULT_XMPP_PORT = 5222;
+    private static final String COMMAND_NAMESPACE = "http://jabber.org/protocol/commands";
 
     private NotificationManager mNotificationManager;
     private XmppConnectionAdapter mConnection;
@@ -343,6 +344,7 @@
 	    pm.addIQProvider("query", "jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version"));
 	} catch (ClassNotFoundException e) {
 	    // Not sure what's happening here.
+	    Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Version");
 	}
 	// VCard
 	pm.addIQProvider("vCard", "vcard-temp", new VCardProvider());
@@ -367,16 +369,17 @@
 	pm.addExtensionProvider("data", "http://jabber.org/protocol/ibb", new IBBProviders.Data());
 	// Privacy
 	pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
-	pm.addIQProvider("command", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider());
-	pm.addExtensionProvider("malformed-action", "http://jabber.org/protocol/commands",
+	pm.addIQProvider("command", COMMAND_NAMESPACE, new AdHocCommandDataProvider());
+	pm.addExtensionProvider("malformed-action", COMMAND_NAMESPACE,
 	    new AdHocCommandDataProvider.MalformedActionError());
-	pm.addExtensionProvider("bad-locale", "http://jabber.org/protocol/commands",
+	pm.addExtensionProvider("bad-locale", COMMAND_NAMESPACE,
 	    new AdHocCommandDataProvider.BadLocaleError());
-	pm.addExtensionProvider("bad-payload", "http://jabber.org/protocol/commands",
+	pm.addExtensionProvider("bad-payload", COMMAND_NAMESPACE,
 	    new AdHocCommandDataProvider.BadPayloadError());
-	pm.addExtensionProvider("bad-sessionid", "http://jabber.org/protocol/commands",
+	pm.addExtensionProvider("bad-sessionid", COMMAND_NAMESPACE,
 	    new AdHocCommandDataProvider.BadSessionIDError());
-	pm.addExtensionProvider("session-expired", "http://jabber.org/protocol/commands",
+	pm.addExtensionProvider("session-expired", COMMAND_NAMESPACE,
 	    new AdHocCommandDataProvider.SessionExpiredError());
     }
 }
+
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Tue Dec 22 15:56:54 2009 +0100
@@ -141,7 +141,7 @@
 		notification.flags = Notification.FLAG_AUTO_CANCEL;
 		notification.setLatestEventInfo(mService, tickerText, mService
 			.getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat));
-		mService.sendNotification(chat.hashCode(), notification);
+		mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification);
 	    } catch (RemoteException e) {
 		Log.e(TAG, e.getMessage());
 	    }
@@ -154,6 +154,8 @@
 	public void processMessage(IChat chat, Message message) {
 	    try {
 		if (!chat.isOpen() && message.getBody() != null) {
+		    if (chat instanceof ChatAdapter)
+			mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat);
 		    notifyNewChat(chat);
 		}
 	    } catch (RemoteException e) {
@@ -214,6 +216,7 @@
     public IChat createChat(String jid, IMessageListener listener) {
 	String key = StringUtils.parseBareAddress(jid);
 	ChatAdapter result;
+	Log.d(TAG, "Get chat key = "+key);
 	if (mChats.containsKey(key)) {
 	    result = mChats.get(key);
 	    result.addMessageListener(listener);
@@ -231,6 +234,9 @@
      */
     @Override
     public void destroyChat(IChat chat) throws RemoteException {
+	// Can't remove it. otherwise we will lose all futur message in this chat
+	// chat.removeMessageListener(mChatListener);
+	deleteChatNotification(chat);
 	mChats.remove(chat.getParticipant().getJID());
     }
 
@@ -239,7 +245,11 @@
      */
     @Override
     public void deleteChatNotification(IChat chat) {
-	mService.deleteNotification(chat.hashCode());
+	try {
+	    mService.deleteNotification(chat.getParticipant().getJID().hashCode());
+	} catch (RemoteException e) {
+	    Log.v(TAG, "Remote exception ", e);
+	}
     }
 
     /**
--- a/src/com/beem/project/beem/ui/Chat.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java	Tue Dec 22 15:56:54 2009 +0100
@@ -363,6 +363,7 @@
 	String fromName = null;
 	List<Message> chatMessages = mChat.getMessages();
 	mListMessages.clear();
+	mMessagesListAdapter.notifyDataSetChanged();
 	MessageText lastMessage = null;
 
 	for (Message m : chatMessages) {
--- a/src/com/beem/project/beem/ui/CreateAccount.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/ui/CreateAccount.java	Tue Dec 22 15:56:54 2009 +0100
@@ -139,7 +139,7 @@
      */
     private void createErrorDialog(String errMsg) {
 	AlertDialog.Builder builder = new AlertDialog.Builder(this);
-	builder.setTitle(R.string.create_account_err_dialog_title).setMessage(errMsg).setCancelable(false);
+	builder.setTitle(R.string.create_account_err_dialog_title).setMessage(errMsg).setCancelable(false).setIcon(android.R.drawable.ic_dialog_alert);
 	builder.setNeutralButton(R.string.create_account_close_dialog_button, new DialogInterface.OnClickListener() {
 
 	    @Override
@@ -193,20 +193,17 @@
      * @return Registered proxy type
      */
     private ProxyInfo.ProxyType getRegisteredProxyType() {
-	ProxyInfo.ProxyType result;
-	switch (mSettings.getInt("settings_key_proxy_type", DEFAULT_INT_VALUE)) {
-	    case 0:
+	ProxyInfo.ProxyType result = ProxyInfo.ProxyType.NONE;
+	if (mSettings.getBoolean("settings_key_proxy_use", false)) {
+	    String type = mSettings.getString("settings_key_proxy_type", "none");
+	    if ("HTTP".equals(type))
 		result = ProxyInfo.ProxyType.HTTP;
-		break;
-	    case 1:
+	    else if ("SOCKS4".equals(type))
 		result = ProxyInfo.ProxyType.SOCKS4;
-		break;
-	    case 2:
+	    else if ("SOCKS5".equals(type))
 		result = ProxyInfo.ProxyType.SOCKS5;
-		break;
-	    default:
+	    else
 		result = ProxyInfo.ProxyType.NONE;
-		break;
 	}
 	return result;
     }
@@ -269,7 +266,7 @@
 	final String passwordConfirmFielddValue = ((EditText) findViewById(R.id.create_account_confirm_password))
 	    .getText().toString();
 
-	return passwordFieldValue.equals(passwordConfirmFielddValue) && !passwordConfirmFielddValue.equals("");
+	return passwordFieldValue.equals(passwordConfirmFielddValue) && !"".equals(passwordConfirmFielddValue);
     }
 
     /**
--- a/src/com/beem/project/beem/utils/BeemConnectivity.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/utils/BeemConnectivity.java	Tue Dec 22 15:56:54 2009 +0100
@@ -51,18 +51,22 @@
 import android.net.wifi.WifiManager;
 import android.telephony.TelephonyManager;
 
-// TODO: Auto-generated Javadoc
 /**
  * The Class BeemConnectivity.
  */
-public class BeemConnectivity {
-    
+public final class BeemConnectivity {
+
+    /**
+     * Private constructor to forbid instantiation.
+     */
+    private BeemConnectivity() { }
+
     /**
      * Checks if is connected.
      * @param ctx the ctx
      * @return true, if is connected
      */
-    static public boolean isConnected(Context ctx) {
+    public static boolean isConnected(Context ctx) {
 	ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
 	NetworkInfo ni = cm.getActiveNetworkInfo();
 	return ni != null && ni.isConnected();
--- a/src/com/beem/project/beem/utils/FreePort.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/utils/FreePort.java	Tue Dec 22 15:56:54 2009 +0100
@@ -46,7 +46,6 @@
 import java.io.IOException;
 import java.net.ServerSocket;
 
-// TODO: Auto-generated Javadoc
 /**
  * Utility class to get a free port.
  * @author nikita
--- a/src/com/beem/project/beem/utils/PresenceType.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/utils/PresenceType.java	Tue Dec 22 15:56:54 2009 +0100
@@ -45,7 +45,6 @@
 
 import org.jivesoftware.smack.packet.Presence;
 
-// TODO: Auto-generated Javadoc
 /**
  * Utility class to deal with Presence type.
  * @author nikita
--- a/src/com/beem/project/beem/utils/Status.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/utils/Status.java	Tue Dec 22 15:56:54 2009 +0100
@@ -46,7 +46,6 @@
 import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smack.packet.Presence.Mode;
 
-// TODO: Auto-generated Javadoc
 /**
  * Utility class to deal with status and presence value.
  * @author marseille
@@ -151,7 +150,7 @@
      * @return is obline
      */
     public static boolean statusOnline(int status) {
-	return (status != Status.CONTACT_STATUS_DISCONNECT && status != Status.CONTACT_STATUS_UNAVAILABLE);
+	return status != Status.CONTACT_STATUS_DISCONNECT && status != Status.CONTACT_STATUS_UNAVAILABLE;
     }
 
 }
--- a/src/com/beem/project/beem/utils/package-info.java	Tue Dec 22 15:56:03 2009 +0100
+++ b/src/com/beem/project/beem/utils/package-info.java	Tue Dec 22 15:56:54 2009 +0100
@@ -41,5 +41,8 @@
     Head of the EIP Laboratory.
 
 */
+/**
+ * This package contains utility class to deal with various aspect of BEEM.
+ */
 package com.beem.project.beem.utils;