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 (diff)
parent 164 ff0f63e92986 (current 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
Binary file res/drawable/away.png has changed
Binary file res/drawable/buddie_robot.png has changed
Binary file res/drawable/chat.png has changed
Binary file res/drawable/connecting.png has changed
Binary file res/drawable/dnd.png has changed
Binary file res/drawable/error.png has changed
Binary file res/drawable/invisible.png has changed
Binary file res/drawable/logo.jpg has changed
Binary file res/drawable/message.png has changed
Binary file res/drawable/online.png has changed
Binary file res/drawable/requested.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/drawable/scrollbar_vertical_thumb.xml	Fri Apr 24 00:55:18 2009 +0200
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+  
+          http://www.apache.org/licenses/LICENSE-2.0
+  
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <gradient android:startColor="#3333FF" android:endColor="#8080FF"
+            android:angle="0"/>
+    <corners android:radius="6dp" />
+</shape>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/drawable/scrollbar_vertical_track.xml	Fri Apr 24 00:55:18 2009 +0200
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+  
+          http://www.apache.org/licenses/LICENSE-2.0
+  
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <gradient android:startColor="#505050" android:endColor="#C0C0C0"
+            android:angle="0"/>
+    <corners android:radius="0dp" />
+</shape>
Binary file res/drawable/xmpp.jpg has changed
Binary file res/drawable/xmpp.png has changed
--- a/res/layout/contactlistcontact.xml	Thu Apr 23 22:33:20 2009 +0200
+++ b/res/layout/contactlistcontact.xml	Fri Apr 24 00:55:18 2009 +0200
@@ -9,8 +9,10 @@
         android:gravity="center_vertical" >
 
         <ImageView android:id="@+id/contactliststatus"
-        	android:layout_weight="5"
-        	android:layout_width="fill_parent"
+        	android:adjustViewBounds="true"
+            android:maxWidth="15dip"
+            android:maxHeight="15dip"
+        	android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:gravity="center_vertical" />
 
@@ -30,8 +32,11 @@
 		</LinearLayout>
 
         <ImageView android:id="@+id/contactlistavatar"
-        	android:layout_weight="5"
-        	android:layout_width="fill_parent"
+        	android:adjustViewBounds="true"
+            android:maxWidth="50dip"
+            android:maxHeight="50dip"
+            android:padding="1dip"
+        	android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:gravity="center_vertical" />
             
--- a/res/layout/sendim.xml	Thu Apr 23 22:33:20 2009 +0200
+++ b/res/layout/sendim.xml	Fri Apr 24 00:55:18 2009 +0200
@@ -7,31 +7,35 @@
         android:orientation="horizontal"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        android:paddingLeft="10px"
-        android:paddingRight="10px"
         android:background="@drawable/beem_sendim_header_1"
         android:gravity="center_vertical" >
 
-        <ImageView android:id="@+id/sendimavatar"
-        	android:layout_weight="5"
-        	android:layout_width="fill_parent"
+        <ImageView
+        	android:id="@+id/sendimavatar"
+        	android:src="@drawable/avatar"
+        	android:adjustViewBounds="true"
+        	android:maxWidth="70dip"
+            android:maxHeight="70dip"
+            android:padding="10dip"
+        	android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:gravity="center_vertical" />
+             />
 
 		<LinearLayout
 			android:orientation="vertical"
-			android:layout_weight="1"
         	android:layout_width="fill_parent"
         	android:layout_height="wrap_content" >
         	<TextView android:id="@+id/sendimlogin"
 				android:layout_width="fill_parent"
             	android:layout_height="wrap_content"            	
-            	android:paddingLeft="20sp" />
+            	android:paddingLeft="10sp" />
 			<TextView android:id="@+id/sendimstatus"
 				android:layout_width="fill_parent"
             	android:layout_height="wrap_content"
+            	android:lines="1"
+            	android:scrollHorizontally="true"
             	android:hint="@string/SendIMNoStatusSet"
-            	android:paddingLeft="20sp" />
+            	android:paddingLeft="15sp" />
 		</LinearLayout>
 </LinearLayout>
 
@@ -76,6 +80,9 @@
 		android:layout_width="fill_parent"
 		android:layout_height="fill_parent"
 		android:background="@drawable/beem_sendim_textview"
+		android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track"
+	    android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
+	    android:scrollbarSize="12dip"
 		android:layout_weight="1">
 		
 		<TextView android:id="@+id/sendimlist"
--- a/res/menu/contactlistmenu.xml	Thu Apr 23 22:33:20 2009 +0200
+++ b/res/menu/contactlistmenu.xml	Fri Apr 24 00:55:18 2009 +0200
@@ -1,6 +1,6 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
 	<item android:title="@string/MenuConnection" android:id="@+id/account_edit" android:icon="@drawable/xmpp"/>
-	<item android:title="@string/MenuAddContact" android:id="@+id/add_contact" />
+	<item android:title="@string/MenuAddContact" android:id="@+id/add_contact" android:icon="@drawable/buddie_robot"/>
 	<item android:title="@string/MenuAccountAbout" android:id="@+id/account_about"/>
 	<item android:title="@string/MenuAccountCreate" android:id="@+id/account_create"/>
 </menu>
--- a/src/com/beem/project/beem/BeemApplication.java	Thu Apr 23 22:33:20 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java	Fri Apr 24 00:55:18 2009 +0200
@@ -5,6 +5,7 @@
 
 import java.util.LinkedList;
 import java.util.List;
+
 import android.app.Activity;
 import android.app.Application;
 import android.app.ProgressDialog;
@@ -18,9 +19,13 @@
 import android.os.Message;
 import android.os.RemoteException;
 import android.util.Log;
+import android.widget.Toast;
+
 import com.beem.project.beem.service.aidl.IBeemConnectionListener;
 import com.beem.project.beem.service.aidl.IXmppConnection;
 import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.ui.AddContact;
+import com.beem.project.beem.ui.ContactList;
 import com.beem.project.beem.utils.Status;
 
 /**
@@ -61,7 +66,6 @@
 	    try {
 		mConnection = mFacade.createConnection();
 		if (!mConnection.isAuthentificated()) {
-		    mProgressDialog.show();
 		    mConnection.addConnectionListener(mConnectionListener);
 		    mApplicationContext.startService(BeemApplication.SERVICE_INTENT);
 		}else {
@@ -111,6 +115,8 @@
      */
     public synchronized void startBeemService() {
 	if (!mIsConnected) {
+	    mProgressDialog.setMessage("Connecting...");
+	    mProgressDialog.show();
 	    // the connection will be made on service connect
 	    mApplicationContext.bindService(BeemApplication.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
 	}
@@ -207,7 +213,6 @@
 	 * Constructor.
 	 */
 	public ConnectionListener() {
-
 	}
 
 	/**
@@ -215,9 +220,7 @@
 	 */
 	@Override
 	public void connectionClosed() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    Log.e("BeemApp", "test1");
-
+	    Log.e(TAG, "Connection Close");
 	}
 
 	/**
@@ -252,8 +255,6 @@
 	 */
 	@Override
 	public void reconnectingIn(int seconds) throws RemoteException {
-	    // TODO Auto-generated method stub
-	    mProgressDialog.show();
 	}
 
 	/**
@@ -261,9 +262,6 @@
 	 */
 	@Override
 	public void reconnectionFailed() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    Log.e("BeemApp", "test3");
-
 	}
 
 	/**
@@ -271,8 +269,6 @@
 	 */
 	@Override
 	public void reconnectionSuccessful() throws RemoteException {
-	    // TODO Auto-generated method stub
-
 	}
 
 	@Override
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Thu Apr 23 22:33:20 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Fri Apr 24 00:55:18 2009 +0200
@@ -88,7 +88,10 @@
 	    return true;
 	} catch (XMPPException e) {
 	    Log.e(TAG, "Error while connecting", e);
-	    mConListener.connectionFailed(e.getXMPPError().getMessage()); //
+	    if (e.getXMPPError() != null)
+		mConListener.connectionFailed(e.getXMPPError().getMessage()); //
+	    else
+		mConListener.connectionFailed("Error On Connection");
 	}
 	return false;
     }
