divers petites opti et un petit debug dans Login
authornikita@nikita-laptop
Sun, 08 Nov 2009 02:01:19 +0100
changeset 499 973f28f405bc
parent 498 6c2a766f2297
child 500 4da77df8f950
divers petites opti et un petit debug dans Login
res/layout/contactlist_group.xml
res/layout/contactlistcontact.xml
res/values-fr/strings.xml
res/values/colors.xml
res/values/strings.xml
src/com/beem/project/beem/ui/ContactList.java
src/com/beem/project/beem/ui/CreateAccount.java
src/com/beem/project/beem/ui/Login.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/contactlist_group.xml	Sun Nov 08 02:01:19 2009 +0100
@@ -0,0 +1,4 @@
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+	android:textColor="@color/white" android:textColorHighlight="@color/red"
+	android:typeface="normal" android:textStyle="bold" android:id="@+id/contactlist_group"></TextView>
\ No newline at end of file
--- a/res/layout/contactlistcontact.xml	Sat Nov 07 07:06:17 2009 +0100
+++ b/res/layout/contactlistcontact.xml	Sun Nov 08 02:01:19 2009 +0100
@@ -1,12 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 	android:orientation="horizontal" android:layout_width="fill_parent"
-	android:layout_height="wrap_content"
-	android:paddingLeft="10px"
-	android:paddingRight="10px"
-	android:paddingTop="4px"
-	android:paddingBottom="4px"
-	android:gravity="center_vertical">
+	android:layout_height="wrap_content" android:paddingLeft="10px"
+	android:paddingRight="10px" android:paddingTop="4px"
+	android:paddingBottom="4px" android:gravity="center_vertical">
 
 	<ImageView android:id="@+id/contactliststatus"
 		android:adjustViewBounds="true" android:maxWidth="15dip"
@@ -19,10 +16,13 @@
 		<TextView android:id="@+id/contactlistpseudo"
 			android:layout_width="fill_parent" android:layout_height="wrap_content"
 			android:paddingLeft="16px" android:singleLine="true"
-			android:maxLines="1" />
+			android:maxLines="1" android:textColor="@color/white"
+			android:textSize="14px" android:textStyle="bold" />
 		<TextView android:id="@+id/contactlistmsgperso"
 			android:layout_width="fill_parent" android:layout_height="wrap_content"
 			android:paddingLeft="16px" android:singleLine="true"
-			android:maxLines="1" android:linksClickable="false" android:autoLink="all" />
+			android:maxLines="1" android:linksClickable="false" android:autoLink="all"
+			android:scrollHorizontally="true" android:textColor="@color/white"
+			android:textSize="12px" />
 	</LinearLayout>
 </LinearLayout>
--- a/res/values-fr/strings.xml	Sat Nov 07 07:06:17 2009 +0100
+++ b/res/values-fr/strings.xml	Sun Nov 08 02:01:19 2009 +0100
@@ -169,7 +169,6 @@
 	<string name="settings_menu_create_account">Créer un compte</string>
 	<string name="settings_menu_login">Se connecter</string>
 	<string name="settings_saved_ok">Les paramètres ont été enregistrés avec succès.</string>
-	<string name="settings_filename">beem_settings</string>
 	
 	<string name="settings_key_account_username">beem_account_username</string>
 	<string name="settings_key_account_password">beem_account_password</string>
--- a/res/values/colors.xml	Sat Nov 07 07:06:17 2009 +0100
+++ b/res/values/colors.xml	Sun Nov 08 02:01:19 2009 +0100
@@ -3,4 +3,5 @@
 	<color name="blue_sky">#A0C8FF</color>
 	<color name="black">#000000</color>
 	<color name="white">#FFFFFF</color>
+	<color name="red">#FF0000</color>
 </resources>
