# HG changeset patch
# User marseille@marseille-desktop
# Date 1237139972 -3600
# Node ID accfe4a4010f7f8c11609e4843f066bba22cd845
# Parent c36eb05998137c8870f1c01e42711f20647089be
Interface 'finit' connection / configuration finit.
diff -r c36eb0599813 -r accfe4a4010f res/layout/main.xml
--- a/res/layout/main.xml Sat Mar 14 23:36:04 2009 +0100
+++ b/res/layout/main.xml Sun Mar 15 18:59:32 2009 +0100
@@ -10,28 +10,27 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
-
-
-
-
-
-
+
+
+ android:scrollHorizontally="true" />
+
+
-
diff -r c36eb0599813 -r accfe4a4010f res/layout/settings.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/settings.xml Sun Mar 15 18:59:32 2009 +0100
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r c36eb0599813 -r accfe4a4010f res/menu/account.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/menu/account.xml Sun Mar 15 18:59:32 2009 +0100
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff -r c36eb0599813 -r accfe4a4010f src/com/beem/project/beem/Beem.java
--- a/src/com/beem/project/beem/Beem.java Sat Mar 14 23:36:04 2009 +0100
+++ b/src/com/beem/project/beem/Beem.java Sun Mar 15 18:59:32 2009 +0100
@@ -1,16 +1,55 @@
package com.beem.project.beem;
import android.app.Activity;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.EditText;
-public class Beem extends Activity
-{
- /** Called when the activity is first created. */
+public class Beem extends Activity {
+ public static final String jabberSettings = "Beem";
+ private SharedPreferences mSettings;
+ /**
+ * Called when the activity is first created. */
@Override
- public void onCreate(Bundle savedInstanceState)
- {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
-
+
+ mSettings = getSharedPreferences(jabberSettings, MODE_PRIVATE);
+ showJID();
+ }
+
+
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.account, menu);
+ return true;
}
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ SettingsDialog Dialog = new SettingsDialog(this, mSettings);
+ switch (item.getItemId()) {
+ case R.id.account_edit:
+ Dialog.show();
+ return true;
+ case R.id.account_about:
+ return true;
+ }
+ return false;
+ }
+
+ public void showJID() {
+ EditText ejid = (EditText) findViewById(R.id.jid);
+ String jid = mSettings.getString("login", "") +
+ "@" + mSettings.getString("host", "") ;
+ if (jid.length() == 1)
+ jid = "Enter Jabber ID / Create New Account";
+ ejid.setText(jid);
+ }
+
+
}
diff -r c36eb0599813 -r accfe4a4010f src/com/beem/project/beem/SettingsDialog.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/SettingsDialog.java Sun Mar 15 18:59:32 2009 +0100
@@ -0,0 +1,64 @@
+package com.beem.project.beem;
+
+import android.app.Dialog;
+import android.content.SharedPreferences;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+/**
+ *
+ */
+public class SettingsDialog extends Dialog implements android.view.View.OnClickListener {
+
+ private Beem mbeem;
+ private SharedPreferences mSettings;
+ public SettingsDialog(Beem beem, SharedPreferences settings) {
+ super(beem);
+ this.mbeem = beem;
+ this.mSettings = settings;
+ }
+
+ protected void onStart() {
+ super.onStart();
+ setContentView(R.layout.settings);
+ getWindow().setFlags(4, 4);
+ setTitle("Jabber Account Settings");
+ showSettings();
+ Button ok = (Button) findViewById(R.id.ok);
+ ok.setOnClickListener(this);
+ }
+
+ public void onClick(View v) {
+ SharedPreferences.Editor editor = mSettings.edit();
+ editor.putString("host", getText(R.id.host));
+ editor.putString("port", getText(R.id.port));
+ editor.putString("login", getText(R.id.userid));
+ editor.putString("password", getText(R.id.password));
+ editor.commit();
+
+ this.mbeem.showJID();
+ dismiss();
+ }
+
+ private void showSettings() {
+ String tmp;
+ EditText eHost = (EditText) findViewById(R.id.host);
+ if ((tmp = mSettings.getString("host","")) != "")
+ eHost.setText(tmp);
+ EditText ePort = (EditText) findViewById(R.id.port);
+ if ((tmp = mSettings.getString("port","")) != "")
+ ePort.setText(tmp);
+ EditText eLogin = (EditText) findViewById(R.id.userid);
+ if ((tmp = mSettings.getString("login","")) != "")
+ eLogin.setText(tmp);
+ EditText ePwd = (EditText) findViewById(R.id.password);
+ if ((tmp = mSettings.getString("password","")) != "")
+ ePwd.setText(tmp);
+ }
+
+ private String getText(int id) {
+ EditText widget = (EditText) this.findViewById(id);
+ return widget.getText().toString();
+ }
+}