# HG changeset patch # User "Vincent Veronis" # Date 1300593435 -3600 # Node ID 56a04fcdd3fdfdf0c6d5bbbe4e487fe34c4b29ef # Parent e221906b6fc79a5e75c7a70064ba171a47fd3dda Multi Account connection sans multi count diff -r e221906b6fc7 -r 56a04fcdd3fd src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Sun Mar 20 02:55:29 2011 +0100 +++ b/src/com/beem/project/beem/BeemService.java Sun Mar 20 04:57:15 2011 +0100 @@ -103,7 +103,7 @@ private Map mBeemConnection = new HashMap(); //TODO: MAp maybe instead of LIST - private Map mBind = new HashMap(); + private Map mBind = new HashMap(); private boolean mOnOffReceiverIsRegistered; @@ -123,8 +123,8 @@ @Override public IBinder onBind(Intent intent) { Log.d(TAG, "ONBIND()"); - //TODO: Prendre le bon mbind dans le tableau - return mBind.get(intent.getExtras().getString("account_name")); + Log.e(TAG, intent.getStringExtra("account_name")); + return (IBinder) mBind.get(intent.getStringExtra("account_name")); } @Override @@ -253,6 +253,7 @@ */ public IXmppFacade getBind() { //TODO: Prendre le bon mbind dans le tableau + Log.e(TAG, "GETBIND"); return mBind.get(0); } diff -r e221906b6fc7 -r 56a04fcdd3fd src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Sun Mar 20 02:55:29 2011 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Sun Mar 20 04:57:15 2011 +0100 @@ -39,7 +39,7 @@ Flavien Astraud, November 26, 2009 -*/ + */ package com.beem.project.beem.ui; import java.util.ArrayList; @@ -121,16 +121,16 @@ private final BeemContactList mAdapterContactList = new BeemContactList(); private final List mListGroup = new ArrayList(); - /** Map containing a list of the different contacts of a given group. - * Each list is a @{link SortedList} so there is no need to sort it again. - * */ + /** + * Map containing a list of the different contacts of a given group. Each list is a @{link SortedList} so there is + * no need to sort it again. + */ private final Map> mContactOnGroup = new HashMap>(); private final BeemContactListOnClick mOnContactClick = new BeemContactListOnClick(); private final Handler mHandler = new Handler(); private final ServiceConnection mServConn = new BeemServiceConnection(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); - private final ComparatorContactListByStatusAndName mComparator = - new ComparatorContactListByStatusAndName(); + private final ComparatorContactListByStatusAndName mComparator = new ComparatorContactListByStatusAndName(); private final BeemRosterListener mBeemRosterListener = new BeemRosterListener(); private List mListContact; private String mSelectedGroup; @@ -143,6 +143,8 @@ private BeemBanner mAdapterBanner; private boolean mBinded; + private String mAccountName; + /** * Constructor. */ @@ -166,7 +168,9 @@ public final boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.contact_list_menu_settings: - startActivity(new Intent(this, Settings.class)); + Intent i = new Intent(this, Settings.class); + i.putExtra("account_name", mAccountName); + startActivity(i); return true; case R.id.contact_list_menu_add_contact: startActivity(new Intent(ContactList.this, AddContact.class)); @@ -252,8 +256,8 @@ result = true; break; case R.id.contact_list_context_menu_userinfo_subscription: - Dialog subscription = new ResendSubscription(ContactList.this, - mXmppFacade, mSelectedContact).create(); + Dialog subscription = new ResendSubscription(ContactList.this, mXmppFacade, mSelectedContact) + .create(); subscription.show(); result = true; break; @@ -280,6 +284,8 @@ mSettings = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.contactlist); + mAccountName = getIntent().getStringExtra("account_name"); + this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); mInflater = getLayoutInflater(); @@ -289,13 +295,19 @@ listView.setOnItemClickListener(mOnContactClick); registerForContextMenu(listView); listView.setAdapter(mAdapterContactList); + Log.e(TAG, "ONCREATE"); } @Override protected void onResume() { super.onResume(); - if (!mBinded) - mBinded = bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); + if (!mBinded) { + Log.e(TAG, "ON RESUME"); + Intent i = new Intent(SERVICE_INTENT); + i.putExtras(getIntent()); + Log.e(TAG, i.getStringExtra("account_name")); + mBinded = bindService(i, mServConn, BIND_AUTO_CREATE); + } } /** @@ -376,12 +388,10 @@ } /** - * {@inheritDoc} - * Simple stategy to handle the onEntriesAdded event. - * if contact has to be shown : + * {@inheritDoc} Simple stategy to handle the onEntriesAdded event. if contact has to be shown : *
    - *
  • add him to his groups
  • - *
  • add him to the specials groups + *
  • add him to his groups
  • + *
  • add him to the specials groups *