\ No newline at end of file
--- a/res/values/strings.xml	Sat Nov 07 07:06:17 2009 +0100
+++ b/res/values/strings.xml	Sun Nov 08 02:01:19 2009 +0100
@@ -157,7 +157,6 @@
 	<string name="settings_menu_create_account">Create an account</string>
 	<string name="settings_menu_login">Login</string>
 	<string name="settings_saved_ok">The settings have been saved successfully.</string>
-	<string name="settings_filename">beem_settings</string>
 
 	<string name="settings_key_account_username">beem_account_username</string>
 	<string name="settings_key_account_password">beem_account_password</string>
--- a/src/com/beem/project/beem/ui/ContactList.java	Sat Nov 07 07:06:17 2009 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java	Sun Nov 08 02:01:19 2009 +0100
@@ -18,14 +18,11 @@
 import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.graphics.Color;
-import android.graphics.Typeface;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.preference.PreferenceManager;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -71,6 +68,7 @@
     private final ServiceConnection mServConn = new BeemServiceConnection();
     private BeemBroadcastReceiver mReceiver;
     private Map<Integer, Bitmap> mIconsMap = new HashMap<Integer, Bitmap>();
+    private LayoutInflater mInflater;
 
     static {
 	SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -96,6 +94,7 @@
 	mHandler = new Handler();
 	mReceiver = new BeemBroadcastReceiver(mServConn);
 	this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
+	mInflater = LayoutInflater.from(this);
 	prepareIconsStatus();
     }
 
@@ -461,11 +460,9 @@
 		    }
 		    curContact.setStatus(mRoster.getPresence(StringUtils.parseBareAddress(presence.getFrom())));
 		    int status = presence.getStatus();
-		    if (!resfound && status != Status.CONTACT_STATUS_DISCONNECT
-			&& status != Status.CONTACT_STATUS_UNAVAILABLE)
+		    if (!resfound && !Status.statusOnline(status))
 			curContact.addRes(pres);
-		    else if (resfound && status == Status.CONTACT_STATUS_DISCONNECT
-			&& status == Status.CONTACT_STATUS_UNAVAILABLE)
+		    else if (resfound && Status.statusOnline(status))
 			curContact.delRes(pres);
 		    mHandler.post(new RunnableChange());
 		    return;
