merge with ui
authorDa Risk <darisk972@gmail.com>
Wed, 15 Apr 2009 19:41:35 +0200
changeset 108 c60aa2237865
parent 107 71ad42062140 (current diff)
parent 104 b31649abe731 (diff)
child 109 ec30f9790f83
merge with ui
res/layout/messagelist.xml
src/com/beem/project/beem/BeemApplication.java
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/ui/ContactList.java
Binary file res/drawable/boot_robot.png has changed
--- a/res/layout/messagelist.xml	Thu Apr 16 00:33:00 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TextView xmlns:android="http://schemas.android.com/apk/res/android" id="text1"
-          android:textSize="2mm"
-          android:singleLine="false"
-          android:layout_width="fill_parent"
-          android:layout_height="wrap_content"/>
\ No newline at end of file
--- a/res/layout/sendim.xml	Thu Apr 16 00:33:00 2009 +0200
+++ b/res/layout/sendim.xml	Wed Apr 15 19:41:35 2009 +0200
@@ -3,17 +3,47 @@
     android:orientation="vertical"
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent">
-
-    <ListView android:id="@android:id/list"
-        android:layout_width="fill_parent" 
-        android:layout_height="fill_parent"
-        android:layout_weight="1"
-        android:transcriptMode="alwaysScroll"/>
+    
+    <RelativeLayout
+    	android:paddingLeft="10px"
+    	android:paddingRight="10px"
+    	android:paddingTop="10px"
+    	android:background="@color/blue_sky"
+    	android:orientation="horizontal"
+		android:layout_width="fill_parent"
+		android:layout_height="wrap_content">
+		
+    	<ImageView android:id="@+id/sendimavatar"
+    		android:layout_width="wrap_content"
+    		android:layout_height="wrap_content"
+			android:src="@drawable/avatar"/>
+        
+        <TextView android:id="@+id/sendimlogin"
+        	android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:layout_alignTop="@id/sendimavatar"
+			android:layout_toRightOf="@id/sendimavatar"
+        	android:hint="@string/SendIMLoginHint"/>
+    </RelativeLayout>
+	<ScrollView
+		android:id="@+id/sendimscroll"
+		android:layout_width="fill_parent"
+		android:layout_height="fill_parent"
+		android:layout_weight="1">
+		
+		<TextView android:id="@+id/sendimlist"
+        	android:layout_width="fill_parent"
+        	android:layout_height="wrap_content"
+        	android:singleLine="false"/>
+        	<!--android:choiceMode="none"
+        	android:transcriptMode="alwaysScroll"-->
+        	
+    </ScrollView>
         
     <EditText android:id="@+id/userText"
         android:layout_width="fill_parent"
         android:cursorVisible="false"
-        android:hint="@string/SendIMHint"
+        android:hint="@string/SendIMToSendHint"
         android:layout_height="wrap_content" />
         
 </LinearLayout>
\ No newline at end of file
--- a/res/menu/contactlistmenu.xml	Thu Apr 16 00:33:00 2009 +0200
+++ b/res/menu/contactlistmenu.xml	Wed Apr 15 19:41:35 2009 +0200
@@ -1,4 +1,4 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
-	<item android:title="Creer ou Editer un compte" android:id="@+id/account_edit"/>
+	<item android:title="Creer ou Editer un compte" android:id="@+id/account_edit" android:icon="@drawable/xmpp"/>
 	<item android:title="L'equipe Beem" android:id="@+id/account_about"/>
 </menu>
--- a/res/values/colors.xml	Thu Apr 16 00:33:00 2009 +0200
+++ b/res/values/colors.xml	Wed Apr 15 19:41:35 2009 +0200
@@ -2,4 +2,5 @@
 <resources>
 	<color name="blue_sky">#A0C8FF</color>
 	<color name="black">#000000</color>
+<color name="white">#FFFFFF</color>
 </resources>