*/ @Override @@ -413,10 +423,9 @@ } /** - * {@inheritDoc} - * Simple stategy to handle the onEntriesDeleted event. + * {@inheritDoc} Simple stategy to handle the onEntriesDeleted event. *
    - *
  • Remove the contact from all groups
  • + *
  • Remove the contact from all groups
  • *
*/ @Override @@ -447,12 +456,11 @@ } /** - * {@inheritDoc} - * Simple stategy to handle the onEntriesUpdated event. + * {@inheritDoc} Simple stategy to handle the onEntriesUpdated event. *
    - *
  • Remove the contact from all groups
  • - *
  • if contact has to be shown add it to his groups
  • - *
  • if contact has to be shown add it to the specials groups
  • + *
  • Remove the contact from all groups
  • + *
  • if contact has to be shown add it to his groups
  • + *
  • if contact has to be shown add it to the specials groups
  • *
*/ @Override @@ -473,8 +481,7 @@ for (String group : groups) { if (!mListGroup.contains(group)) { mListGroup.add(mListGroup.size() - 1, group); - List tmplist = new SortedList( - new LinkedList(), mComparator); + List tmplist = new SortedList(new LinkedList(), mComparator); mContactOnGroup.put(group, tmplist); } mContactOnGroup.get(group).remove(contact); @@ -492,12 +499,11 @@ } /** - * {@inheritDoc} - * Simple stategy to handle the onPresenceChanged event. + * {@inheritDoc} Simple stategy to handle the onPresenceChanged event. *
    - *
  • Remove the contact from all groups
  • - *
  • if contact has to be shown add it to his groups
  • - *
  • if contact has to be shown add it to the specials groups
  • + *
  • Remove the contact from all groups
  • + *
  • if contact has to be shown add it to his groups
  • + *
  • if contact has to be shown add it to the specials groups
  • *
*/ @Override @@ -527,10 +533,8 @@ } /** - * Add a contact to the special list No Group and All contacts. - * The contact will be added if the list is not the current list otherwise - * the list must be modified in a Handler. - * + * Add a contact to the special list No Group and All contacts. The contact will be added if the list is not the + * current list otherwise the list must be modified in a Handler. * @param contact the contact to add. */ private void addToSpecialList(Contact contact) { @@ -547,7 +551,6 @@ /** * Update the current list with the status of contact. - * * @param listName name of the current list * @param contact contact to update */ @@ -556,12 +559,11 @@ final List groups = contact.getGroups(); String noGroup = getString(R.string.contact_list_no_group); String allGroup = getString(R.string.contact_list_all_contact); - final boolean add = ((!hideDisconnected || Status.statusOnline(contact.getStatus())) && // must show and - ( - (listName.equals(noGroup) && groups.isEmpty()) || // in no group - groups.contains(listName) || // or in current - listName.equals(allGroup) // or in all - )); + final boolean add = ((!hideDisconnected || Status.statusOnline(contact.getStatus())) && // must show and + ((listName.equals(noGroup) && groups.isEmpty()) || // in no group + groups.contains(listName) || // or in current + listName.equals(allGroup) // or in all + )); mHandler.post(new Runnable() { public void run() { mListContact.remove(contact); @@ -624,7 +626,6 @@ return mListContact.get(position).hashCode(); } - /** * {@inheritDoc} */ @@ -672,8 +673,8 @@ } /** - * Get a LayerDrawable containing the avatar and the status icon. - * The status icon will change with the level of the drawable. + * Get a LayerDrawable containing the avatar and the status icon. The status icon will change with the level of + * the drawable. * @param avatarId the avatar id to retrieve or null to get default * @return a LayerDrawable */ @@ -710,7 +711,8 @@ /** * Create a ContactFilter. */ - public ContactFilter() { } + public ContactFilter() { + } @Override protected Filter.FilterResults performFiltering(CharSequence constraint) { @@ -730,7 +732,7 @@ } @Override - protected void publishResults(CharSequence constraint, Filter.FilterResults results) { + protected void publishResults(CharSequence constraint, Filter.FilterResults results) { Log.d(TAG, "publishResults"); List contacts = (List) results.values; mListContact = contacts; @@ -799,7 +801,12 @@ try { mRoster = mXmppFacade.getRoster(); if (mRoster != null) { + Log.e(TAG, "ROSTER"); + List tmpGroupList = mRoster.getGroupsNames(); + for (String string : tmpGroupList) { + Log.e(TAG, string); + } Collections.sort(tmpGroupList); mListGroup.clear(); mListGroup.add(getString(R.string.contact_list_all_contact)); @@ -824,6 +831,7 @@ @Override public void onServiceDisconnected(ComponentName name) { + Log.e(TAG, "SERVICE DISCO"); try { mRoster.removeRosterListener(mBeemRosterListener); } catch (RemoteException e) { @@ -839,9 +847,7 @@ } /** - * Assign the differents contact to their groups. - * This methods will fill the mContactOnGroup map. - * + * Assign the differents contact to their groups. This methods will fill the mContactOnGroup map. * @param contacts list of contacts * @param groupNames list of existing groups */ @@ -874,7 +880,6 @@ /** * Make the List of the map became Insertion sorted list. - * * @param map the map to convert. */ private void makeSortedList(Map> map) { @@ -885,9 +890,6 @@ } } - - - /** * Comparator Contact by status and name. */ diff -r e221906b6fc7 -r 56a04fcdd3fd src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Sun Mar 20 02:55:29 2011 +0100 +++ b/src/com/beem/project/beem/ui/Login.java Sun Mar 20 04:57:15 2011 +0100 @@ -56,6 +56,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -81,6 +82,7 @@ private static final int LOGIN_REQUEST_CODE = 1; private TextView mTextView; private BeemApplication mBeemApplication; + private String mAccountName; List mListAccount = new ArrayList(); private BeemAccountList mAdapterAccountList; @@ -95,17 +97,17 @@ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Application app = getApplication(); - if (app instanceof BeemApplication) { - mBeemApplication = (BeemApplication) app; - if (mBeemApplication.isConnected()) { - startActivity(new Intent(this, ContactList.class)); - finish(); - } else if (!mBeemApplication.isAccountConfigured()) { - startActivity(new Intent(this, Account.class)); - finish(); - } - } +// Application app = getApplication(); +// if (app instanceof BeemApplication) { +// mBeemApplication = (BeemApplication) app; +// if (mBeemApplication.isConnected()) { +// startActivity(new Intent(this, ContactList.class)); +// finish(); +// } else if (!mBeemApplication.isAccountConfigured()) { +// startActivity(new Intent(this, Account.class)); +// finish(); +// } +// } setContentView(R.layout.login); mTextView = (TextView) findViewById(R.id.log_as_msg); ListView listView = (ListView) findViewById(R.id.accountlist); @@ -123,8 +125,11 @@ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == LOGIN_REQUEST_CODE) { - if (resultCode == Activity.RESULT_OK) { - startActivity(new Intent(this, ContactList.class)); + if (resultCode == Activity.RESULT_OK) { + Intent i = new Intent(this, ContactList.class); + Log.e("LOGIN", "ACCOUNT NAME : " + mAccountName); + i.putExtra("account_name", mAccountName); + startActivity(i); finish(); } else if (resultCode == Activity.RESULT_CANCELED) { if (data != null) { @@ -254,7 +259,8 @@ @Override public void onItemClick(AdapterView arg0, View v, int pos, long lpos) { Intent i = new Intent(Login.this, LoginAnim.class); - i.putExtra("account_name", mListAccount.get(pos)); + mAccountName = mListAccount.get(pos); + i.putExtra("account_name", mAccountName); startActivityForResult(i, LOGIN_REQUEST_CODE); } } diff -r e221906b6fc7 -r 56a04fcdd3fd src/com/beem/project/beem/ui/LoginAnim.java --- a/src/com/beem/project/beem/ui/LoginAnim.java Sun Mar 20 02:55:29 2011 +0100 +++ b/src/com/beem/project/beem/ui/LoginAnim.java Sun Mar 20 04:57:15 2011 +0100 @@ -122,7 +122,7 @@ mTask = new LoginTask(); if (mXmppFacade == null) { Intent i = new Intent(LoginAnim.SERVICE_INTENT); - i.putExtra("account_name", getIntent().getExtras().getString("account_name")); + i.putExtras(getIntent()); bindService(i, mServConn, BIND_AUTO_CREATE); } } diff -r e221906b6fc7 -r 56a04fcdd3fd src/com/beem/project/beem/ui/Settings.java --- a/src/com/beem/project/beem/ui/Settings.java Sun Mar 20 02:55:29 2011 +0100 +++ b/src/com/beem/project/beem/ui/Settings.java Sun Mar 20 04:57:15 2011 +0100 @@ -73,6 +73,7 @@ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + getSharedPreferences(getIntent().getExtras().getString("account_name"), MODE_PRIVATE); addPreferencesFromResource(R.layout.preferences); }