--- a/res/layout/contactdialog.xml Thu Oct 01 18:03:32 2009 +0200
+++ b/res/layout/contactdialog.xml Thu Oct 01 18:20:15 2009 +0200
@@ -9,19 +9,7 @@
<Button android:id="@+id/CDCall" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/CDCall" />
- <Button android:id="@+id/CDAlias" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CDAlias" />
-
- <Button android:id="@+id/CDDelete" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CDDelete" />
-
- <Button android:id="@+id/CDResend" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CDResend" />
-
<Button android:id="@+id/CDInfos" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/CDInfos" />
- <Button android:id="@+id/CDBlock" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CDBlock" />
-
</LinearLayout>
\ No newline at end of file
--- a/res/layout/contactlist.xml Thu Oct 01 18:03:32 2009 +0200
+++ b/res/layout/contactlist.xml Thu Oct 01 18:20:15 2009 +0200
@@ -4,7 +4,7 @@
android:orientation="vertical">
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/gallery" android:layout_width="fill_parent"
+ android:id="@+id/contactlist_banner" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:spacing="50px" />
<LinearLayout android:layout_width="fill_parent"
--- a/res/layout/userinfo.xml Thu Oct 01 18:03:32 2009 +0200
+++ b/res/layout/userinfo.xml Thu Oct 01 18:20:15 2009 +0200
@@ -1,7 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
- <ListView android:id="@+id/userinfo" android:layout_width="fill_parent"
- android:layout_height="fill_parent" />
-</LinearLayout>
\ No newline at end of file
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="fill_parent" android:layout_height="wrap_content">
+ <LinearLayout android:id="@+id/userinfo_layout_alias"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="70px">
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingLeft="20sp"
+ android:singleLine="true" android:maxLines="1" android:textSize="30px"
+ android:text="@string/userinfo_label_alias" />
+ <TextView android:id="@+id/userinfo_alias"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:paddingLeft="20sp" android:singleLine="true" />
+ </LinearLayout>
+ <View android:layout_height="1px" android:layout_width="fill_parent"
+ android:background="#FFFFFF" />
+ <LinearLayout android:id="@+id/userinfo_layout_vcard"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="70px">
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingLeft="20sp"
+ android:singleLine="true" android:maxLines="1" android:textSize="30px"
+ android:text="@string/userinfo_label_vcard" />
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingLeft="20sp"
+ android:singleLine="true" android:text="@string/userinfo_def_vcard" />
+ </LinearLayout>
+ <View android:layout_height="1px" android:layout_width="fill_parent"
+ android:background="#FFFFFF" />
+ <LinearLayout android:id="@+id/userinfo_layout_chg_group"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="70px">
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingLeft="20sp"
+ android:singleLine="true" android:maxLines="1" android:textSize="30px"
+ android:text="@string/userinfo_label_chg_group" />
+ <Gallery android:id="@+id/userinfo_groups"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:spacing="10px" />
+ </LinearLayout>
+ <View android:layout_height="1px" android:layout_width="fill_parent"
+ android:background="#FFFFFF" />
+ <LinearLayout android:id="@+id/userinfo_layout_re_suscription"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="70px">
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingLeft="20sp"
+ android:singleLine="true" android:maxLines="1" android:textSize="30px"
+ android:text="@string/userinfo_label_re_suscription" />
+ </LinearLayout>
+ <View android:layout_height="1px" android:layout_width="fill_parent"
+ android:background="#FFFFFF" />
+ <LinearLayout android:id="@+id/userinfo_layout_block"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="70px">
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingLeft="20sp"
+ android:singleLine="true" android:maxLines="1" android:textSize="30px"
+ android:text="@string/userinfo_label_block" />
+ </LinearLayout>
+ <View android:layout_height="1px" android:layout_width="fill_parent"
+ android:background="#FFFFFF" />
+ <LinearLayout android:id="@+id/userinfo_layout_delete"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="70px">
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingLeft="20sp"
+ android:singleLine="true" android:maxLines="1" android:textSize="30px"
+ android:text="@string/userinfo_label_delete" />
+ </LinearLayout>
+ </LinearLayout>
+</ScrollView>
\ No newline at end of file
--- a/res/layout/userinfo_alias.xml Thu Oct 01 18:03:32 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <TextView android:id="@+id/userinfo_alias_label"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:paddingLeft="20sp" android:singleLine="true" android:maxLines="1"
- android:textSize="30px" android:text="Alias" />
- <TextView android:id="@+id/userinfo_alias_def"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:paddingLeft="20sp" android:singleLine="true"
- android:text="Modifier le nom affiche de votre contact" />
-</LinearLayout>
\ No newline at end of file
--- a/res/values-en/strings.xml Thu Oct 01 18:03:32 2009 +0200
+++ b/res/values-en/strings.xml Thu Oct 01 18:20:15 2009 +0200
@@ -38,7 +38,7 @@
<string name="CDCall">Call</string>
<string name="CDAlias">Alias</string>
<string name="CDResend">Resend suscription</string>
- <string name="CDInfos">User infos</string>
+ <string name="CDInfos">Manage User</string>
<string name="CDBlock">Block user</string>
<string name="CDDelete">Delete user</string>
<string name="CDSure2Delete">Are you sure you want to delete this contact?
@@ -214,5 +214,17 @@
<string name="contact_list_menu_settings">Settings</string>
<string name="contact_list_all_contact">All contacts</string>
<string name="contact_list_no_group">No group</string>
+
+ <!--
+ UserInfo Activity
+ -->
+ <string name="userinfo_label_alias">Alias</string>
+ <string name="userinfo_label_vcard">VCard</string>
+ <string name="userinfo_label_chg_group">Manage groups</string>
+ <string name="userinfo_label_re_suscription">Resend suscription</string>
+ <string name="userinfo_label_block">Block</string>
+ <string name="userinfo_label_delete">Delete</string>
+ <string name="userinfo_def_vcard">User informations</string>
+ <string name="userinfo_resend">Suscription resend</string>
</resources>
--- a/res/values-fr/strings.xml Thu Oct 01 18:03:32 2009 +0200
+++ b/res/values-fr/strings.xml Thu Oct 01 18:20:15 2009 +0200
@@ -34,12 +34,8 @@
<!-- ContactDialog class -->
<string name="CDChat">Chat</string>
- <string name="CDAlias">Alias</string>
<string name="CDCall">Appeller</string>
- <string name="CDResend">Réenvoyer la demande</string>
- <string name="CDInfos">Informations utilisateur</string>
- <string name="CDBlock">Bloquer l\'utilisateur</string>
- <string name="CDDelete">Supprimer l\'utilisateur</string>
+ <string name="CDInfos">Gestion utilisateur</string>
<string name="CDSure2Delete">Êtes-vous sûr de vouloir supprimer ce contact ?</string>
<string name="CDSure2DeleteYes">Oui</string>
<string name="CDSure2DeleteNo">Non</string>
@@ -211,4 +207,15 @@
<string name="contact_list_all_contact">Tous les contacts</string>
<string name="contact_list_no_group">Aucun groupe</string>
+ <!--
+ UserInfo Activity
+ -->
+ <string name="userinfo_label_alias">Alias</string>
+ <string name="userinfo_label_vcard">VCard</string>
+ <string name="userinfo_label_chg_group">Modifier groupe</string>
+ <string name="userinfo_label_re_suscription">Renvoyer souscription</string>
+ <string name="userinfo_label_block">Bloquer</string>
+ <string name="userinfo_label_delete">Supprimer</string>
+ <string name="userinfo_def_vcard">Informations utilisateur</string>
+ <string name="userinfo_resend">Souscription réenvoyée</string>
</resources>
--- a/src/com/beem/project/beem/service/RosterAdapter.java Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java Thu Oct 01 18:20:15 2009 +0200
@@ -3,7 +3,6 @@
*/
package com.beem.project.beem.service;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -85,15 +84,10 @@
* {@inheritDoc}
*/
@Override
- public void deleteContact(Contact contact, String group) throws RemoteException {
+ public void deleteContact(Contact contact) throws RemoteException {
try {
RosterEntry entry = mAdaptee.getEntry(contact.getJID());
- if (entry.getGroups().size() == 0) {
- mAdaptee.removeEntry(entry);
- } else {
- mAdaptee.getGroup(group).removeEntry(entry);
- mRosterListener.onEntryDeleteFromGroup(group, contact.getJID());
- }
+ mAdaptee.removeEntry(entry);
} catch (XMPPException e) {
e.printStackTrace();
}
@@ -107,7 +101,7 @@
try {
mAdaptee.createGroup(groupname);
} catch (IllegalArgumentException e) {
- //pas grave, plus simple a gerer comme ca.
+ // pas grave, plus simple a gerer comme ca.
Log.e(TAG, "Error while creating group", e);
}
}
@@ -201,7 +195,7 @@
* @param jid the jid of the entry which is deleted.
*/
public void onEntryDeleteFromGroup(String group, String jid) {
- //Log.i(TAG, "entry delete listener");
+ // Log.i(TAG, "entry delete listener");
final int n = mRemoteRosListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
@@ -220,7 +214,7 @@
*/
@Override
public void entriesAdded(Collection<String> addresses) {
- //Log.i(TAG, "Ajout de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
+ // Log.i(TAG, "Ajout de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
final int n = mRemoteRosListeners.beginBroadcast();
List<String> tab = new ArrayList<String>();
@@ -241,7 +235,7 @@
*/
@Override
public void entriesDeleted(Collection<String> addresses) {
- //Log.i(TAG, "Suppression de l'entry");
+ // Log.i(TAG, "Suppression de l'entry");
final int n = mRemoteRosListeners.beginBroadcast();
List<String> tab = new ArrayList<String>();
@@ -262,7 +256,7 @@
*/
@Override
public void entriesUpdated(Collection<String> addresses) {
- //Log.i(TAG, "Update de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
+ // Log.i(TAG, "Update de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
final int n = mRemoteRosListeners.beginBroadcast();
List<String> tab = new ArrayList<String>();
@@ -283,7 +277,7 @@
*/
@Override
public void presenceChanged(Presence presence) {
- //Log.i(TAG, "presence Changed");
+ // Log.i(TAG, "presence Changed");
/* redispatch vers les IBeemRosterListener */
final int n = mRemoteRosListeners.beginBroadcast();
--- a/src/com/beem/project/beem/service/aidl/IRoster.aidl Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IRoster.aidl Thu Oct 01 18:20:15 2009 +0200
@@ -8,7 +8,7 @@
Contact addContact(in String user, in String name, in String[] groups);
- void deleteContact(in Contact contact, in String group);
+ void deleteContact(in Contact contact);
Contact getContact(in String jid);
void setContactName(in String jid, in String name);
--- a/src/com/beem/project/beem/ui/AddContact.java Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java Thu Oct 01 18:20:15 2009 +0200
@@ -23,6 +23,7 @@
import com.beem.project.beem.R;
import com.beem.project.beem.service.aidl.IXmppFacade;
import com.beem.project.beem.utils.BeemBroadcastReceiver;
+
/**
* This activity is used to add a contact.
* @author nikita
@@ -43,7 +44,8 @@
/**
* Constructor.
*/
- public AddContact() { }
+ public AddContact() {
+ }
/**
* {@inheritDoc}
@@ -87,7 +89,8 @@
/**
* Constructor.
*/
- public BeemServiceConnection() { }
+ public BeemServiceConnection() {
+ }
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
@@ -123,7 +126,7 @@
boolean isEmail = Pattern.matches("[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}", login);
if (!isEmail) {
Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedLoginError), Toast.LENGTH_SHORT)
- .show();
+ .show();
return;
}
String alias;
@@ -134,14 +137,13 @@
if (mXmppFacade != null) {
if (mXmppFacade.getRoster().getContact(login) != null)
mGroup.addAll(mXmppFacade.getRoster().getContact(login).getGroups());
- if (mXmppFacade.getRoster().addContact(login, alias,
- mGroup.toArray(new String[mGroup.size()])) == null) {
+ if (mXmppFacade.getRoster().addContact(login, alias, mGroup.toArray(new String[mGroup.size()])) == null) {
Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedError), Toast.LENGTH_SHORT)
- .show();
+ .show();
return;
} else {
Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded), Toast.LENGTH_SHORT)
- .show();
+ .show();
finish();
}
}
--- a/src/com/beem/project/beem/ui/ContactDialog.java Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java Thu Oct 01 18:20:15 2009 +0200
@@ -1,58 +1,50 @@
package com.beem.project.beem.ui;
-import org.jivesoftware.smack.packet.Presence;
-
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
-import android.util.Log;
import android.view.View;
import android.widget.Button;
import com.beem.project.beem.BeemService;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
-import com.beem.project.beem.service.PresenceAdapter;
import com.beem.project.beem.service.aidl.IXmppFacade;
+/**
+ * This activity class provides the view to show dialog when long click on contact list.
+ * @author marseille
+ */
public class ContactDialog extends Dialog {
- public static final String TAG = "Option Dialog";
private final Contact mContact;
- private final String mGroup;
private final Context mContext;
- private IXmppFacade mXmppFacade = null;
+ private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
- public ContactDialog(final Context context, Contact curContact, String group) {
+ /**
+ * Constructor.
+ * @param context context where is call the dialog.
+ * @param curContact current contact.
+ */
+ public ContactDialog(final Context context, final Contact curContact) {
super(context);
mContext = context;
setContentView(R.layout.contactdialog);
mContact = curContact;
- mGroup = group;
setTitle(curContact.getJID());
Button button = (Button) findViewById(R.id.CDChat);
- button.setOnClickListener(new chatListener());
- button = (Button) findViewById(R.id.CDAlias);
- button.setOnClickListener(new aliasListener());
- button = (Button) findViewById(R.id.CDDelete);
- button.setOnClickListener(new deleteListener());
- button = (Button) findViewById(R.id.CDResend);
- button.setOnClickListener(new resendListener());
- button = (Button) findViewById(R.id.CDBlock);
- button.setOnClickListener(new blockListener());
+ button.setOnClickListener(new ChatListener());
button = (Button) findViewById(R.id.CDInfos);
- button.setOnClickListener(new infosListener());
+ button.setOnClickListener(new InfosListener());
button = (Button) findViewById(R.id.CDCall);
button.setOnClickListener(new CallListener());
@@ -65,49 +57,38 @@
mContext.unbindService(mServConn);
}
+ /**
+ * Event simple click on call button.
+ */
class CallListener implements View.OnClickListener {
+ /**
+ * Constructor.
+ */
+ public CallListener() {
+ }
+
@Override
public void onClick(View v) {
try {
- //TODO: permettre a l'user de choisir a quel ressource il veut faire le call.
+ //TODO permettre a l'user de choisir a quel ressource il veut faire le call.
mXmppFacade.call(mContact.getJID() + "/BEEM");
} catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- }
-
- class aliasListener implements View.OnClickListener {
-
- @Override
- public void onClick(View v) {
-
- ContactDialogAliasDialog dialog = new ContactDialogAliasDialog(mContext, mContact);
- dialog.setOwnerActivity(ContactDialog.this.getOwnerActivity());
- dialog.initService(mXmppFacade);
- dialog.show();
- }
-
- }
-
- class blockListener implements View.OnClickListener {
-
- @Override
- public void onClick(View v) {
- try {
- mXmppFacade.blockUser(mContact.getJID());
- } catch (RemoteException e) {
e.printStackTrace();
}
- dismiss();
- }
+ }
}
- class chatListener implements View.OnClickListener {
+ /**
+ * Event simple click on chat button.
+ */
+ class ChatListener implements View.OnClickListener {
+
+ /**
+ * Constructor.
+ */
+ public ChatListener() {
+ }
@Override
public void onClick(View v) {
@@ -120,64 +101,39 @@
}
- class deleteListener implements View.OnClickListener {
+ /**
+ * Event simple click on info button.
+ */
+ class InfosListener implements View.OnClickListener {
- @Override
- public void onClick(View v) {
- final Activity a = ContactDialog.this.getOwnerActivity();
- AlertDialog.Builder builder = new AlertDialog.Builder(a);
- builder.setMessage(a.getString(R.string.CDDelete)).setCancelable(false).setPositiveButton(
- a.getString(R.string.CDSure2DeleteYes), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- try {
- mXmppFacade.getRoster().deleteContact(mContact, mGroup);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- dismiss();
- }
- }).setNegativeButton(a.getString(R.string.CDSure2DeleteNo), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
+ /**
+ * Constructor.
+ */
+ public InfosListener() {
}
- }
-
- class infosListener implements View.OnClickListener {
@Override
public void onClick(View v) {
Activity a = ContactDialog.this.getOwnerActivity();
- Intent i = new Intent(mContext, GroupList.class);
- //i.setData(mContact.toUri());
- i.putExtra("JID", mContact.getJID());
+ Intent i = new Intent(mContext, UserInfo.class);
+ i.setData(mContact.toUri());
a.startActivity(i);
dismiss();
}
}
- class resendListener implements View.OnClickListener {
+ /**
+ * The service connection used to connect to the Beem service.
+ */
+ private class BeemServiceConnection implements ServiceConnection {
- @Override
- public void onClick(View v) {
- Presence presencePacket = new Presence(Presence.Type.subscribe);
- presencePacket.setTo(mContact.getJID());
- try {
- mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket));
- } catch (RemoteException e) {
- Log.e(TAG, "resend subscription error", e);
- }
- dismiss();
+ /**
+ * Constructor.
+ */
+ public BeemServiceConnection() {
}
- }
-
- private class BeemServiceConnection implements ServiceConnection {
-
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mXmppFacade = IXmppFacade.Stub.asInterface(service);
--- a/src/com/beem/project/beem/ui/ContactDialogAliasDialog.java Thu Oct 01 18:03:32 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/**
- *
- */
-package com.beem.project.beem.ui;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-
-import com.beem.project.beem.R;
-import com.beem.project.beem.service.Contact;
-import com.beem.project.beem.service.aidl.IXmppFacade;
-
-/**
- * @author marseille
- */
-public class ContactDialogAliasDialog extends Dialog {
-
- protected static final String TAG = "CAlias";
- private Contact mContact;
- private IXmppFacade mService;
-
- public ContactDialogAliasDialog(Context context, Contact contact) {
- super(context);
- setContentView(R.layout.contactdialogaliasdialog);
- setTitle("Alias");
- mContact = contact;
- EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
- nameText.setText(mContact.getName());
-
- Button ok = (Button) findViewById(R.id.CDAliasDialogOk);
- ok.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
- EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
- try {
- Log.d(TAG, mContact.getJID() + nameText.getText().toString());
- mService.getRoster().setContactName(mContact.getJID(), nameText.getText().toString());
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- dismiss();
- }
-
- });
- }
-
- public void initService(IXmppFacade service) {
- mService = service;
- }
-}
--- a/src/com/beem/project/beem/ui/ContactList.java Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Oct 01 18:20:15 2009 +0200
@@ -50,7 +50,7 @@
*/
public class ContactList extends Activity {
- //private static final String TAG = "CONTACTLIST_ACT";
+ // private static final String TAG = "CONTACTLIST_ACT";
private static final Intent SERVICE_INTENT = new Intent();
private static final int REQUEST_CODE = 1;
private BeemContactList mAdapterContactList;
@@ -166,7 +166,7 @@
*/
@Override
protected void onStop() {
- Log.d("CONTACTLIST","onStop");
+ Log.d("CONTACTLIST", "onStop");
super.onStop();
if (mReceiver.isBinded())
unbindService(mServConn);
@@ -235,7 +235,7 @@
* buildBanner.
*/
private void buildBanner() {
- Gallery g = (Gallery) findViewById(R.id.gallery);
+ Gallery g = (Gallery) findViewById(R.id.contactlist_banner);
g.setOnItemClickListener(new OnItemClickGroupName());
g.setAdapter(mAdapterBanner);
}
@@ -280,7 +280,7 @@
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View v, int pos, long lpos) {
Contact c = mListContact.get(pos);
- ContactDialog dialogContact = new ContactDialog(ContactList.this, c, mCurGroup);
+ ContactDialog dialogContact = new ContactDialog(ContactList.this, c);
dialogContact.setOwnerActivity(ContactList.this);
dialogContact.show();
return true;
@@ -288,7 +288,7 @@
}
/**
- * Event on middle groupe name.
+ * Event simple click on middle groupe name.
*/
private class OnItemClickGroupName implements OnItemClickListener {
@@ -484,6 +484,13 @@
}
Contact c = mListContact.get(position);
+ if (mRoster != null) {
+ try {
+ c = mRoster.getContact(c.getJID());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
bindView(v, c);
return v;
}
@@ -521,7 +528,7 @@
break;
default:
imageDrawable = getResources().getDrawable(R.drawable.error);
- break;
+ break;
}
imgV.setImageDrawable(imageDrawable);
--- a/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Thu Oct 01 18:20:15 2009 +0200
@@ -5,6 +5,9 @@
import com.beem.project.beem.R;
+/**
+ * Class to show smiley in sendim.
+ */
public class SendIMDialogSmiley extends Dialog {
@SuppressWarnings("unused")
@@ -12,7 +15,12 @@
@SuppressWarnings("unused")
private SharedPreferences mSet;
- public SendIMDialogSmiley(SendIM sendim, SharedPreferences settings) {
+ /**
+ * Constructor.
+ * @param sendim unused
+ * @param settings unused
+ */
+ public SendIMDialogSmiley(final SendIM sendim, final SharedPreferences settings) {
super(sendim);
this.mSendIM = sendim;
this.mSet = settings;
--- a/src/com/beem/project/beem/ui/UserInfo.java Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/UserInfo.java Thu Oct 01 18:20:15 2009 +0200
@@ -1,22 +1,37 @@
package com.beem.project.beem.ui;
-import java.util.ArrayList;
import java.util.List;
+import org.jivesoftware.smack.packet.Presence;
+
import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
+import android.os.IBinder;
+import android.os.RemoteException;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
import android.widget.BaseAdapter;
-import android.widget.ListView;
-import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Gallery;
+import android.widget.TextView;
+import android.widget.Toast;
+import com.beem.project.beem.BeemService;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
+import com.beem.project.beem.service.PresenceAdapter;
+import com.beem.project.beem.service.aidl.IRoster;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
/**
* This activity class provides the view for user infos after long click on a correspondant.
@@ -24,11 +39,17 @@
*/
public class UserInfo extends Activity {
+ private static final Intent SERVICE_INTENT = new Intent();
+ private final ServiceConnection mServConn = new BeemServiceConnection();
+ private TextView mTextAlias;
+ private Gallery mGalleryGroups;
private Contact mContact;
- private static final List<String> mInfo = new ArrayList<String>();
+ private IXmppFacade mXmppFacade;
+ private BeemBroadcastReceiver mReceiver;
+ private String mJID;
static {
- mInfo.add("alias");
+ SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
}
/**
@@ -44,35 +65,150 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.userinfo);
- mContact = new Contact(getIntent().getData());
- setTitle(mContact.getName());
- ListView listview = (ListView) findViewById(R.id.userinfo);
- listview.setAdapter(new BeemUserInfo(this));
- listview.setOnItemClickListener(new BeemUserInfoClick());
+ View v = (View) findViewById(R.id.userinfo_layout_alias);
+ v.setOnClickListener(new AliasListener());
+ v = findViewById(R.id.userinfo_layout_delete);
+ v.setOnClickListener(new DeleteListener());
+ v = findViewById(R.id.userinfo_layout_chg_group);
+ v.setOnClickListener(new GroupListener());
+ v = findViewById(R.id.userinfo_layout_re_suscription);
+ v.setOnClickListener(new ResendListener());
+ mTextAlias = (TextView) findViewById(R.id.userinfo_alias);
+ mGalleryGroups = (Gallery) findViewById(R.id.userinfo_groups);
+ mReceiver = new BeemBroadcastReceiver(mServConn);
+ mJID = getIntent().getData().getEncodedSchemeSpecificPart();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onResume() {
+ super.onResume();
+ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
+ bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+ mReceiver.setBinded();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onPause() {
+ super.onPause();
+ this.unregisterReceiver(mReceiver);
+ if (mReceiver.isBinded())
+ unbindService(mServConn);
+ }
+
+ /**
+ * Event simple click on layout alias.
+ */
+ private class AliasListener implements View.OnClickListener {
+ /**
+ * Constructor.
+ */
+ public AliasListener() {
+ }
+
+ @Override
+ public void onClick(View v) {
+ Dialog d = new DialogAlias();
+ d.show();
+ }
+
}
/**
- * Event simple click on item of the user info.
+ * Event simple click on layout group.
+ */
+ private class GroupListener implements View.OnClickListener {
+ /**
+ * Constructor.
+ */
+ public GroupListener() {
+ }
+
+ @Override
+ public void onClick(View v) {
+ Intent i = new Intent(UserInfo.this, GroupList.class);
+ i.putExtra("JID", mContact.getJID());
+ startActivity(i);
+ }
+
+ }
+
+ /**
+ * Create dialog alias.
*/
- public class BeemUserInfoClick implements OnItemClickListener {
- @Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
- Log.i("OOO", mInfo.get(arg2));
+ public class DialogAlias extends Dialog {
+
+ /**
+ * Constructor.
+ */
+ public DialogAlias() {
+ super(UserInfo.this);
+ setContentView(R.layout.contactdialogaliasdialog);
+ setTitle(mContact.getJID());
+ EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
+ if (mContact.getName().length() == 0)
+ nameText.setText(mContact.getJID());
+ else
+ nameText.setText(mContact.getName());
+ Button ok = (Button) findViewById(R.id.CDAliasDialogOk);
+ ok.setOnClickListener(new ContactDialogAliasDialogOK());
+ }
+
+ /**
+ * Event click on the button OK.
+ */
+ private class ContactDialogAliasDialogOK implements View.OnClickListener {
+
+ /**
+ * Constructor.
+ */
+ public ContactDialogAliasDialogOK() {
+ }
+
+ @Override
+ public void onClick(View v) {
+ IRoster r;
+ try {
+ r = mXmppFacade.getRoster();
+ if (r != null) {
+ EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
+ String name = nameText.getText().toString();
+ if (name.length() == 0)
+ name = mContact.getJID();
+ r.setContactName(mContact.getJID(), name);
+ mContact.setName(name);
+ mTextAlias.setText(name);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ dismiss();
+ }
}
}
/**
- * Adapter user info list.
+ * Adapter group horizontal list.
*/
- public class BeemUserInfo extends BaseAdapter {
- private LayoutInflater mInflater;
+ public class BeemGroups extends BaseAdapter {
+ private Context mContext;
+ private List<String> mListGroup;
/**
* Constructor.
* @param c context activity.
+ * @param listGroup the user group list.
*/
- public BeemUserInfo(final Context c) {
- mInflater = LayoutInflater.from(c);
+ public BeemGroups(final Context c, final List<String> listGroup) {
+ mContext = c;
+ if (listGroup.size() == 0)
+ listGroup.add("No Group");
+ mListGroup = listGroup;
}
/**
@@ -80,7 +216,7 @@
*/
@Override
public int getCount() {
- return mInfo.size();
+ return mListGroup.size();
}
/**
@@ -104,13 +240,109 @@
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- View v = convertView;
- if (convertView == null) {
- if (position == 0)
- v = mInflater.inflate(R.layout.userinfo_alias, null);
+ TextView textView = new TextView(mContext);
+ textView.setText(mListGroup.get(position));
+ return textView;
+ }
+
+ }
+
+ /**
+ * Event simple click on layout resend suscription.
+ */
+ class ResendListener implements View.OnClickListener {
+
+ /**
+ * Constructor.
+ */
+ public ResendListener() {
+ }
+
+ @Override
+ public void onClick(View v) {
+ Presence presencePacket = new Presence(Presence.Type.subscribe);
+ presencePacket.setTo(mContact.getJID());
+ try {
+ mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket));
+ } catch (RemoteException e) {
+ e.printStackTrace();
}
- return v;
+ Toast.makeText(UserInfo.this, getString(R.string.userinfo_resend), Toast.LENGTH_LONG).show();
+ }
+
+ }
+
+ /**
+ * Event simple click on layout delete.
+ */
+ class DeleteListener implements View.OnClickListener {
+
+ /**
+ * Constructor.
+ */
+ public DeleteListener() {
+ }
+
+ @Override
+ public void onClick(View v) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(UserInfo.this);
+ builder.setMessage(UserInfo.this.getString(R.string.CDSure2Delete)).setCancelable(false).setPositiveButton(
+ UserInfo.this.getString(R.string.CDSure2DeleteYes), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ try {
+ mXmppFacade.getRoster().deleteContact(mContact);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }).setNegativeButton(UserInfo.this.getString(R.string.CDSure2DeleteNo),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
}
}
+ /**
+ * The ServiceConnection used to connect to the Beem service.
+ */
+ private class BeemServiceConnection implements ServiceConnection {
+
+ /**
+ * Constructor.
+ */
+ public BeemServiceConnection() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mXmppFacade = IXmppFacade.Stub.asInterface(service);
+ try {
+ IRoster r = mXmppFacade.getRoster();
+ if (r != null) {
+
+ setTitle(mJID);
+ mContact = r.getContact(mJID);
+ mTextAlias.setText(mContact.getName());
+ mGalleryGroups.setAdapter(new BeemGroups(UserInfo.this, mContact.getGroups()));
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ mXmppFacade = null;
+ }
+ }
}