# HG changeset patch # User jamu@gaia # Date 1260498114 -3600 # Node ID a67f46ac98b1b9254cb52f0caffb5ec217ca904b # Parent dee39889d2d7c6c1338682959fb0c143b342454d Modification de la gestion des Dialogs dans l'activité PrivacyList. Modification des bind/unbind dans les activités ContactList, Chat et PrivacyList pour cause de leak. diff -r dee39889d2d7 -r a67f46ac98b1 res/menu/privacy_list_context.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/menu/privacy_list_context.xml Fri Dec 11 03:21:54 2009 +0100 @@ -0,0 +1,8 @@ + + + + + diff -r dee39889d2d7 -r a67f46ac98b1 res/values-fr/strings.xml --- a/res/values-fr/strings.xml Thu Dec 10 04:14:24 2009 +0100 +++ b/res/values-fr/strings.xml Fri Dec 11 03:21:54 2009 +0100 @@ -286,6 +286,12 @@ Créer une liste privée Titre Créer + Contacts + Groupes + Supprimer + Souhaitez-vous vraiment supprimer la liste privée intitulée '%s' ? + Oui + Non Mettre à jour diff -r dee39889d2d7 -r a67f46ac98b1 res/values/strings.xml --- a/res/values/strings.xml Thu Dec 10 04:14:24 2009 +0100 +++ b/res/values/strings.xml Fri Dec 11 03:21:54 2009 +0100 @@ -273,6 +273,9 @@ Buddies Groups Delete + Do you really want to delete the privacy list entitled '%s' ? + Yes + No Update diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/Chat.java --- a/src/com/beem/project/beem/ui/Chat.java Thu Dec 10 04:14:24 2009 +0100 +++ b/src/com/beem/project/beem/ui/Chat.java Fri Dec 11 03:21:54 2009 +0100 @@ -155,13 +155,16 @@ mHandler = new Handler(); + // SVC Bind + bindService(SERVICE_INTENT, mConn, BIND_AUTO_CREATE); + // Listeners mMessageListener = new OnMessageListener(); mChatManagerListener = new OnChatManagerListener(); mBroadcastReceiver = new BeemBroadcastReceiver(mConn); this.registerReceiver(mBroadcastReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); - + // UI mContactNameTextView = (TextView) findViewById(R.id.chat_contact_name); mContactStatusMsgTextView = (TextView) findViewById(R.id.chat_contact_status_msg); @@ -191,7 +194,7 @@ super.onDestroy(); Log.v(TAG, "BEGIN onDestroy."); - this.unregisterReceiver(mBroadcastReceiver); + if (mChatManager != null) { try { mChatManager.removeChatCreationListener(mChatManagerListener); @@ -199,6 +202,10 @@ Log.e(TAG, e.getMessage()); } } + + this.unregisterReceiver(mBroadcastReceiver); + unbindService(mConn); + Log.v(TAG, "END onDestroy."); } @@ -210,7 +217,6 @@ super.onStart(); Log.v(TAG, "BEGIN onStart."); - bindService(new Intent(this, BeemService.class), mConn, BIND_AUTO_CREATE); Log.v(TAG, "END onStart."); } @@ -229,9 +235,6 @@ Log.e(TAG, e.getMessage()); } } - if (mBroadcastReceiver.isBinded()) { - unbindService(mConn); - } Log.v(TAG, "END onStop."); } @@ -784,6 +787,7 @@ * JID attribute mutator. * @param bareJid A String containing the author's bare JID of the message. */ + @SuppressWarnings("unused") public void setBareJid(String bareJid) { mBareJid = bareJid; } @@ -792,6 +796,7 @@ * Name attribute mutator. * @param name A String containing the author's name of the message. */ + @SuppressWarnings("unused") public void setName(String name) { mName = name; } diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Thu Dec 10 04:14:24 2009 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Fri Dec 11 03:21:54 2009 +0100 @@ -67,13 +67,16 @@ import com.beem.project.beem.utils.Status; /** - * The contact list activity displays the roster of the user. - * TODO: Dismiss dialogs on destroy to avoid window leak + * The contact list activity displays the roster of the user. TODO: Dismiss dialogs on destroy to avoid window leak */ public class ContactList extends Activity { // private static final String TAG = "CONTACTLIST_ACT"; private static final Intent SERVICE_INTENT = new Intent(); + static { + SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); + } + private static final int REQUEST_CODE = 1; private BeemContactList mAdapterContactList; private BeemBanner mAdapterBanner; @@ -91,10 +94,6 @@ private final Map mIconsMap = new HashMap(); private LayoutInflater mInflater; - static { - SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); - } - /** * Constructor. */ @@ -113,8 +112,11 @@ mAdapterContactList = new BeemContactList(this); mAdapterBanner = new BeemBanner(this); mHandler = new Handler(); + + bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); mReceiver = new BeemBroadcastReceiver(mServConn); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); + mInflater = LayoutInflater.from(this); prepareIconsStatus(); } @@ -241,7 +243,6 @@ @Override protected void onStart() { super.onStart(); - bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); } /** @@ -251,7 +252,6 @@ protected void onStop() { super.onStop(); if (mReceiver.isBinded()) { - unbindService(mServConn); mReceiver.setBinded(false); } } @@ -264,6 +264,7 @@ protected void onDestroy() { super.onDestroy(); this.unregisterReceiver(mReceiver); + unbindService(mServConn); } /** diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/PrivacyList.java --- a/src/com/beem/project/beem/ui/PrivacyList.java Thu Dec 10 04:14:24 2009 +0100 +++ b/src/com/beem/project/beem/ui/PrivacyList.java Fri Dec 11 03:21:54 2009 +0100 @@ -1,52 +1,22 @@ /** - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Véronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program “Beem” - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ + * BEEM is a videoconference application on the Android Platform. Copyright (C) 2009 by Frederic-Charles Barthelery, + * Jean-Manuel Da Silva, Nikita Kozlov, Philippe Lago, Jean Baptiste Vergely, Vincent Véronis. This file is part of + * BEEM. BEEM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. BEEM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with BEEM. If not, see + * . Please send bug reports with examples or suggestions to contact@beem-project.com or + * http://dev.beem-project.com/ Epitech, hereby disclaims all copyright interest in the program “Beem” written by + * Frederic-Charles Barthelery, Jean-Manuel Da Silva, Nikita Kozlov, Philippe Lago, Jean Baptiste Vergely, Vincent + * Veronis. Nicolas Sadirac, November 26, 2009 President of Epitech. Flavien Astraud, November 26, 2009 Head of the EIP + * Laboratory. + */ package com.beem.project.beem.ui; import java.util.ArrayList; import java.util.List; -import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import android.content.ComponentName; @@ -54,26 +24,27 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; +import android.content.DialogInterface.OnDismissListener; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; -import android.view.LayoutInflater; +import android.view.ContextMenu; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; +import android.widget.AdapterView; import android.widget.ArrayAdapter; -import android.widget.EditText; -import android.widget.ListView; -import com.beem.project.beem.BeemService; import com.beem.project.beem.R; import com.beem.project.beem.service.PrivacyListItem; import com.beem.project.beem.service.aidl.IPrivacyListListener; import com.beem.project.beem.service.aidl.IPrivacyListManager; import com.beem.project.beem.service.aidl.IXmppFacade; +import com.beem.project.beem.ui.dialogs.builders.CreatePrivacyList; +import com.beem.project.beem.ui.dialogs.builders.DeletePrivacyList; import com.beem.project.beem.utils.BeemBroadcastReceiver; /** @@ -87,17 +58,19 @@ static { SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); } - private static final int DIALOG_PRIVACY_LIST_ITEM = 1; - private static final int DIALOG_CREATE_PRIVACY_LIST = 2; + + private static final int DIALOG_CREATE = 0; + private static final int DIALOG_UPDATE_BUDDIES = 1; + private static final int DIALOG_UPDATE_GROUPS = 2; + private static final int DIALOG_DELETE = 3; private static final String SAVED_INSTANCE_KEY_PRIVACY_LISTS = "PRIVACY_LISTS"; - private static final String SAVED_INSTANCE_KEY_LAST_CLICKED_ITEM = "LAST_CLICKED_ITEM"; private Handler mHandler = new Handler(); private ArrayAdapter mAdapter; private final List mPrivacyListNames = new ArrayList(); - private int mPosLastClickedItem; + private String mCurrPrivacyListName; private final ServiceConnection mConn = new BeemServiceConnection(); private BeemBroadcastReceiver mBroadcastReceiver; @@ -119,7 +92,6 @@ protected void onSaveInstanceState(Bundle savedInstanceState) { Log.d(TAG, "BEGIN onSaveInstanceState."); savedInstanceState.putStringArrayList(SAVED_INSTANCE_KEY_PRIVACY_LISTS, (ArrayList) mPrivacyListNames); - savedInstanceState.putInt(SAVED_INSTANCE_KEY_LAST_CLICKED_ITEM, mPosLastClickedItem); Log.d(TAG, "END onSaveInstanceState."); super.onSaveInstanceState(savedInstanceState); } @@ -131,18 +103,21 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "BEGIN onCreate."); + setContentView(R.layout.privacy_list); + registerForContextMenu(this.getListView()); mHandler = new Handler(); if (savedInstanceState != null && !savedInstanceState.isEmpty()) { mPrivacyListNames.addAll(savedInstanceState.getStringArrayList(SAVED_INSTANCE_KEY_PRIVACY_LISTS)); - mPosLastClickedItem = savedInstanceState.getInt(SAVED_INSTANCE_KEY_LAST_CLICKED_ITEM); } mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mPrivacyListNames); setListAdapter(mAdapter); + bindService(SERVICE_INTENT, mConn, BIND_AUTO_CREATE); + mPrivacyListListener = new PrivacyListListener(); mBroadcastReceiver = new BeemBroadcastReceiver(mConn); this.registerReceiver(mBroadcastReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); @@ -154,76 +129,11 @@ * {@inheritDoc}. */ @Override - protected void onPrepareDialog(int id, Dialog dialog) { - Log.d(TAG, "BEGIN onPrepareDialog."); - switch (id) { - case DIALOG_PRIVACY_LIST_ITEM: - String dialogTitle = (mPosLastClickedItem > mPrivacyListNames.size() ? "" : mPrivacyListNames - .get(mPosLastClickedItem)); - dialog.setTitle(dialogTitle); - } - Log.d(TAG, "END onPrepareDialog."); - } - - /** - * {@inheritDoc}. - */ - @Override - protected Dialog onCreateDialog(int id) { - Log.d(TAG, "BEGIN onCreateDialog."); - switch (id) { - case DIALOG_PRIVACY_LIST_ITEM: - return new AlertDialog.Builder(this).setTitle("X").setItems(R.array.privacy_list_select_dialog, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - String[] items = getResources().getStringArray(R.array.privacy_list_select_dialog); - if (items[which].equals(getResources() - .getString(R.string.privacy_list_select_dialog_delete))) { - try { - mPrivacyListManager.removePrivacyList(mPrivacyListNames.get(mPosLastClickedItem)); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - dismissDialog(DIALOG_PRIVACY_LIST_ITEM); - } - } - }).create(); - - case DIALOG_CREATE_PRIVACY_LIST: - LayoutInflater factory = LayoutInflater.from(this); - final View textEntryView = factory.inflate(R.layout.privacy_list_create_dialog, null); - - return new AlertDialog.Builder(this).setTitle(R.string.privacy_list_create_dialog_title).setView( - textEntryView).setPositiveButton(R.string.privacy_list_create_dialog_create_button, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - EditText listNameField = (EditText) textEntryView - .findViewById(R.id.privacy_list_create_dialog_list_name); - try { - mPrivacyListManager.createPrivacyList(listNameField.getText().toString(), - new ArrayList()); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - } - }).setNegativeButton(R.string.CancelButton, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - } - }).create(); - } - Log.d(TAG, "END onCreateDialog."); - return null; - } - - /** - * {@inheritDoc}. - */ - @Override protected void onDestroy() { super.onDestroy(); Log.v(TAG, "BEGIN onDestroy."); - this.unregisterReceiver(mBroadcastReceiver); + if (mPrivacyListManager != null) { try { mPrivacyListManager.removePrivacyListListener(mPrivacyListListener); @@ -231,6 +141,10 @@ Log.e(TAG, e.getMessage()); } } + + this.unregisterReceiver(mBroadcastReceiver); + unbindService(mConn); + Log.v(TAG, "END onDestroy."); } @@ -242,7 +156,6 @@ super.onStart(); Log.v(TAG, "BEGIN onStart."); - bindService(new Intent(this, BeemService.class), mConn, BIND_AUTO_CREATE); Log.v(TAG, "END onStart."); } @@ -254,10 +167,41 @@ super.onStop(); Log.v(TAG, "BEGIN onStop."); - if (mBroadcastReceiver.isBinded()) { - unbindService(mConn); + Log.v(TAG, "END onStop."); + } + + /** + * {@inheritDoc}. + */ + @Override + protected Dialog onCreateDialog(int id) { + Dialog dialog; + switch (id) { + case DIALOG_CREATE: + dialog = new CreatePrivacyList(PrivacyList.this, mPrivacyListManager).create(); + dialog.setOnDismissListener(new OnDismissListener() { + + @Override + public void onDismiss(DialogInterface dialog) { + PrivacyList.this.removeDialog(DIALOG_CREATE); + } + }); + break; + case DIALOG_DELETE: + dialog = new DeletePrivacyList(PrivacyList.this, mPrivacyListManager, mCurrPrivacyListName).create(); + dialog.setOnDismissListener(new OnDismissListener() { + + @Override + public void onDismiss(DialogInterface dialog) { + PrivacyList.this.removeDialog(DIALOG_DELETE); + } + + }); + break; + default: + dialog = null; } - Log.v(TAG, "END onStop."); + return dialog; } /** @@ -273,12 +217,33 @@ } /** - * {@inheritDoc}. + * {@inheritDoc} */ @Override - public void onListItemClick(ListView l, View v, int position, long id) { - mPosLastClickedItem = position; - showDialog(DIALOG_PRIVACY_LIST_ITEM); + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.privacy_list_context, menu); + mCurrPrivacyListName = mPrivacyListNames.get(((AdapterView.AdapterContextMenuInfo) menuInfo).position); + menu.setHeaderTitle(mCurrPrivacyListName); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean onContextItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.privacy_list_context_menu_buddies_item: + return true; + case R.id.privacy_list_context_menu_groups_item: + return true; + case R.id.privacy_list_context_menu_delete_item: + showDialog(DIALOG_DELETE); + return true; + default: + return super.onContextItemSelected(item); + } } /** @@ -288,7 +253,7 @@ public final boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.privacy_list_menu_create: - showDialog(DIALOG_CREATE_PRIVACY_LIST); + showDialog(DIALOG_CREATE); return true; default: return false; diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/dialogs/builders/Alias.java --- a/src/com/beem/project/beem/ui/dialogs/builders/Alias.java Thu Dec 10 04:14:24 2009 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/Alias.java Fri Dec 11 03:21:54 2009 +0100 @@ -4,6 +4,7 @@ import android.content.Context; import android.content.DialogInterface; import android.os.RemoteException; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; @@ -16,7 +17,9 @@ * Create dialog alias. */ public class Alias extends AlertDialog.Builder { - + + private final static String TAG = "Dialogs.Builders > Alias"; + private IRoster mRoster; private Contact mContact; private EditText mEditTextAlias; @@ -27,10 +30,10 @@ */ public Alias(final Context context, IRoster roster, Contact contact) { super(context); - + mRoster = roster; mContact = contact; - + LayoutInflater factory = LayoutInflater.from(context); final View textEntryView = factory.inflate(R.layout.contactdialogaliasdialog, null); setTitle(mContact.getJID()); @@ -65,7 +68,7 @@ try { mRoster.setContactName(mContact.getJID(), name); } catch (RemoteException e) { - e.printStackTrace(); + Log.e(TAG, e.getMessage()); } } } diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java Fri Dec 11 03:21:54 2009 +0100 @@ -0,0 +1,80 @@ +package com.beem.project.beem.ui.dialogs.builders; + +import java.util.ArrayList; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.os.RemoteException; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; + +import com.beem.project.beem.R; +import com.beem.project.beem.service.PrivacyListItem; +import com.beem.project.beem.service.aidl.IPrivacyListManager; + +/** + * Use this builder to build a dialog which handles a privacy list creation. + * @author Jean-Manuel Da Silva + */ +public class CreatePrivacyList extends AlertDialog.Builder { + + private static final String TAG = "Dialogs.Builders > CreatePrivacyList"; + + private final IPrivacyListManager mPrivacyListManager; + private final View mTextEntryView; + private EditText mListNameField; + + /** + * Constructor. + * @param context context activity. + */ + public CreatePrivacyList(final Context context, IPrivacyListManager privacyListManager) { + super(context); + + LayoutInflater factory = LayoutInflater.from(context); + + mTextEntryView = factory.inflate(R.layout.privacy_list_create_dialog, null); + setView(mTextEntryView); + + mPrivacyListManager = privacyListManager; + mListNameField = (EditText) mTextEntryView.findViewById(R.id.privacy_list_create_dialog_list_name); + + setTitle(R.string.privacy_list_create_dialog_title); + setPositiveButton(R.string.privacy_list_create_dialog_create_button, new DialogClickListener()); + setNegativeButton(R.string.CancelButton, new DialogClickListener()); + } + + /** + * Event click listener. + */ + class DialogClickListener implements DialogInterface.OnClickListener { + + /** + * Constructor. + */ + public DialogClickListener() { + } + + /* + * (non-Javadoc) + * @see android.content.DialogInterface.OnClickListener#onClick(android.content.DialogInterface, int) + */ + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == DialogInterface.BUTTON_POSITIVE) { + try { + Log.d(TAG, "mPrivacyListManager ## " + mPrivacyListManager); + Log.d(TAG, "listNameField ## " + mListNameField); + Log.d(TAG, "listNameField.getText().toString() ## " + mListNameField.getText().toString()); + mPrivacyListManager.createPrivacyList(mListNameField.getText().toString(), + new ArrayList()); + } catch (RemoteException e) { + Log.e(TAG, e.getMessage()); + } + } + } + } +} \ No newline at end of file diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java --- a/src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java Thu Dec 10 04:14:24 2009 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java Fri Dec 11 03:21:54 2009 +0100 @@ -4,13 +4,16 @@ import android.content.Context; import android.content.DialogInterface; import android.os.RemoteException; +import android.util.Log; import com.beem.project.beem.R; import com.beem.project.beem.service.Contact; import com.beem.project.beem.service.aidl.IRoster; public class DeleteContact extends AlertDialog.Builder { - + + private final static String TAG = "Dialogs.Builders > DeleteContact"; + private IRoster mRoster; private Contact mContact; @@ -20,10 +23,10 @@ */ public DeleteContact(final Context context, IRoster roster, Contact contact) { super(context); - + mContact = contact; mRoster = roster; - + setMessage(R.string.userinfo_sure2delete); DialogClickListener dl = new DialogClickListener(); setPositiveButton(R.string.userinfo_yes, dl); @@ -34,8 +37,7 @@ * Event click listener. */ private class DialogClickListener implements DialogInterface.OnClickListener { - - + /** * Constructor. */ @@ -48,7 +50,7 @@ try { mRoster.deleteContact(mContact); } catch (RemoteException e) { - e.printStackTrace(); + Log.e(TAG, e.getMessage()); } } } diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java Fri Dec 11 03:21:54 2009 +0100 @@ -0,0 +1,57 @@ +package com.beem.project.beem.ui.dialogs.builders; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.os.RemoteException; +import android.util.Log; + +import com.beem.project.beem.R; +import com.beem.project.beem.service.aidl.IPrivacyListManager; + +public class DeletePrivacyList extends AlertDialog.Builder { + + private static final String TAG = "Dialogs.Builders > DeletePrivacyList"; + + private final IPrivacyListManager mPrivacyListManager; + private final String mPrivacyListName; + + /** + * Constructor. + * @param context context activity. + */ + public DeletePrivacyList(final Context context, IPrivacyListManager privacyListManager, String privacyListName) { + super(context); + + mPrivacyListManager = privacyListManager; + mPrivacyListName = privacyListName; + + setMessage(context.getString(R.string.privacy_list_delete_dialog_msg, privacyListName)); + DialogClickListener dl = new DialogClickListener(); + setPositiveButton(R.string.privacy_list_delete_dialog_yes, dl); + setNegativeButton(R.string.privacy_list_delete_dialog_no, dl); + } + + /** + * Event click listener. + */ + private class DialogClickListener implements DialogInterface.OnClickListener { + + /** + * Constructor. + */ + public DialogClickListener() { + } + + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == DialogInterface.BUTTON_POSITIVE) { + try { + mPrivacyListManager.removePrivacyList(mPrivacyListName); + } catch (RemoteException e) { + Log.e(TAG, e.getMessage()); + } + } + } + } +} diff -r dee39889d2d7 -r a67f46ac98b1 src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java --- a/src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java Thu Dec 10 04:14:24 2009 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java Fri Dec 11 03:21:54 2009 +0100 @@ -6,6 +6,7 @@ import android.content.Context; import android.content.DialogInterface; import android.os.RemoteException; +import android.util.Log; import android.widget.Toast; import com.beem.project.beem.R; @@ -14,7 +15,9 @@ import com.beem.project.beem.service.aidl.IXmppFacade; public class ResendSubscription extends AlertDialog.Builder { - + + private final static String TAG = "Dialogs.Builders > ResendSubscription"; + private Context mContext; private IXmppFacade mXmppFacade; private Contact mContact; @@ -25,11 +28,11 @@ */ public ResendSubscription(final Context context, IXmppFacade xmppFacade, Contact contact) { super(context); - + mContext = context; mXmppFacade = xmppFacade; mContact = contact; - + setMessage(R.string.userinfo_sureresend); DialogClickListener dl = new DialogClickListener(); setPositiveButton(R.string.userinfo_yes, dl); @@ -40,8 +43,6 @@ * Event click listener. */ class DialogClickListener implements DialogInterface.OnClickListener { - - /** * Constructor. @@ -62,7 +63,7 @@ mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket)); Toast.makeText(mContext, mContext.getString(R.string.userinfo_resend), Toast.LENGTH_SHORT).show(); } catch (RemoteException e) { - e.printStackTrace(); + Log.e(TAG, e.getMessage()); } } }