/soc/2012/michael/android: fbb68f11c847: Added back-button abili...

Michael Zangl michael at soc.pidgin.im
Sat Jul 7 03:34:13 EDT 2012


Changeset: fbb68f11c8472daa948a7d75dbdf481adc640a22
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-06-17 17:30 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/fbb68f11c847

Description:

Added back-button ability to account edit dialog

diffstat:

 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/PurpleTestClient.java        |  16 +++---
 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/AccountEditView.java |  21 +++++++++-
 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/core/ViewController.java     |   2 +
 3 files changed, 29 insertions(+), 10 deletions(-)

diffs (109 lines):

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
@@ -1,17 +1,18 @@
 package im.pidgin.libpurple.testclient;
 
-import java.util.LinkedList;
-
 import im.pidgin.libpurple.account.PurpleAccount;
 import im.pidgin.libpurple.core.PurpleInstance;
 import im.pidgin.libpurple.testclient.about.AboutView;
+import im.pidgin.libpurple.testclient.account.AccountEditView;
 import im.pidgin.libpurple.testclient.accountlist.AccountListView;
 import im.pidgin.libpurple.testclient.core.TestClientView;
 import im.pidgin.libpurple.testclient.core.ViewController;
+
+import java.util.LinkedList;
+
 import android.app.Activity;
 import android.os.Bundle;
 import android.view.View;
-import android.widget.TextView;
 
 public class PurpleTestClient extends Activity implements ViewController {
 	private PurpleInstance instance;
@@ -40,7 +41,8 @@
 		viewStack.addLast(new DisplayedView(view, androidView));
 	}
 
-	private void goBack() {
+	@Override
+	public void goBack() {
 		DisplayedView popped = viewStack.pollLast();
 		popped.notifyRemove();
 
@@ -84,14 +86,12 @@
 
 	@Override
 	public void displayAccountEdit(PurpleAccount account) {
-		// TODO Auto-generated method stub
-		
+		showView(new AccountEditView(this, account));
 	}
 
 	@Override
 	public void displayNewAccountDialog() {
-		// TODO Auto-generated method stub
-		
+		showView(new AccountEditView(this));		
 	}
 
 	@Override
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/AccountEditView.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/AccountEditView.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/AccountEditView.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/AccountEditView.java
@@ -5,6 +5,7 @@
 import im.pidgin.libpurple.testclient.core.TestClientView;
 import im.pidgin.libpurple.testclient.core.ViewController;
 import android.view.View;
+import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.TextView;
 
@@ -33,7 +34,13 @@
 	public View createView() {
 		View root = viewController.getLayoutInflater().inflate(R.layout.accountedit, null);
 		
-        TextView title = (TextView) root.findViewById(R.id.accountedit_headline);
+        registerTitlebar(root);
+        
+        return root;
+	}
+
+	private void registerTitlebar(View root) {
+		TextView title = (TextView) root.findViewById(R.id.accountedit_headline);
         Button okButton = (Button) root.findViewById(R.id.accountedit_ok);
         
         if (account == null) {
@@ -44,7 +51,17 @@
         	okButton.setText(R.string.accountedit_ok);
         }
         
-        return root;
+        okButton.setOnClickListener(new OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				saveAndExit();
+			}
+		});
+	}
+
+	protected void saveAndExit() {
+		//TODO: save
+		viewController.goBack();
 	}
 
 	@Override
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/core/ViewController.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/core/ViewController.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/core/ViewController.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/core/ViewController.java
@@ -23,6 +23,8 @@
 
 	PurpleInstance getPurple();
 
+	void goBack();
+	
 	void runOnUiThread(Runnable runnable);
 
 	Resources getResources();



More information about the Commits mailing list