# HG changeset patch # User nikita@nikita-laptop # Date 1257573111 -3600 # Node ID 84a73d51156f9092046c47bf0aec254b300d29a4 # Parent 3c83d2e2c4788b4d137653a82239309f26d55bd0 debug d'un gros bug dans login que j'avais laissé dans le commit d'avant, gestion du hide offline diff -r 3c83d2e2c478 -r 84a73d51156f src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Fri Nov 06 19:38:17 2009 +0100 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Sat Nov 07 06:51:51 2009 +0100 @@ -1,6 +1,3 @@ -/** - * - */ package com.beem.project.beem.service; import java.util.ArrayList; @@ -205,7 +202,7 @@ * Listener for the roster events. It will call the remote listeners registered. * @author darisk */ - private class RosterListenerAdapter implements RosterListener { + private class RosterListenerAdapter implements RosterListener{ /** * Constructor. @@ -218,7 +215,8 @@ * @param group the group the entry was. * @param jid the jid of the entry which is deleted. */ - public void onEntryDeleteFromGroup(String group, String jid) { + @SuppressWarnings("unused") + public void onEntryDeleteFromGroup(final String group, final String jid) { // Log.i(TAG, "entry delete listener"); final int n = mRemoteRosListeners.beginBroadcast(); for (int i = 0; i < n; i++) { diff -r 3c83d2e2c478 -r 84a73d51156f src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Fri Nov 06 19:38:17 2009 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Sat Nov 07 06:51:51 2009 +0100 @@ -24,6 +24,7 @@ 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; @@ -55,7 +56,6 @@ public class ContactList extends Activity { //private static final String TAG = "CONTACTLIST_ACT"; - private static final boolean DEFAULT_BOOLEAN_VALUE = false; private static final Intent SERVICE_INTENT = new Intent(); private static final int REQUEST_CODE = 1; private BeemContactList mAdapterContactList; @@ -89,7 +89,7 @@ @Override protected void onCreate(Bundle saveBundle) { super.onCreate(saveBundle); - mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE); + mSettings = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.contactlist); mAdapterContactList = new BeemContactList(this); mAdapterBanner = new BeemBanner(this); @@ -306,11 +306,6 @@ /** * Prepare Bitmap Map. */ - - private boolean getRegisteredContactHidden() { - return mSettings.getBoolean(getString(R.string.settings_key_hidden_contact), DEFAULT_BOOLEAN_VALUE); - } - private void prepareIconsStatus(){ mIconsMap.put(Status.CONTACT_STATUS_AVAILABLE, BitmapFactory.decodeResource(getResources(), R.drawable.status_available)); mIconsMap.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT, BitmapFactory.decodeResource(getResources(), R.drawable.status_available)); @@ -498,7 +493,16 @@ */ @Override public int getCount() { - return mListContact.size(); + if (mSettings.getBoolean("settings_key_hidden_contact", false)) { + int res = 0; + for (Contact c : mListContact) { + if (Status.statusOnline(c.getStatus())) + res++; + } + return res; + } else { + return mListContact.size(); + } } /** @@ -526,8 +530,19 @@ if (convertView == null) { v = mInflater.inflate(R.layout.contactlistcontact, null); } - - Contact c = mListContact.get(position); + Contact c = null; + if (mSettings.getBoolean("settings_key_hidden_contact", false)) { + int res = 0; + for (Contact cur : mListContact) { + if (res == position) { + c = cur; + break; + } + if (Status.statusOnline(cur.getStatus())) + res++; + } + } else + c = mListContact.get(position); if (mRoster != null) { try { c = mRoster.getContact(c.getJID()); @@ -535,7 +550,14 @@ e.printStackTrace(); } } - bindView(v, c); + 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); + } return v; } @@ -652,10 +674,10 @@ for (String s : tmpGroupList) { List tmpList = new ArrayList(); for (Contact c : tmpContactList) { - if (c.getGroups().size() == 0 && !tmpNoGroup.contains(c)) - tmpNoGroup.add(c); - else if (c.getGroups().contains(s)) - tmpList.add(c); + if (c.getGroups().size() == 0 && !tmpNoGroup.contains(c)) + tmpNoGroup.add(c); + else if (c.getGroups().contains(s)) + tmpList.add(c); } mContactOnGroup.put(s, tmpList); } diff -r 3c83d2e2c478 -r 84a73d51156f src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Fri Nov 06 19:38:17 2009 +0100 +++ b/src/com/beem/project/beem/ui/Login.java Sat Nov 07 06:51:51 2009 +0100 @@ -101,13 +101,15 @@ if (mIsConfigured && (mIsConnectedService || mXmppFacade != null)) { mReceiver.setBinded(false); boolean isConnected = false; - try { - isConnected = mXmppConnection.isAuthentificated(); - } catch (RemoteException e) { - e.printStackTrace(); + if (mXmppConnection != null) { + try { + isConnected = mXmppConnection.isAuthentificated(); + } catch (RemoteException e) { + e.printStackTrace(); + } } unbindService(mServConn); - if (isConnected) { + if (!isConnected) { stopService(SERVICE_INTENT); } mXmppFacade = null; diff -r 3c83d2e2c478 -r 84a73d51156f src/com/beem/project/beem/utils/Status.java --- a/src/com/beem/project/beem/utils/Status.java Fri Nov 06 19:38:17 2009 +0100 +++ b/src/com/beem/project/beem/utils/Status.java Sat Nov 07 06:51:51 2009 +0100 @@ -115,4 +115,14 @@ } return res; } + + /** + * Check if contact is online by his status. + * @param status contact status + * @return is obline + */ + public static boolean statusOnline(int status) { + return (status != Status.CONTACT_STATUS_DISCONNECT && status != Status.CONTACT_STATUS_UNAVAILABLE); + } + }