--- a/AndroidManifest.xml Tue Apr 21 19:06:38 2009 +0200
+++ b/AndroidManifest.xml Wed Apr 22 00:25:01 2009 +0200
@@ -2,14 +2,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.beem.project.beem" android:versionCode="1"
android:versionName="1.0">
- <application android:label="@string/app_name" android:name="BeemApplication" android:theme="@style/customtheme.contactList">
+ <application android:label="@string/app_name" android:name="BeemApplication"
+ android:theme="@style/customtheme.contactList">
<activity android:name=".ui.ContactList" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name=".ui.ContactListSettings" android:label="@string/app_name" />
+ <activity android:name=".ui.ContactListSettings"
+ android:label="@string/app_name" />
<activity android:name=".ui.SendIM" android:label="@string/app_name" />
<activity android:name=".ui.ChangeStatus" android:label="@string/app_name" />
<service android:name="BeemService" android:enabled="true"
--- a/res/layout/contactlistsettings.xml Tue Apr 21 19:06:38 2009 +0200
+++ b/res/layout/contactlistsettings.xml Wed Apr 22 00:25:01 2009 +0200
@@ -1,88 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Host/Port:"
- android:minWidth="90dp"
- />
-
- <EditText android:id="@+id/host"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="16sp"
- android:autoText="false"
- android:capitalize="none"
- android:layout_weight="2"
- android:scrollHorizontally="true"/>
- <EditText android:id="@+id/port"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="16sp"
- android:autoText="false"
- android:capitalize="none"
- android:layout_weight="3"
- android:scrollHorizontally="true"/>
- </LinearLayout>
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="Server connection"
+ android:textSize="18sp" />
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:text="Host/Port:"
+ android:minWidth="90dp" android:textSize="14sp" />
+ <EditText android:id="@+id/host" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:singleLine="true"
+ android:textSize="14sp" android:autoText="false" android:capitalize="none"
+ android:layout_weight="2" android:scrollHorizontally="true" />
+ <EditText android:id="@+id/port" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:singleLine="true"
+ android:textSize="14sp" android:autoText="false" android:capitalize="none"
+ android:layout_weight="3" android:scrollHorizontally="true" />
+ </LinearLayout>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:text="Userid:"
+ android:minWidth="90dp" android:textSize="14sp" />
+ <EditText android:id="@+id/userid" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:singleLine="true"
+ android:textSize="14sp" android:autoText="false" android:capitalize="none"
+ android:scrollHorizontally="true" />
+ </LinearLayout>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:text="Password:"
+ android:minWidth="90dp" android:textSize="14sp" />
+ <EditText android:id="@+id/password" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:singleLine="true"
+ android:password="true" android:textSize="14sp" android:autoText="false"
+ android:capitalize="none" android:scrollHorizontally="true" />
+ </LinearLayout>
+
+ <Spinner android:id="@+id/proxy_type" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Userid:"
- android:minWidth="90dp"
- />
- <EditText android:id="@+id/userid"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="16sp"
- android:autoText="false"
- android:capitalize="none"
- android:scrollHorizontally="true"/>
- </LinearLayout>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Password:"
- android:minWidth="90dp"
- />
- <EditText android:id="@+id/password"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:password="true"
- android:textSize="16sp"
- android:autoText="false"
- android:capitalize="none"
- android:scrollHorizontally="true"/>
- </LinearLayout>
+ <LinearLayout android:id="@+id/proxy_layout"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="Proxy informations"
+ android:textSize="18sp" />
+
+ <LinearLayout android:orientation="horizontal"
+ android:layout_width="fill_parent" android:layout_height="wrap_content">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:text="Host/Port:"
+ android:minWidth="90dp" android:textSize="14sp" />
+ <EditText android:id="@+id/proxy_host" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:singleLine="true"
+ android:textSize="14sp" android:autoText="false" android:capitalize="none"
+ android:layout_weight="2" android:scrollHorizontally="true" />
+ <EditText android:id="@+id/proxy_port" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:singleLine="true"
+ android:textSize="14sp" android:autoText="false" android:capitalize="none"
+ android:layout_weight="3" android:scrollHorizontally="true" />
+ </LinearLayout>
- <Button android:id="@+id/ok"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:text="OK">
- <requestFocus/>
- </Button>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:text="Login :"
+ android:minWidth="90dp" android:textSize="14sp" />
+ <EditText android:id="@+id/proxy_login"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:singleLine="true" android:textSize="14sp" android:autoText="false"
+ android:capitalize="none" android:scrollHorizontally="true" />
+ </LinearLayout>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:text="Password:"
+ android:minWidth="90dp" android:textSize="14sp" />
+ <EditText android:id="@+id/proxy_pwd" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:singleLine="true"
+ android:password="true" android:textSize="14sp" android:autoText="false"
+ android:capitalize="none" android:scrollHorizontally="true" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <Button android:id="@+id/ok" android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
+ android:text="OK">
+ <requestFocus />
+ </Button>
+
</LinearLayout>
\ No newline at end of file
--- a/res/values/strings.xml Tue Apr 21 19:06:38 2009 +0200
+++ b/res/values/strings.xml Wed Apr 22 00:25:01 2009 +0200
@@ -22,7 +22,9 @@
<string name="PreferenceFileName">Beem</string>
<string name="PreferenceHostKey">host</string>
- <string name="PreferenceJID">Jabber ID</string><string name="PreferenceLoginKey">login</string><string name="PreferencePasswordKey">password</string>
+ <string name="PreferenceJID">Jabber ID</string>
+ <string name="PreferenceLoginKey">login</string>
+ <string name="PreferencePasswordKey">password</string>
<string name="PreferencePortKey">port</string>
<string name="PreferenceProxyHost">proxy_host</string>
<string name="PreferenceProxyPort">proxy_port</string>
@@ -30,6 +32,7 @@
<string name="PreferenceProxyType">proxy_type</string>
<string name="PreferenceProxyUser">proxy_user</string>
<string name="PreferenceProxyPassword">proxy_password</string>
+ <string name="PreferenceProxyTypeNone">None</string>
<string name="PreferenceProxyTypeHttp">HTTP</string>
<string name="PreferenceProxyTypeSocks4">SOCKS4</string>
<string name="PreferenceProxyTypeSocks5">SOCKS5</string>
--- a/src/com/beem/project/beem/ui/ContactListSettings.java Tue Apr 21 19:06:38 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactListSettings.java Wed Apr 22 00:25:01 2009 +0200
@@ -1,63 +1,124 @@
package com.beem.project.beem.ui;
import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
-import android.util.Log;
import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.widget.AdapterView.OnItemSelectedListener;
import com.beem.project.beem.R;
public class ContactListSettings extends Activity {
public static final int CHANGE = 1;
+ private boolean mIsChanged = false;
private SharedPreferences mSettings;
+ private String[] mProxyTypeString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contactlistsettings);
- mSettings = getSharedPreferences(
- getString(R.string.PreferenceFileName), MODE_PRIVATE);
+
+ String TypeNone = getString(R.string.PreferenceProxyTypeNone);
+ String TypeHTTP = getString(R.string.PreferenceProxyTypeHttp);
+ String TypeSocks4 = getString(R.string.PreferenceProxyTypeSocks4);
+ String TypeSocks5 = getString(R.string.PreferenceProxyTypeSocks5);
+
+ mProxyTypeString = new String[] { TypeNone, TypeHTTP, TypeSocks4, TypeSocks5 };
+ mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+
+ Spinner sp = (Spinner) findViewById(R.id.proxy_type);
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
+ mProxyTypeString);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ sp.setAdapter(adapter);
+ for (int i = 0; i < mProxyTypeString.length; ++i)
+ if (mProxyTypeString[i].equals(getPreferenceString(R.string.PreferenceProxyType)))
+ sp.setSelection(i);
+ sp.setOnItemSelectedListener(mProxyType);
+
showSettings();
Button ok = (Button) findViewById(R.id.ok);
ok.setOnClickListener(mOkListener);
}
+ private OnItemSelectedListener mProxyType = new OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
+ String value = parent.getSelectedItem().toString();
+ LinearLayout ll = (LinearLayout) findViewById(R.id.proxy_layout);
+ SharedPreferences.Editor editor = mSettings.edit();
+
+ if (value.equals(getString(R.string.PreferenceProxyTypeNone))) {
+ ll.setVisibility(LinearLayout.INVISIBLE);
+ editor.putBoolean(getString(R.string.PreferenceUseProxy), false);
+ } else {
+ ll.setVisibility(LinearLayout.VISIBLE);
+ editor.putBoolean(getString(R.string.PreferenceUseProxy), true);
+ }
+ if (!value.equals(getPreferenceString(R.string.PreferenceProxyType))) {
+ editor.putString(getString(R.string.PreferenceProxyType), value);
+ mIsChanged = true;
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ }
+
+ };
+
private OnClickListener mOkListener = new OnClickListener() {
public void onClick(View v) {
- boolean b = false;
SharedPreferences.Editor editor = mSettings.edit();
if (isChanged(R.id.host, R.string.PreferenceHostKey)) {
- editor.putString(
- getString(R.string.PreferenceHostKey),
- getWidgetText(R.id.host));
- b = true;
+ editor.putString(getString(R.string.PreferenceHostKey), getWidgetText(R.id.host));
+ mIsChanged = true;
}
if (isChanged(R.id.port, R.string.PreferencePortKey)) {
- editor.putString(
- getString(R.string.PreferencePortKey),
- getWidgetText(R.id.port));
- b = true;
+ editor.putString(getString(R.string.PreferencePortKey), getWidgetText(R.id.port));
+ mIsChanged = true;
}
if (isChanged(R.id.userid, R.string.PreferenceLoginKey)) {
- editor.putString(
- getString(R.string.PreferenceLoginKey),
- getWidgetText(R.id.userid));
- b = true;
+ editor.putString(getString(R.string.PreferenceLoginKey), getWidgetText(R.id.userid));
+ mIsChanged = true;
}
if (isChanged(R.id.password, R.string.PreferencePasswordKey)) {
- editor.putString(
- getString(R.string.PreferencePasswordKey),
- getWidgetText(R.id.password));
- b = true;
+ editor.putString(getString(R.string.PreferencePasswordKey), getWidgetText(R.id.password));
+ mIsChanged = true;
}
- if (b == true) {
+ if (isChanged(R.id.proxy_host, R.string.PreferenceProxyHost)) {
+ editor.putString(getString(R.string.PreferenceProxyHost), getWidgetText(R.id.proxy_host));
+ mIsChanged = true;
+ }
+ if (isChanged(R.id.proxy_port, R.string.PreferenceProxyPort)) {
+ editor.putString(getString(R.string.PreferenceProxyPort), getWidgetText(R.id.proxy_port));
+ mIsChanged = true;
+ }
+ if (isChanged(R.id.proxy_login, R.string.PreferenceProxyUser)) {
+ editor.putString(getString(R.string.PreferenceProxyUser), getWidgetText(R.id.proxy_login));
+ mIsChanged = true;
+ }
+ if (isChanged(R.id.proxy_pwd, R.string.PreferenceProxyPassword)) {
+ editor.putString(getString(R.string.PreferenceProxyPassword), getWidgetText(R.id.proxy_pwd));
+ mIsChanged = true;
+ }
+
+ if (mIsChanged == true) {
editor.commit();
setResult(RESULT_OK);
} else
@@ -79,6 +140,15 @@
e.setText(getPreferenceString(R.string.PreferenceLoginKey));
e = (EditText) findViewById(R.id.password);
e.setText(getPreferenceString(R.string.PreferencePasswordKey));
+
+ e = (EditText) findViewById(R.id.proxy_host);
+ e.setText(getPreferenceString(R.string.PreferenceProxyHost));
+ e = (EditText) findViewById(R.id.proxy_port);
+ e.setText(getPreferenceString(R.string.PreferenceProxyPort));
+ e = (EditText) findViewById(R.id.proxy_login);
+ e.setText(getPreferenceString(R.string.PreferenceProxyUser));
+ e = (EditText) findViewById(R.id.proxy_pwd);
+ e.setText(getPreferenceString(R.string.PreferenceProxyPassword));
}
private String getWidgetText(int id) {