\ No newline at end of file
--- a/res/values/strings.xml	Thu Apr 16 00:33:00 2009 +0200
+++ b/res/values/strings.xml	Wed Apr 15 19:41:35 2009 +0200
@@ -29,9 +29,11 @@
 
 	<!--  SendIM class -->
 	<string name="SendIMSays"> says :\n</string>
-	<string name="SendIMHint">Tip text here</string>
+	<string name="SendIMToSendHint">Tip text here</string>
 	<string name="SendIMState">Is : </string>
 	<string name="SendIMFrom">and is speaking from : </string>
 	<string name="SendIMSmiley">Insert a smiley</string>
+	<string name="SendIMLoginHint">login</string>
+	<string name="SendIMNoStatusSet">No status set</string>
 
 </resources>
--- a/res/values/style.xml	Thu Apr 16 00:33:00 2009 +0200
+++ b/res/values/style.xml	Wed Apr 15 19:41:35 2009 +0200
@@ -3,10 +3,21 @@
   <style name="customtheme" parent="android:Theme">
  </style>
  
-  	<style name="customtheme.login"> 
+  	<style name="customtheme.contactList"> 
     <item name="android:windowBackground">@drawable/background</item>
     <item name="android:windowNoTitle">true</item>
+    <item name="android:textColor">#FFFF00</item>
+    <item name="android:typeface">sans</item>
+    <item name="android:textSize">18sp</item>
 
- 
-  </style>        
+  </style>
+  
+  	<style name="customtheme.jungle">
+  	<item name="android:windowBackground">@drawable/background</item>
+    <item name="android:windowNoTitle">true</item>
+    <item name="android:textColor">#FFFF00</item>
+    <item name="android:typeface">sans</item>
+    <item name="android:textSize">18sp</item>
+    </style>
+  	
 </resources>
