/soc/2012/michael/android: 32e44e58e6b3: Created layouts for abo...
Michael Zangl
michael at soc.pidgin.im
Sat Jul 7 03:34:13 EDT 2012
Changeset: 32e44e58e6b3544dfb45b361829cb61cca1e7452
Author: Michael Zangl <michael at soc.pidgin.im>
Date: 2012-06-16 15:55 +0200
Branch: soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/32e44e58e6b3
Description:
Created layouts for about page and account list and basic view handling in acitivity class.
diffstat:
android/workspace/im.pidgin.libpurple.testclient/res/layout/main.xml | 11 +-
android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist.xml | 45 ++++++
android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist_item.xml | 46 +++++++
android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist.xml | 8 +
android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist_item.xml | 7 +
android/workspace/im.pidgin.libpurple.testclient/res/values/dimens.xml | 7 +
android/workspace/im.pidgin.libpurple.testclient/res/values/strings.xml | 10 +-
android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/PurpleTestClient.java | 65 ++++++++-
android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/about/AboutView.java | 33 +++++
android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/accountlist/AccountView.java | 41 ++++++
android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/core/TestClientView.java | 22 +++
android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/core/ViewController.java | 24 +++
12 files changed, 305 insertions(+), 14 deletions(-)
diffs (truncated from 406 to 300 lines):
diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/layout/main.xml b/android/workspace/im.pidgin.libpurple.testclient/res/layout/about.xml
rename from android/workspace/im.pidgin.libpurple.testclient/res/layout/main.xml
rename to android/workspace/im.pidgin.libpurple.testclient/res/layout/about.xml
--- a/android/workspace/im.pidgin.libpurple.testclient/res/layout/main.xml
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/layout/about.xml
@@ -5,9 +5,16 @@
android:orientation="vertical" >
<TextView
- android:id="@+id/main_text"
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/about_title"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <TextView
+ android:id="@+id/about_purple_version"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:text="@string/hello" />
+ android:text="" />
</LinearLayout>
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist.xml b/android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist.xml
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist.xml
@@ -0,0 +1,45 @@
+<?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"
+ android:layout_gravity="right" >
+
+ <TextView
+ android:id="@+id/accountlist_headline"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1"
+ android:text="@string/accountlist_title"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <Button
+ android:id="@+id/accountlist_newButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_margin="@dimen/padding_button"
+ android:text="@string/accountlist_new" />
+
+ </LinearLayout>
+
+ <ListView
+ android:id="@+id/accountlist"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="5" >
+ </ListView>
+
+ <Button
+ android:id="@+id/accountlist_buddyListButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_margin="@dimen/padding_button"
+ android:text="@string/accountlist_showBuddylist" />
+</LinearLayout>
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist_item.xml b/android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist_item.xml
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/layout/accountlist_item.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="top"
+ android:padding="@dimen/padding_listitem" >
+
+ <CheckBox
+ android:id="@+id/accountitem_accountIsActive"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:layout_marginRight="@dimen/padding_listitem_icon"
+ android:focusable="false"
+ android:focusableInTouchMode="false" />
+
+ <ImageView
+ android:id="@+id/accountlist_item_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@+id/accountitem_accountIsActive"
+ android:layout_marginRight="@dimen/padding_listitem_icon"
+ android:layout_alignParentTop="true"
+ android:contentDescription="@string/accountlist_accountIcon" />
+
+ <TextView
+ android:id="@+id/accountlist_item_username"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_alignWithParentIfMissing="true"
+ android:layout_toRightOf="@+id/accountlist_item_icon"
+ android:layout_marginTop="@dimen/padding_listitem_text"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/accountlist_item_protocol"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/accountlist_item_username"
+ android:layout_toRightOf="@+id/accountlist_item_icon"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#888888" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist.xml b/android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist.xml
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+ <item android:id="@+id/accountlist_menu_new" android:title="@string/accountlist_new"></item>
+ <item android:id="@+id/accountlist_menu_about" android:title="@string/about_menu_title"></item>
+
+
+
+</menu>
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist_item.xml b/android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist_item.xml
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/menu/accountlist_item.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+ <item android:id="@+id/accountlist_item_menu_edit" android:title="@string/accountlist_edit"></item>
+ <item android:id="@+id/accountlist_item_menu_delete" android:title="@string/accountlist_delete"></item>
+
+
+</menu>
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/res/values/dimens.xml b/android/workspace/im.pidgin.libpurple.testclient/res/values/dimens.xml
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/res/values/dimens.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <dimen name="padding_listitem">2sp</dimen>
+ <dimen name="padding_button">3sp</dimen>
+ <dimen name="padding_listitem_text">6sp</dimen>
+ <dimen name="padding_listitem_icon">6sp</dimen>
+</resources>
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
@@ -1,7 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
-
- <string name="hello">Hello World, PurpleTestClient!</string>
<string name="app_name">Im.pidgin.libpurple.testclient</string>
+ <string name="accountlist_accountIcon">Account icon</string>
+ <string name="accountlist_new">Newâ¦</string>
+ <string name="accountlist_delete">Delete</string>
+ <string name="accountlist_edit">Editâ¦</string>
+ <string name="about_title">About Purple Testclient</string>
+ <string name="about_menu_title">Aboutâ¦</string>
+ <string name="accountlist_title">Accounts</string>
+ <string name="accountlist_showBuddylist">Go to Buddylist</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
@@ -1,19 +1,64 @@
package im.pidgin.libpurple.testclient;
+import java.util.LinkedList;
+
import im.pidgin.libpurple.core.PurpleInstance;
+import im.pidgin.libpurple.testclient.core.TestClientView;
import android.app.Activity;
import android.os.Bundle;
+import android.view.View;
import android.widget.TextView;
public class PurpleTestClient extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- TextView text = (TextView) findViewById(R.id.main_text);
-
- text.setText("Purple Version: " + PurpleInstance.createInstance("testclient", getFilesDir()).getVersion());
- }
+ private PurpleInstance instance;
+
+ private final LinkedList<DisplayedView> viewStack = new LinkedList<DisplayedView>();
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (instance != null) {
+ instance = PurpleInstance.createInstance("testclient",
+ getFilesDir());
+ }
+
+ }
+
+ private void showView(TestClientView view) {
+ if (!viewStack.isEmpty()) {
+ viewStack.peekLast().notifyRemove();
+ }
+
+ View androidView = view.createView();
+ setContentView(androidView);
+ viewStack.addLast(new DisplayedView(view, androidView));
+ }
+
+ private void goBack() {
+ DisplayedView popped = viewStack.pollLast();
+ popped.notifyRemove();
+
+ if (!viewStack.isEmpty()) {
+ viewStack.peekLast().androidView = viewStack.peekLast().view
+ .createView();
+ setContentView(viewStack.peekLast().androidView);
+ } else {
+ finish();
+ }
+ }
+
+ private static class DisplayedView {
+ private final TestClientView view;
+ private View androidView;
+
+ private DisplayedView(TestClientView view, View androidView) {
+ this.view = view;
+ this.androidView = androidView;
+ }
+
+ public void notifyRemove() {
+ view.removed(androidView);
+ }
+ }
}
\ No newline at end of file
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/about/AboutView.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/about/AboutView.java
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/about/AboutView.java
@@ -0,0 +1,33 @@
+package im.pidgin.libpurple.testclient.about;
+
+import android.view.View;
+import android.widget.TextView;
+import im.pidgin.libpurple.testclient.R;
+import im.pidgin.libpurple.testclient.core.TestClientView;
+import im.pidgin.libpurple.testclient.core.ViewController;
+
+public class AboutView implements TestClientView {
+
+ private final ViewController viewController;
+
+ public AboutView(ViewController viewController) {
+ this.viewController = viewController;
+ }
+
+ @Override
+ public View createView() {
+ View root = viewController.getLayoutInflater().inflate(R.layout.about, null);
+
+ TextView text = (TextView) root.findViewById(R.id.about_purple_version);
+ text.setText("Purple Version: " + viewController.getPurple().getVersion());
+
+ return root;
+ }
+
+ @Override
+ public void removed(View view) {
+ // TODO Auto-generated method stub
More information about the Commits
mailing list