--- a/src/com/beem/project/beem/ui/ChangeStatus.java	Thu Apr 23 22:33:20 2009 +0200
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java	Fri Apr 24 00:55:18 2009 +0200
@@ -1,16 +1,14 @@
 package com.beem.project.beem.ui;
 
 import android.app.Activity;
-
+import android.content.Context;
 import android.content.Intent;
-
-import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
-
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.RemoteException;
+import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.ArrayAdapter;
@@ -22,7 +20,6 @@
 import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.BeemService;
 import com.beem.project.beem.R;
-
 import com.beem.project.beem.service.aidl.IXmppFacade;
 import com.beem.project.beem.utils.Status;
 
@@ -44,18 +41,20 @@
     private static final int UNAVAILABLE_IDX = 4;
     private SharedPreferences mSettings;
     private ArrayAdapter<String> mAdapter;
-    private Context mContext = this;
     private Toast mToast;
+    private static Integer nb = 0;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
 	super.onCreate(savedInstanceState);
-	setContentView(R.layout.changestatus);
-
+	
+	nb++;
+	Log.i("nb de oncreate changestatus", nb.toString());
 	// Beem Application specific
 	mHandler = new Handler();
 	mBeemApplication = BeemApplication.getApplication(this);
-
+	
+	setContentView(R.layout.changestatus);
 	mStatusText = (TextView) findViewById(R.id.ChangeStatusText);
 	mOk = (Button) findViewById(R.id.ChangeStatusOk);
 	mClear = (Button) findViewById(R.id.ChangeStatusClear);
