Use relative layout in chat activity.
authorDa Risk <darisk972@gmail.com>
Tue, 12 Jan 2010 23:21:16 +0100
changeset 634 bac4b1927a08
parent 633 947763da95ed
child 635 e76311960b40
Use relative layout in chat activity.
res/layout/chat.xml
res/layout/login.xml
src/com/beem/project/beem/ui/Chat.java
--- a/res/layout/chat.xml	Tue Jan 12 12:31:21 2010 +0100
+++ b/res/layout/chat.xml	Tue Jan 12 23:21:16 2010 +0100
@@ -2,26 +2,25 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 	android:layout_width="fill_parent" android:layout_height="fill_parent"
 	android:orientation="vertical">
-	<LinearLayout android:id="@+id/chat_header"
+	<RelativeLayout android:id="@+id/chat_header"
 		android:layout_width="fill_parent" android:layout_height="wrap_content"
-		android:orientation="horizontal" android:gravity="center_vertical"
 		android:background="#222222" android:padding="4px">
 		<ImageView android:id="@+id/chat_contact_status_icon"
 			android:adjustViewBounds="true" android:layout_width="wrap_content"
-			android:layout_height="wrap_content" android:gravity="center_vertical" />
-		<LinearLayout android:orientation="vertical"
+			android:layout_height="wrap_content"
+			android:layout_centerVertical="true" />
+		<TextView android:id="@+id/chat_contact_name"
 			android:layout_width="fill_parent" android:layout_height="wrap_content"
-			android:paddingLeft="15sp">
-			<TextView android:id="@+id/chat_contact_name"
-				android:layout_width="fill_parent" android:layout_height="wrap_content"
-				android:lines="1" android:singleLine="true" android:textSize="16sp"
-				android:textStyle="bold" android:textColor="#FFFFFF" />
-			<TextView android:id="@+id/chat_contact_status_msg"
-				android:layout_width="fill_parent" android:layout_height="wrap_content"
-				android:autoLink="all" android:textSize="12sp" android:textColor="#FFFFFF"
-				android:textColorLink="#FFFFFF" />
-		</LinearLayout>
-	</LinearLayout>
+			android:layout_toRightOf="@id/chat_contact_status_icon"
+			android:layout_marginLeft="15sp"
+			android:lines="1" android:singleLine="true" android:textSize="16sp"
+			android:textStyle="bold" android:textColor="#FFFFFF" />
+		<TextView android:id="@+id/chat_contact_status_msg"
+			android:layout_width="fill_parent" android:layout_height="wrap_content"
+			android:layout_below="@id/chat_contact_name" android:layout_alignLeft="@id/chat_contact_name"
+			android:autoLink="all" android:textSize="12sp" android:textColor="#FFFFFF"
+			android:textColorLink="#FFFFFF" />
+	</RelativeLayout>
 	<View android:layout_width="fill_parent" android:layout_height="2dp"
 		android:fadingEdge="horizontal" android:background="#555555" />
 	<ListView android:id="@+id/chat_messages"
@@ -32,7 +31,7 @@
 	<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="wrap_content"
+		<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"
--- a/res/layout/login.xml	Tue Jan 12 12:31:21 2010 +0100
+++ b/res/layout/login.xml	Tue Jan 12 23:21:16 2010 +0100
@@ -3,7 +3,7 @@
 	android:layout_width="fill_parent" android:layout_height="fill_parent"
 	android:orientation="vertical">
 	<LinearLayout android:orientation="vertical"
-		android:layout_width="fill_parent" android:layout_height="fill_parent">
+		android:layout_width="fill_parent" android:layout_height="wrap_content">
 		<ImageView android:id="@+id/log_as_logo" android:src="@drawable/logo"
 			android:layout_width="fill_parent" android:layout_height="wrap_content"
 			android:layout_marginBottom="25px" android:layout_marginTop="42px" />
--- a/src/com/beem/project/beem/ui/Chat.java	Tue Jan 12 12:31:21 2010 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java	Tue Jan 12 23:21:16 2010 +0100
@@ -387,11 +387,11 @@
 	public void onServiceConnected(ComponentName name, IBinder service) {
 	    mXmppFacade = IXmppFacade.Stub.asInterface(service);
 	    try {
-		mChatManager = mXmppFacade.getChatManager();
-		mRoster = mXmppFacade.getRoster();
-		mRoster.addRosterListener(mBeemRosterListener);
+		if ((mRoster = mXmppFacade.getRoster()) != null )
+		    mRoster.addRosterListener(mBeemRosterListener);
 		mContact = new Contact(getIntent().getData());
-		changeCurrentChat(mContact);
+		if ((mChatManager = mXmppFacade.getChatManager()) != null)
+		    changeCurrentChat(mContact);
 	    } catch (RemoteException e) {
 		Log.e(TAG, e.getMessage());
 	    }