@@ -478,14 +475,12 @@
      * Adapter contact list.
      */
     private class BeemContactList extends BaseAdapter {
-	private final LayoutInflater mInflater;
 
 	/**
 	 * Constructor.
 	 * @param context context activity.
 	 */
 	public BeemContactList(final Context context) {
-	    mInflater = LayoutInflater.from(context);
 	}
 
 	/**
@@ -550,11 +545,8 @@
 		    e.printStackTrace();
 		}
 	    }
-	    Log.d("ContactList", "hide " + mSettings.getBoolean("settings_key_hidden_contact", false));
-
 	    if (mSettings.getBoolean("settings_key_hidden_contact", false) && !Status.statusOnline(c.getStatus())) {
 		v.setVisibility(View.GONE);
-		Log.d("ContactList", "hide " + c.getJID());
 	    } else {
 		bindView(v, c);
 	    }
@@ -573,17 +565,8 @@
 		TextView v = (TextView) view.findViewById(R.id.contactlistpseudo);
 		imgV.setImageBitmap(mIconsMap.get(curContact.getStatus()));
 		v.setText(curContact.getName());
-		v.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
-		v.setTextColor(Color.WHITE);
-		v.setTextSize(14);
-
 		v = (TextView) view.findViewById(R.id.contactlistmsgperso);
-		if (v != null) {
-		    v.setText(curContact.getMsgState());
-		    v.setTextColor(Color.WHITE);
-		    v.setTextSize(12);
-		    v.setHorizontallyScrolling(isFinishing());
-		}
+		v.setText(curContact.getMsgState());
 	    }
 	}
     }
@@ -592,14 +575,11 @@
      * Adapter banner list.
      */
     public class BeemBanner extends BaseAdapter {
-	private final Context mContext;
-
 	/**
 	 * Constructor.
 	 * @param c context activity.
 	 */
 	public BeemBanner(final Context c) {
-	    mContext = c;
 	}
 
 	/**
@@ -631,12 +611,12 @@
 	 */
 	@Override
 	public View getView(int position, View convertView, ViewGroup parent) {
-	    TextView i = new TextView(mContext);
-	    i.setText(mListGroup.get(position));
-	    i.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
-	    i.setTextColor(Color.WHITE);
-	    i.setHighlightColor(Color.RED);
-	    return i;
+	    View v = convertView;
+	    if (convertView == null) {
+		v = mInflater.inflate(R.layout.contactlist_group, null);
+	    }
+	    ((TextView) v).setText(mListGroup.get(position));
+	    return v;
 	}
 
     }
--- a/src/com/beem/project/beem/ui/CreateAccount.java	Sat Nov 07 07:06:17 2009 +0100
+++ b/src/com/beem/project/beem/ui/CreateAccount.java	Sun Nov 08 02:01:19 2009 +0100
@@ -14,6 +14,7 @@
 import android.content.DialogInterface;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.preference.PreferenceManager;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
@@ -53,7 +54,7 @@
 	super.onCreate(savedInstanceState);
 	setContentView(R.layout.create_account);
 	initCreateAccountButton();
-	mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
+	mSettings = PreferenceManager.getDefaultSharedPreferences(this);
     }
 
     /**
--- a/src/com/beem/project/beem/ui/Login.java	Sat Nov 07 07:06:17 2009 +0100
+++ b/src/com/beem/project/beem/ui/Login.java	Sun Nov 08 02:01:19 2009 +0100
@@ -6,7 +6,6 @@
 import android.content.ComponentName;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.content.SharedPreferences;
 import android.os.Bundle;
@@ -26,7 +25,6 @@
 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.utils.BeemBroadcastReceiver;
 import com.beem.project.beem.utils.Status;
 
 /**
@@ -53,7 +51,6 @@
     private SharedPreferences mSettings;
     private boolean mIsConfigured;
     private int mRetry;
-    private BeemBroadcastReceiver mReceiver;
     private IXmppConnection mXmppConnection;
 
     /**
@@ -88,7 +85,6 @@
 	mSettings = PreferenceManager.getDefaultSharedPreferences(this);
 	setContentView(R.layout.login);
 	mProgressDialog = new ProgressDialog(this);
-	mReceiver = new BeemBroadcastReceiver(mServConn);
     }
 
     /**
@@ -99,7 +95,6 @@
 	super.onStop();
 	Log.d(TAG, "onStop " + mIsConnectedService);
 	if (mIsConfigured && (mIsConnectedService || mXmppFacade != null)) {
-	    mReceiver.setBinded(false);
 	    boolean isConnected = false;
 	    if (mXmppConnection != null) {
 		try {
@@ -123,7 +118,6 @@
     protected void onPause() {
 	super.onPause();
 	Log.d(TAG, "onPause");
-	this.unregisterReceiver(mReceiver);
 	mConnectionHandler.removeCallbacks(mConnectionRunnable);
 	mProgressDialog.dismiss();
     }
@@ -135,7 +129,6 @@
     protected void onResume() {
 	super.onResume();
 	Log.d(TAG, "onResume");
-	this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
     }
 
     /**
@@ -153,7 +146,6 @@
 		e.printStackTrace();
 	    }
 	    bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
-	    mReceiver.setBinded(true);
 	    mIsConnectedService = true;
 	}
     }
@@ -225,7 +217,6 @@
 		mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
 		if (mIsConfigured) {
 		    bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
-		    mReceiver.setBinded(true);
 		}
 	    }
 
@@ -266,7 +257,6 @@
 	public void connectionFailed(String errorMsg) throws RemoteException {
 	    Log.d(TAG, "CONNECTIONFAILLED");
 	    if (mXmppFacade != null) {
-		mReceiver.setBinded(false);
 		Login.this.unbindService(mServConn);
 		Login.this.stopService(SERVICE_INTENT);
 		mIsConnectedService = false;