@@ -67,7 +66,7 @@
 	mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, STATUS);
 	mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 	mSpinner.setAdapter(mAdapter);
-	mToast = Toast.makeText(mContext, R.string.ChangeStatusOk, Toast.LENGTH_LONG);
+	mToast = Toast.makeText(this, R.string.ChangeStatusOk, Toast.LENGTH_LONG);
 	showSettings();
     }
 
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Apr 23 22:33:20 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 24 00:55:18 2009 +0200
@@ -44,6 +44,7 @@
     private IXmppFacade mService = null;
     private BeemApplication mBeemApplication;
     private BeemRosterListener mRosterListener;
+    private SharedPreferences mSettings;
     private IRoster mRoster;
 
     @SuppressWarnings("unchecked")
@@ -62,7 +63,20 @@
 	super.onCreate(saveBundle);
 	mBeemApplication = BeemApplication.getApplication(this);
 	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() {
@@ -82,14 +96,6 @@
 		callbackShowContactList();
 	    }
 	});
-
-	// 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
@@ -153,19 +159,13 @@
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 	if (requestCode == PREFERENCECHANGED) {
 	    if (resultCode == RESULT_OK) {
+		setListAdapter(null);
 		mBeemApplication.stopBeemService();
 		mBeemApplication.startBeemService();
 	    }
 	}
     }
 
-    private boolean isStatusOK(int status) {
-	if (status == Status.CONTACT_STATUS_AVAILABLE || status == Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT
-	    || status == Status.CONTACT_STATUS_AWAY || status == Status.CONTACT_STATUS_BUSY)
-	    return true;
-	return false;
-    }
-
     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	Thu Apr 23 22:33:20 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactListSettings.java	Fri Apr 24 00:55:18 2009 +0200
@@ -1,8 +1,11 @@
 package com.beem.project.beem.ui;
 
 import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.AdapterView;
@@ -11,6 +14,7 @@
 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;
@@ -48,16 +52,18 @@
 	showSettings();
 	Button ok = (Button) findViewById(R.id.ok);
 	ok.setOnClickListener(mOkListener);
-	
+
 	Button reco = (Button) findViewById(R.id.reconnect);
-	reco.setOnClickListener(new OnClickListener () {
+	reco.setOnClickListener(new OnClickListener() {
 
 	    @Override
 	    public void onClick(View v) {
-		setResult(RESULT_OK);
-		finish();
+		if (mSettings.getString(getString(R.string.PreferenceHostKey), "") != "") {
+		    setResult(RESULT_OK);
+		    finish();
+		}
 	    }
-	    
+
 	});
     }
 
@@ -92,7 +98,7 @@
     private OnClickListener mOkListener = new OnClickListener() {
 	public void onClick(View v) {
 	    SharedPreferences.Editor editor = mSettings.edit();
-	    
+
 	    if (isChanged(R.id.host, R.string.PreferenceHostKey)) {
 		editor.putString(getString(R.string.PreferenceHostKey), getWidgetText(R.id.host));
 		mIsChanged = true;
@@ -114,8 +120,10 @@
 		editor.putString(getString(R.string.PreferenceProxyHost), getWidgetText(R.id.proxy_host));
 		mIsChanged = true;
 	    }
-	    if (Integer.parseInt(getWidgetText(R.id.proxy_port)) != mSettings.getInt(getString(R.string.PreferenceProxyPort), 1080) ) {
-		editor.putInt(getString(R.string.PreferenceProxyPort), Integer.parseInt(getWidgetText(R.id.proxy_port)));
+	    if (Integer.parseInt(getWidgetText(R.id.proxy_port)) != mSettings.getInt(
+		getString(R.string.PreferenceProxyPort), 1080)) {
+		editor
+		    .putInt(getString(R.string.PreferenceProxyPort), Integer.parseInt(getWidgetText(R.id.proxy_port)));
 		mIsChanged = true;
 	    }
 	    if (isChanged(R.id.proxy_login, R.string.PreferenceProxyUser)) {