Modification de la liste de contact pour qu'elle se reconnecte comme il
authormarseille
Fri, 24 Apr 2009 00:55:18 +0200
changeset 165 6e008c3695ff
parent 162 72bfb4fe5815 (current diff)
parent 164 ff0f63e92986 (diff)
child 166 d076437706a4
Modification de la liste de contact pour qu'elle se reconnecte comme il faut.
src/com/beem/project/beem/BeemApplication.java
src/com/beem/project/beem/ui/ContactList.java
src/com/beem/project/beem/ui/ContactListSettings.java
--- a/AndroidManifest.xml	Fri Apr 24 00:32:21 2009 +0200
+++ b/AndroidManifest.xml	Fri Apr 24 00:55:18 2009 +0200
@@ -30,4 +30,5 @@
 	<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
 	<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"></uses-permission>
 	<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
+<uses-sdk android:minSdkVersion="2"></uses-sdk>
 </manifest> 
--- a/src/com/beem/project/beem/BeemApplication.java	Fri Apr 24 00:32:21 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java	Fri Apr 24 00:55:18 2009 +0200
@@ -102,7 +102,7 @@
 	mBeemApp.mActivity = activity;
 	mBeemApp.mProgressDialog = new ProgressDialog(activity);
 	mBeemApp.mProgressDialog.setTitle("Beem");
-	mBeemApp.mProgressDialog.setIcon(R.drawable.barthe_f);
+	mBeemApp.mProgressDialog.setIcon(R.drawable.signal);
 	mBeemApp.mProgressDialog.setMessage("Connecting...");
 	mBeemApp.mApplicationContext = activity.getApplication();
 	mBeemApp.mPrivateResources = activity.getResources();
--- a/src/com/beem/project/beem/BeemService.java	Fri Apr 24 00:32:21 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Fri Apr 24 00:55:18 2009 +0200
@@ -49,6 +49,7 @@
     private String mLogin;
     private String mPassword;
     private String mHost;
+    private int mPort;
     private ConnectionConfiguration mConnectionConfiguration;
     private ProxyInfo mProxyInfo;
     private boolean mUseProxy;
@@ -81,8 +82,10 @@
 	mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), "");
 	mPassword = mSettings.getString(getString(R.string.PreferencePasswordKey), "");
 	mHost = mSettings.getString(getString(R.string.PreferenceHostKey), "");
+	mPort = mSettings.getInt(getString(R.string.PreferencePortKey), 5222);
+	
 	// TODO penser a commenter
-	//mHost = "10.0.2.2";
+	// mHost = "10.0.2.2";
 	initConnectionConfig();
 	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 	mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
@@ -136,9 +139,9 @@
 	    int pport =  mSettings.getInt(getString(R.string.PreferenceProxyPort), 1080);
 	    ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
 	    mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass);
-	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mProxyInfo);
+	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mProxyInfo);
 	} else {
-	    mConnectionConfiguration = new ConnectionConfiguration(mHost);
+	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort);
 	}
 	mConnectionConfiguration.setDebuggerEnabled(false);
 	mConnectionConfiguration.setSendPresence(true);
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 24 00:32:21 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 24 00:55:18 2009 +0200
@@ -65,6 +65,18 @@
 	mRosterListener = new BeemRosterListener();
 	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
 	mBeemApplication.startBeemService();
+
+	// bug fixe temporaire des betises de marseille
+	/*
+	 * SharedPreferences mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	 * SharedPreferences.Editor editor = mSettings.edit(); editor.putInt(getString(R.string.PreferencePortKey),
+	 * 5222); editor.commit();
+	 */
+    }
+    
+    @Override
+    protected void onResume() {
+	super.onResume();
 	mBeemApplication.callWhenConnectedToServer(new Handler(), new Runnable() {
 	    @Override
 	    public void run() {
@@ -147,22 +159,13 @@
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 	if (requestCode == PREFERENCECHANGED) {
 	    if (resultCode == RESULT_OK) {
-		/*
-		List<String> tmp = new ArrayList<String>();
-		tmp.add("");
-		List<Contact> tmpC = new ArrayList<Contact>();
-		tmpC.add(new Contact());
-		showContactList(tmp, tmpC);
-		*/
-		setContentView(R.layout.changestatus);
+		setListAdapter(null);
 		mBeemApplication.stopBeemService();
 		mBeemApplication.startBeemService();
-		//callbackShowContactList();
 	    }
 	}
     }
 
-
     private void showContactList(List<String> listGroup, List<Contact> listContact) {
 	ExpandableListAdapter Adapter;
 	List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
--- a/src/com/beem/project/beem/ui/ContactListSettings.java	Fri Apr 24 00:32:21 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactListSettings.java	Fri Apr 24 00:55:18 2009 +0200
@@ -103,8 +103,8 @@
 		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));
+	    if (Integer.parseInt(getWidgetText(R.id.port)) != mSettings.getInt(getString(R.string.PreferencePortKey), 5222) ) {
+		editor.putInt(getString(R.string.PreferencePortKey), Integer.parseInt(getWidgetText(R.id.port)));
 		mIsChanged = true;
 	    }
 	    if (isChanged(R.id.userid, R.string.PreferenceLoginKey)) {
@@ -152,7 +152,7 @@
 	EditText e = (EditText) findViewById(R.id.host);
 	e.setText(getPreferenceString(R.string.PreferenceHostKey));
 	e = (EditText) findViewById(R.id.port);
-	e.setText(getPreferenceString(R.string.PreferencePortKey));
+	e.setText(String.valueOf(mSettings.getInt(getString(R.string.PreferencePortKey), 1080)));
 	e = (EditText) findViewById(R.id.userid);
 	e.setText(getPreferenceString(R.string.PreferenceLoginKey));
 	e = (EditText) findViewById(R.id.password);