changement de la gestion des settings.
pleins de trucs a traduire dedans.
--- a/.classpath Sat Sep 26 01:15:19 2009 +0200
+++ b/.classpath Sat Sep 26 20:19:07 2009 +0200
@@ -2,17 +2,17 @@
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/smackx-debug.jar"/>
- <classpathentry kind="lib" path="libs/smackx-jingle.jar" sourcepath="/home/darisk/devel/smack_src_3_1_0/jingle/extension/source"/>
+ <classpathentry kind="lib" path="libs/smackx-jingle.jar"/>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/security.jar"/>
- <classpathentry kind="lib" path="libs/smack.jar"/>
- <classpathentry kind="lib" path="libs/smackx.jar"/>
+ <classpathentry kind="lib" path="libs/smack.jar" sourcepath="/home/nikita/devel/smack"/>
+ <classpathentry kind="lib" path="libs/smackx.jar" sourcepath="/home/nikita/devel/smack"/>
<classpathentry kind="lib" path="libs/jlibrtp.jar"/>
- <classpathentry kind="src" path="src"/>
+ <classpathentry excluding="com/beem/project/beem/ui/pref.java" kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
--- a/AndroidManifest.xml Sat Sep 26 01:15:19 2009 +0200
+++ b/AndroidManifest.xml Sat Sep 26 20:19:07 2009 +0200
@@ -15,6 +15,12 @@
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
</intent-filter>
</activity>
+ <activity android:name=".ui.Settings" android:label="@string/edit_settings_name">
+ <intent-filter android:label="Beem Connection">
+ <action
+ android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ </intent-filter>
+ </activity>
<activity android:name=".ui.SendIM" android:label="@string/SendIMActTitle"
android:launchMode="singleTop">
<intent-filter android:label="Beem Connection">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/preferences.xml Sat Sep 26 20:19:07 2009 +0200
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shouldDisableView="true" android:selectable="true">
+ <EditTextPreference android:summary="Permet de modifier votre identifiant de connexion"
+ android:title="@string/settings_account_username" android:key="settings_key_account_username" />
+ <EditTextPreference android:name="password"
+ android:password="true" android:summary="Permet de modifier votre mot de passe de connexion"
+ android:title="@string/settings_account_password" android:key="settings_key_account_password" />
+ <CheckBoxPreference android:title="Utilisation de Gmail"
+ android:defaultValue="false"
+ android:summary="Cochez cette case si vous souhaitez utiliser votre compte Gmail"
+ android:key="settings_key_gmail" />
+ <PreferenceScreen android:key="proxy" android:title="Utilisation d'un proxy">
+ <CheckBoxPreference android:title="Utilisation d'un serveur proxy"
+ android:defaultValue="false"
+ android:summary="Cochez cette case si vous souhaitez utiliser un serveur proxy"
+ android:key="settings_key_proxy_use" />
+ <ListPreference android:dependency="settings_key_proxy_use"
+ android:title="Type du serveur proxy utilisé" android:entries="@array/proxy_types"
+ android:summary="Permet de choisir le type de serveur proxy à utiliser"
+ android:defaultValue="HTTP"
+ android:entryValues="@array/proxy_types" android:key="settings_key_proxy_type" />
+ <EditTextPreference android:dependency="settings_key_proxy_use"
+ android:name="serveur" android:summary="Définition de l'adresse du serveur."
+ android:title="@string/settings_proxy_server" android:key="settings_key_proxy_server" />
+ <EditTextPreference android:dependency="settings_key_proxy_use"
+ android:name="port" android:summary="Définition du port du serveur."
+ android:title="@string/settings_proxy_port" android:key="settings_key_proxy_port" />
+ <EditTextPreference android:dependency="settings_key_proxy_use"
+ android:name="Utilisateur"
+ android:summary="Optionnel, permet de s'authentifier sur le serveur proxy"
+ android:title="@string/settings_proxy_username" android:key="settings_key_proxy_username" />
+ <EditTextPreference android:dependency="settings_key_proxy_use"
+ android:name="pass_user" android:password="true"
+ android:summary="Optionnel, permet de s'authentifier sur le serveur proxy"
+ android:title="@string/settings_proxy_password" android:key="settings_key_proxy_password" />
+ </PreferenceScreen>
+
+ <PreferenceScreen android:key="advanced"
+ android:title="Options avancées">
+ <CheckBoxPreference android:title="@string/settings_xmpp_use_tls"
+ android:defaultValue="false" android:key="settings_key_xmpp_tls_use" />
+ <CheckBoxPreference android:title="Utilisation des options spécifiques du serveur"
+ android:defaultValue="false"
+ android:summary="Cochez cette case si vous souhaitez utiliser des options spécifiques pour votre serveur XMPP"
+ android:key="useSpecificServer" />
+ <EditTextPreference android:dependency="useSpecificServer"
+ android:name="adresse" android:summary="Permet d'éditer l'adresse du serveur"
+ android:title="@string/settings_xmpp_server" android:key="settings_key_xmpp_server"
+ android:defaultValue="10.0.2.2" />
+ <EditTextPreference android:id="@+id/settings_xmpp_port"
+ android:dependency="useSpecificServer" android:name="port"
+ android:summary="Permet d'éditer le port du serveur" android:title="@string/settings_xmpp_port"
+ android:defaultValue="5222" android:key="settings_key_xmpp_port" />
+ </PreferenceScreen>
+</PreferenceScreen>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java Sat Sep 26 01:15:19 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java Sat Sep 26 20:19:07 2009 +0200
@@ -17,8 +17,8 @@
import android.content.SharedPreferences.Editor;
import android.os.IBinder;
import android.os.RemoteException;
+import android.preference.PreferenceManager;
import android.util.Log;
-import android.widget.ArrayAdapter;
import com.beem.project.beem.jingle.JingleService;
import com.beem.project.beem.service.XmppConnectionAdapter;
@@ -62,16 +62,13 @@
*/
private void initConnectionConfig() {
java.security.Security.addProvider(new com.sun.security.sasl.Provider());
- mUseProxy = mSettings.getBoolean(getString(R.string.settings_key_proxy_use), false);
+ mUseProxy = mSettings.getBoolean("settings_key_proxy_use", false);
if (mUseProxy) {
- ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.proxy_types,
- android.R.layout.simple_spinner_item);
- int pos = mSettings.getInt(getString(R.string.settings_key_proxy_type), 0);
- String stype = adapter.getItem(pos).toString();
- String phost = mSettings.getString(getString(R.string.settings_key_proxy_server), "");
- String puser = mSettings.getString(getString(R.string.settings_key_proxy_username), "");
- String ppass = mSettings.getString(getString(R.string.settings_key_proxy_password), "");
- int pport = Integer.parseInt(mSettings.getString(getString(R.string.settings_key_proxy_port), "1080"));
+ String stype = mSettings.getString("settings_key_proxy_type", "HTTP");
+ String phost = mSettings.getString("settings_key_proxy_server", "");
+ String puser = mSettings.getString("settings_key_proxy_username", "");
+ String ppass = mSettings.getString("settings_key_proxy_password", "");
+ int pport = Integer.parseInt(mSettings.getString("settings_key_proxy_port", "1080"));
ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass);
if (mService != null)
@@ -84,7 +81,7 @@
else
mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort);
}
- if (mSettings.getBoolean(getString(R.string.settings_key_xmpp_tls_use), false)) {
+ if (mSettings.getBoolean("settings_key_xmpp_tls_use", false)) {
mConnectionConfiguration.setSecurityMode(SecurityMode.required);
}
mConnectionConfiguration.setDebuggerEnabled(false);
@@ -107,21 +104,19 @@
public void onCreate() {
super.onCreate();
- mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
- mLogin = mSettings.getString(getString(R.string.settings_key_account_username), "");
- mPassword = mSettings.getString(getString(R.string.settings_key_account_password), "");
- mHost = mSettings.getString(getString(R.string.settings_key_xmpp_server), "");
- mPort = Integer.parseInt(mSettings.getString(getString(R.string.settings_key_xmpp_port), "5222"));
+ mSettings = PreferenceManager.getDefaultSharedPreferences(this);
+ mLogin = mSettings.getString("settings_key_account_username", "");
+ mPassword = mSettings.getString("settings_key_account_password", "");
+ mHost = mSettings.getString("settings_key_xmpp_server", "");
+ mPort = Integer.parseInt(mSettings.getString("settings_key_xmpp_port", "5222"));
+ mService = StringUtils.parseServer(mLogin);
- /*
- * Gestion pour gmail.
- */
- if ("".equals(mHost)) {
- mHost = StringUtils.parseServer(mLogin);
+ if (mSettings.getBoolean("settings_key_gmail", false)) {
+ mHost = "talk.google.com";
mService = null;
mLogin = StringUtils.parseName(mLogin);
- } else
- mService = StringUtils.parseServer(mLogin);
+ }
+
initConnectionConfig();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
--- a/src/com/beem/project/beem/ui/AddContact.java Sat Sep 26 01:15:19 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java Sat Sep 26 20:19:07 2009 +0200
@@ -31,13 +31,13 @@
*/
public class AddContact extends Activity {
+ private static final Intent SERVICE_INTENT = new Intent();
private static final String TAG = "AddContact";
private final List<String> mGroup = new ArrayList<String>();
private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
private BroadcastReceiver mReceiver;
- private static final Intent SERVICE_INTENT = new Intent();
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
}
@@ -67,7 +67,7 @@
super.onStop();
unbindService(mServConn);
}
-
+
/**
* {@inheritDoc}
*/
@@ -77,7 +77,7 @@
this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
}
-
+
/**
* {@inheritDoc}
*/
--- a/src/com/beem/project/beem/ui/ContactList.java Sat Sep 26 01:15:19 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Sat Sep 26 20:19:07 2009 +0200
@@ -36,7 +36,6 @@
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
-import com.beem.project.beem.BeemService;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
import com.beem.project.beem.service.PresenceAdapter;
@@ -53,6 +52,7 @@
public class ContactList extends Activity {
//private static final String TAG = "CONTACTLIST_ACT";
+ private static final Intent SERVICE_INTENT = new Intent();
private static final int REQUEST_CODE = 1;
private BeemContactList mAdapterContactList;
private BeemBanner mAdapterBanner;
@@ -66,7 +66,6 @@
private final ServiceConnection mServConn = new BeemServiceConnection();
private BroadcastReceiver mReceiver;
- private static final Intent SERVICE_INTENT = new Intent();
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
}
@@ -131,7 +130,7 @@
public final boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.contact_list_menu_settings:
- startActivityForResult(new Intent(this, EditSettings.class), REQUEST_CODE);
+ startActivityForResult(new Intent(this, Settings.class), REQUEST_CODE);
return true;
case R.id.contact_list_menu_add_contact:
startActivity(new Intent(ContactList.this, AddContact.class));
@@ -146,6 +145,7 @@
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE) {
if (resultCode == 69) {
+ stopService(SERVICE_INTENT);
finish();
startActivity(new Intent(this, Login.class));
}
@@ -158,7 +158,7 @@
@Override
protected void onStart() {
super.onStart();
- bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+ bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
}
/**
@@ -217,8 +217,6 @@
/**
* Contact List construction.
- * @param listContact Contact list.
- * @param listGroup Group list.
*/
private void buildContactList() {
if (mCurGroup != null) {
@@ -231,6 +229,9 @@
listView.setAdapter(mAdapterContactList);
}
+ /**
+ * buildBanner.
+ */
private void buildBanner() {
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setOnItemClickListener(new OnItemClickGroupName());
@@ -289,6 +290,12 @@
*/
private class OnItemClickGroupName implements OnItemClickListener {
+ /**
+ * Constructor.
+ */
+ public OnItemClickGroupName() {
+ }
+
@Override
public void onItemClick(AdapterView<?> arg0, View v, int i, long l) {
mCurGroup = mListGroup.get(i);
@@ -512,7 +519,7 @@
break;
default:
imageDrawable = getResources().getDrawable(R.drawable.error);
- break;
+ break;
}
imgV.setImageDrawable(imageDrawable);
--- a/src/com/beem/project/beem/ui/Login.java Sat Sep 26 01:15:19 2009 +0200
+++ b/src/com/beem/project/beem/ui/Login.java Sat Sep 26 20:19:07 2009 +0200
@@ -12,6 +12,7 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
+import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -32,6 +33,7 @@
public class Login extends Activity {
private static final String TAG = "LOG_AS";
+ private static final int REQUEST_CODE = 1;
private static final Intent SERVICE_INTENT = new Intent();
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -75,11 +77,24 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
+ mSettings = PreferenceManager.getDefaultSharedPreferences(this);
setContentView(R.layout.login);
mProgressDialog = new ProgressDialog(this);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == REQUEST_CODE) {
+ if (resultCode == 69) {
+ stopService(SERVICE_INTENT);
+ }
+ }
+ }
+
@Override
protected void onDestroy() {
super.onDestroy();
@@ -94,11 +109,9 @@
@Override
public void onStart() {
super.onStart();
- mIsConfigured = mSettings.getBoolean(getString(R.string.PreferenceIsConfigured), false);
-
+ mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
if (mIsConfigured)
bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
-
}
/**
@@ -121,7 +134,7 @@
public final boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.login_menu_settings:
- startActivity(new Intent(Login.this, EditSettings.class));
+ startActivity(new Intent(Login.this, Settings.class));
return true;
case R.id.login_menu_about:
createAboutDialog();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/Settings.java Sat Sep 26 20:19:07 2009 +0200
@@ -0,0 +1,127 @@
+package com.beem.project.beem.ui;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.XmppConnectionAdapter;
+
+/**
+ * This class represents an activity which allows the user to change his account or proxy parameters.
+ * @author nikita
+ */
+public class Settings extends PreferenceActivity {
+
+ private static final Intent SERVICE_INTENT = new Intent();
+ private BeemBroadcastReceiver mReceiver;
+
+ static {
+ SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+ }
+
+ /**
+ * Constructor.
+ */
+ public Settings() {
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.layout.preferences);
+ mReceiver = new BeemBroadcastReceiver();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onPause() {
+ super.onPause();
+ this.unregisterReceiver(mReceiver);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onResume() {
+ super.onResume();
+ this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStop() {
+ super.onStop();
+ SharedPreferences settings = getPreferenceManager().getSharedPreferences();
+ settings.edit().putBoolean("PreferenceIsConfigured",
+ !"".equals(settings.getString("settings_key_account_username", ""))
+ || !"".equals(settings.getString("settings_key_account_password", ""))).commit();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater mInflater = getMenuInflater();
+ mInflater.inflate(R.menu.edit_settings, menu);
+ return true;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ Intent i = null;
+ switch (item.getItemId()) {
+ case R.id.settings_menu_create_account:
+ i = new Intent(this, CreateAccount.class);
+ startActivity(i);
+ return true;
+ case R.id.settings_menu_login:
+ setResult(69);
+ SharedPreferences settings = getPreferenceManager().getSharedPreferences();
+ settings.edit().putBoolean("PreferenceIsConfigured",
+ !"".equals(settings.getString("settings_key_account_username", ""))
+ || !"".equals(settings.getString("settings_key_account_password", ""))).commit();
+ this.stopService(SERVICE_INTENT);
+ finish();
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * disconnect Broadcast receiver.
+ */
+ private class BeemBroadcastReceiver extends BroadcastReceiver {
+
+ /**
+ * Constructor.
+ */
+ public BeemBroadcastReceiver() {
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Settings.this.setResult(69);
+ }
+ }
+}