\ No newline at end of file
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Apr 16 00:33:00 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Wed Apr 15 19:41:35 2009 +0200
@@ -61,6 +61,7 @@
     @Override
     protected void onCreate(Bundle saveBundle) {
 	super.onCreate(saveBundle);
+	setTheme(R.style.customtheme_contactList);
 	mHandler = new Handler();
 	mBeemApplication = BeemApplication.getApplication(this);
 	mSettings = getSharedPreferences(
--- a/src/com/beem/project/beem/ui/SendIM.java	Thu Apr 16 00:33:00 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Wed Apr 15 19:41:35 2009 +0200
@@ -2,12 +2,13 @@
 
 import java.util.ArrayList;
 
-import android.app.ListActivity;
+import android.app.Activity;
 import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.RemoteException;
+import android.text.method.ScrollingMovementMethod;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
@@ -16,8 +17,9 @@
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.View.OnKeyListener;
-import android.widget.ArrayAdapter;
 import android.widget.EditText;
+import android.widget.ScrollView;
+import android.widget.TextView;
 
 import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.R;
@@ -30,15 +32,15 @@
 import com.beem.project.beem.service.aidl.IXmppFacade;
 
 /**
- * @author barbu This activity class provide the view for instant messaging
+ * @author barbu This activity class provides the view for instant messaging
  *         after selecting a correspondant.
  */
 
-public class SendIM extends ListActivity implements OnClickListener,
+public class SendIM extends Activity implements OnClickListener,
 	OnKeyListener {
     private EditText mToSend;
     private ArrayList<String> mMessages = new ArrayList<String>();
-    private ArrayAdapter<String> mAdapter;
+    //private ArrayAdapter<String> mAdapter;
     private SendIMDialogSmiley mSmyDialog;
     private SharedPreferences mSet;
     private SharedPreferences mGlobalSettings;
@@ -50,6 +52,11 @@
     private IChatManagerListener mChatManagerListener;
     private IMessageListener mMessageListener;
     private IChat mChat;
+    private Drawable mAvatar;
+    private TextView mText;
+    private TextView mLogin;
+    private ScrollView mScrolling;
+    private Boolean mSpeak;
 
     /**
      * Constructor.
@@ -64,6 +71,7 @@
     @Override
     public void onCreate(Bundle saveBundle) {
 	super.onCreate(saveBundle);
+	setTheme(R.style.customtheme_contactList);
 	mHandler = new Handler();
 	mChatManagerListener = new OnChatListener();
 	mMessageListener = new OnMessageListener();
@@ -72,16 +80,30 @@
 	mToSend = (EditText) findViewById(R.id.userText);
 	mSet = getSharedPreferences("lol", MODE_PRIVATE);
 	mSmyDialog = new SendIMDialogSmiley(this, mSet);
-	mGlobalSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
-
-	mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist,
+	mGlobalSettings = getSharedPreferences(
+		getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	/*mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist,
 		mMessages);
-	setListAdapter(mAdapter);
+	setListAdapter(mAdapter);*/
 
 	mToSend.setOnClickListener(this);
 	mToSend.setOnKeyListener(this);
-
+	
 	mContact = getIntent().getParcelableExtra("contact");
+	setViewHeader();
+	mText = (TextView) findViewById(R.id.sendimlist);
+	mScrolling = (ScrollView) findViewById(R.id.sendimscroll);
+    }
+    
+    private void setViewHeader()
+    {
+	mLogin = (TextView) findViewById(R.id.sendimlogin);
+	String status = mContact.getMsgState();
+	if (status == null)
+	    status = getString(R.string.SendIMNoStatusSet);
+	else
+	    status = mContact.getMsgState();
+	mLogin.setText(mContact.getJID() + "\n" + status);
     }
 
     @Override
@@ -112,8 +134,11 @@
      * pendant la conversation
      */
     private void sendText() {
+	if (mSpeak == null)
+	    mSpeak = false;
 	String text = mToSend.getText().toString();
-	String from = mGlobalSettings.getString(getString(R.string.PreferenceJID), "You");
+	String from = mGlobalSettings.getString(
+		getString(R.string.PreferenceJID), "You");
 	if (!text.equals("")) {
 	    Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
 	    msg.setBody(text);
@@ -123,8 +148,15 @@
 		// TODO Auto-generated catch block
 		e.printStackTrace();
 	    }
-	    mAdapter.add(from + getString(R.string.SendIMSays) + text);
+	    //mAdapter.add(from + getString(R.string.SendIMSays) + text);
+	    if (!mSpeak)
+		mText.append(from + getString(R.string.SendIMSays) + text + "\n");
+	    else
+		mText.append(text + "\n");
 	    mToSend.setText(null);
+	    mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
+	    mToSend.requestFocus();
+	    mSpeak = true;
 	}
     }
 
@@ -168,27 +200,45 @@
 		return false;
 	}
     }
-    
+
     private class OnChatListener extends IChatManagerListener.Stub {
 
 	@Override
 	public void chatCreated(IChat chat, boolean locally)
 		throws RemoteException {
 	    Log.i("LOG", "chatCreated");
-	    
+
 	}
-	
+
     }
-    
+
     private class OnMessageListener extends IMessageListener.Stub {
 
 	@Override
 	public void processMessage(IChat chat, Message msg)
 		throws RemoteException {
 	    Log.i("LOG", "processMessage");
-	    mAdapter.add(mContact.getJID() + " "
-		    + getString(R.string.SendIMSays) + msg.getBody());
+	    /*mAdapter.add(mContact.getJID() + " "
+		    + getString(R.string.SendIMSays) + msg.getBody());*/
+	    
+	    final Message m = msg;
+	    mHandler.post(new Runnable() {
+	    
+	        @Override
+	        public void run() {
+	            if (m.getBody() != null)
+	            {
+	        	if (!mSpeak)
+	        	    mText.append(m.getBody() + "\n");
+	        	else
+	        	    mText.append(mContact.getJID() + " "
+				    + getString(R.string.SendIMSays) + m.getBody() + "\n");
+	        	mSpeak = false;
+	        	mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
+	        	mToSend.requestFocus();
+	            }
+	        }
+	    });
 	}
-	
     }
 }