/soc/2012/michael/android: 132f7a5015e1: Made accounts editable.

Michael Zangl michael at soc.pidgin.im
Wed Jul 25 07:23:39 EDT 2012


Changeset: 132f7a5015e12f7bbad0d56867cd64d6f087197f
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-21 12:44 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/132f7a5015e1

Description:

Made accounts editable.

diffstat:

 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/AccountEditView.java     |  24 ++++++---
 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/ProtocolListAdapter.java |   4 +
 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/accountlist/AccountListView.java |  14 +++++-
 3 files changed, 32 insertions(+), 10 deletions(-)

diffs (110 lines):

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
@@ -52,15 +52,19 @@ public class AccountEditView implements 
 		alias = (EditText) root.findViewById(R.id.accountedit_alias);
 		password = (EditText) root.findViewById(R.id.accountedit_password);
 		protocol = (Spinner) root.findViewById(R.id.accountedit_protocol);
-		
-		PurplePluginList pluginList = viewController.getPurple().getPluginList();
-		protocolList = new ProtocolListAdapter(viewController.getLayoutInflater(), pluginList);
+
+		PurplePluginList pluginList = viewController.getPurple()
+				.getPluginList();
+		protocolList = new ProtocolListAdapter(
+				viewController.getLayoutInflater(), pluginList);
 		protocol.setAdapter(protocolList);
 
 		if (account != null) {
 			username.setText(account.getUsername());
 			alias.setText(account.getAlias());
 			password.setText(account.getPassword());
+			protocol.setSelection(protocolList.indexOf(account.getProtocol()),
+					false);
 			protocol.setEnabled(false);
 		}
 
@@ -76,8 +80,10 @@ public class AccountEditView implements 
 			title.setText(R.string.accountedit_title_new);
 			okButton.setText(R.string.accountedit_ok_new);
 		} else {
+			String alias2 = account.getAlias();
 			title.setText(viewController.getResources().getString(
-					R.string.accountedit_title, account.getAlias()));
+					R.string.accountedit_title,
+					alias2 == null ? account.getUsername() : alias2));
 			okButton.setText(R.string.accountedit_ok);
 		}
 
@@ -90,15 +96,16 @@ public class AccountEditView implements 
 	}
 
 	protected void saveAndExit() {
-		if (protocol == null  || protocolList == null|| username == null || password == null
-				|| alias == null) {
+		if (protocol == null || protocolList == null || username == null
+				|| password == null || alias == null) {
 			throw new IllegalStateException(
 					"No view was created but saveAndExit was called.");
 		}
-		PurpleProtocolPlugin prpl = protocolList.getProtocol(protocol.getSelectedItemPosition());
+		PurpleProtocolPlugin prpl = protocolList.getProtocol(protocol
+				.getSelectedItemPosition());
 
 		PurpleAccount account;
-			String userText = username.getText().toString();
+		String userText = username.getText().toString();
 		if (this.account == null) {
 			account = viewController.getPurple().getAccountList()
 					.addAccount(userText, prpl);
@@ -107,6 +114,7 @@ public class AccountEditView implements 
 			account.setUsername(userText);
 		}
 		account.setAlias(alias.getText().toString());
+		account.setRememberPassword(true);
 		account.setPassword(password.getText().toString());
 
 		viewController.toast(viewController.getResources().getString(
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/ProtocolListAdapter.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/ProtocolListAdapter.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/ProtocolListAdapter.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/account/ProtocolListAdapter.java
@@ -62,4 +62,8 @@ public class ProtocolListAdapter extends
 		return protocols.get(arg0);
 	}
 
+	public int indexOf(PurpleProtocolPlugin protocol) {
+		return protocols.indexOf(protocol);
+	}
+
 }
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/accountlist/AccountListView.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/accountlist/AccountListView.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/accountlist/AccountListView.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/accountlist/AccountListView.java
@@ -5,6 +5,8 @@ import im.pidgin.libpurple.testclient.co
 import im.pidgin.libpurple.testclient.core.ViewController;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
 import android.widget.Button;
 import android.widget.ListView;
 
@@ -34,8 +36,16 @@ public class AccountListView implements 
 		});
 
 		ListView list = (ListView) root.findViewById(R.id.accountlist);
-		list.setAdapter(new AccountListAdapter(viewController, true));
-
+		final AccountListAdapter listAdapter = new AccountListAdapter(viewController, true);
+		list.setAdapter(listAdapter);
+		list.setOnItemClickListener(new OnItemClickListener() {
+			@Override
+			public void onItemClick(AdapterView<?> arg0, View arg1, int index,
+					long arg3) {
+				viewController.displayAccountEdit(listAdapter.getAccount(index));
+			}
+		});
+		
 		Button toBlistButton = (Button) root
 				.findViewById(R.id.accountlist_buddyListButton);
 		if (withBListButton) {



More information about the Commits mailing list