/soc/2012/michael/android: 83474029bb23: Added the conversation ...

Michael Zangl michael at soc.pidgin.im
Tue Aug 7 07:58:35 EDT 2012


Changeset: 83474029bb2339bc4dd5a1984f1b753ea7549ee7
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-08-07 13:58 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/83474029bb23

Description:

Added the conversation view.

diffstat:

 android/workspace/im.pidgin.libpurple.testclient/res/layout/conversation.xml                                           |  52 ++++++++++
 android/workspace/im.pidgin.libpurple.testclient/res/values/strings.xml                                                |   2 +
 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/PurpleTestClient.java              |   4 +-
 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistView.java               |   9 +-
 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java |  44 ++++++++
 5 files changed, 105 insertions(+), 6 deletions(-)

diffs (173 lines):

diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/layout/conversation.xml b/android/workspace/im.pidgin.libpurple.testclient/res/layout/conversation.xml
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/layout/conversation.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" >
+
+        <TextView
+            android:id="@+id/conversation_title"
+            style="@style/headline"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="@string/conversation_title" />
+
+    </LinearLayout>
+    
+    <EditText
+        android:id="@+id/conversation_messages"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:editable="false"
+        android:ems="10"
+        android:inputType="textMultiLine"
+        android:singleLine="false" >
+
+        <requestFocus />
+    </EditText>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" >
+
+        <EditText
+            android:id="@+id/conversation_message"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:ems="10" />
+
+        <Button
+            android:id="@+id/conversation_sendbutton"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/conlersation_send" />
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/values/strings.xml b/android/workspace/im.pidgin.libpurple.testclient/res/values/strings.xml
--- a/android/workspace/im.pidgin.libpurple.testclient/res/values/strings.xml
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/values/strings.xml
@@ -28,5 +28,7 @@
     <string name="addbuddy_account">Account</string>
     <string name="addbuddy_username">Username</string>
     <string name="addbuddy_added">Added buddy %s</string>
+    <string name="conlersation_send">Send</string>
+    <string name="conversation_title">conversation with %s</string>
 
 </resources>
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/PurpleTestClient.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/PurpleTestClient.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/PurpleTestClient.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/PurpleTestClient.java
@@ -9,6 +9,7 @@ import im.pidgin.libpurple.testclient.ac
 import im.pidgin.libpurple.testclient.accountlist.AccountListView;
 import im.pidgin.libpurple.testclient.blist.AddBuddyView;
 import im.pidgin.libpurple.testclient.blist.BlistView;
+import im.pidgin.libpurple.testclient.conversation.ConversationView;
 import im.pidgin.libpurple.testclient.core.TestClientView;
 import im.pidgin.libpurple.testclient.core.ViewController;
 
@@ -128,8 +129,7 @@ public class PurpleTestClient extends Ac
 
 	@Override
 	public void displayConversation(PurpleBuddy buddy) {
-		// TODO Auto-generated method stub
-
+		showView(new ConversationView(this, buddy));
 	}
 
 	@Override
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistView.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistView.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistView.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistView.java
@@ -2,6 +2,7 @@ package im.pidgin.libpurple.testclient.b
 
 import im.pidgin.libpurple.blist.PurpleBlistGroup;
 import im.pidgin.libpurple.blist.PurpleBlistNode;
+import im.pidgin.libpurple.blist.PurpleContact;
 import im.pidgin.libpurple.buddy.PurpleBuddy;
 import im.pidgin.libpurple.testclient.R;
 import im.pidgin.libpurple.testclient.core.TestClientView;
@@ -55,8 +56,8 @@ public class BlistView implements TestCl
 	public void onItemClick(AdapterView<?> parent, View view, int position,
 			long id) {
 		PurpleBlistNode node = blistAdapter.getNodeAt(position);
-		if (node instanceof PurpleBuddy) {
-			PurpleBuddy buddy = (PurpleBuddy) node;
+		if (node instanceof PurpleContact) {
+			PurpleBuddy buddy = ((PurpleContact) node).getPriorityBuddy();
 			viewController.displayConversation(buddy);
 		}
 	}
@@ -65,8 +66,8 @@ public class BlistView implements TestCl
 	public boolean onItemLongClick(AdapterView<?> parent, View view,
 			int position, long id) {
 		PurpleBlistNode node = blistAdapter.getNodeAt(position);
-		if (node instanceof PurpleBuddy) {
-			PurpleBuddy buddy = (PurpleBuddy) node;
+		if (node instanceof PurpleContact) {
+			PurpleBuddy buddy = ((PurpleContact) node).getPriorityBuddy();
 			/* TODO: buddy menu */
 		} else if (node instanceof PurpleBlistGroup) {
 			PurpleBlistGroup group = (PurpleBlistGroup) node;
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java
@@ -0,0 +1,44 @@
+package im.pidgin.libpurple.testclient.conversation;
+
+import im.pidgin.libpurple.buddy.PurpleBuddy;
+import im.pidgin.libpurple.testclient.R;
+import im.pidgin.libpurple.testclient.core.TestClientView;
+import im.pidgin.libpurple.testclient.core.ViewController;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+public class ConversationView implements TestClientView {
+
+	private final ViewController viewController;
+	private final PurpleBuddy buddy;
+	private View view;
+
+	public ConversationView(ViewController viewController, PurpleBuddy buddy) {
+		this.viewController = viewController;
+		this.buddy = buddy;
+	}
+
+	@Override
+	public View createView() {
+		if (view == null) {
+			view = viewController.getLayoutInflater().inflate(R.layout.conversation, null);
+			
+			TextView title = (TextView) view.findViewById(R.id.conversation_title);
+			title.setText(viewController.getResources().getString(R.string.conversation_title, buddy.getDisplayName()));
+			
+			EditText messages = (EditText) view.findViewById(R.id.conversation_messages);
+			EditText message = (EditText) view.findViewById(R.id.conversation_message);
+			Button sendbutton = (Button) view.findViewById(R.id.conversation_sendbutton);
+		}
+		return view;
+	}
+
+	@Override
+	public void removed(View view) {
+		// TODO Auto-generated method stub
+
+	}
+
+}



More information about the Commits mailing list