--- a/AndroidManifest.xml Fri Dec 04 14:25:30 2009 +0100
+++ b/AndroidManifest.xml Fri Dec 04 14:26:17 2009 +0100
@@ -53,12 +53,6 @@
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
</intent-filter>
</activity>
- <activity android:name=".ui.UserInfo" android:label="@string/user_info_name">
- <intent-filter android:label="Beem Connection">
- <action
- android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
- </intent-filter>
- </activity>
<activity android:name=".jingle.demo.JingleCallActivity"
android:label="JingleDemoCall">
<intent-filter>
--- a/res/layout/contactdialog.xml Fri Dec 04 14:25:30 2009 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +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="fill_parent">
-
- <Button android:id="@+id/CDChat" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CDChat" />
-
- <Button android:id="@+id/CDCall" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CDCall" />
-
- <Button android:id="@+id/CDInfos" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CDInfos" />
-
-</LinearLayout>
\ No newline at end of file
--- a/res/layout/contactdialogaliasdialog.xml Fri Dec 04 14:25:30 2009 +0100
+++ b/res/layout/contactdialogaliasdialog.xml Fri Dec 04 14:26:17 2009 +0100
@@ -2,13 +2,14 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
-
+ <TextView android:id="@+id/CDAliasDialogLabel"
+ android:layout_height="wrap_content" android:layout_width="wrap_content"
+ android:layout_marginLeft="20dip" android:layout_marginRight="20dip"
+ android:text="@string/userinfo_label_alias"
+ android:gravity="left" style="@style/Label" />
<EditText android:id="@+id/CDAliasDialogName"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:inputType="textPersonName" android:imeOptions="actionDone"
- android:singleLine="true" android:maxLines="1" />
-
- <Button android:id="@+id/CDAliasDialogOk" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/OkButton" />
-
+ android:layout_height="wrap_content" android:layout_width="fill_parent"
+ android:layout_marginLeft="20dip" android:layout_marginRight="20dip"
+ android:scrollHorizontally="true" android:autoText="false"
+ android:capitalize="none" android:gravity="fill_horizontal" />
</LinearLayout>
--- a/res/layout/userinfo.xml Fri Dec 04 14:25:30 2009 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <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_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/menu/contactlist_context.xml Fri Dec 04 14:25:30 2009 +0100
+++ b/res/menu/contactlist_context.xml Fri Dec 04 14:26:17 2009 +0100
@@ -1,5 +1,21 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/contact_list_context_menu_chat_item" android:title="@string/CDChat" />
- <item android:id="@+id/contact_list_context_menu_call_item" android:title="@string/CDCall" android:visible="false" />
- <item android:id="@+id/contact_list_context_menu_manage_user_item" android:title="@string/CDInfos" />
+ <item android:id="@+id/contact_list_context_menu_chat_item"
+ android:title="@string/CDChat" />
+ <item android:id="@+id/contact_list_context_menu_call_item"
+ android:title="@string/CDCall" android:visible="false" />
+ <item android:id="@+id/contact_list_context_menu_user_info"
+ android:title="@string/CDInfos">
+ <menu>
+ <item android:id="@+id/contact_list_context_menu_userinfo_alias"
+ android:title="@string/userinfo_label_alias" />
+ <item android:id="@+id/contact_list_context_menu_userinfo_group"
+ android:title="@string/userinfo_label_chg_group" />
+ <item android:id="@+id/contact_list_context_menu_userinfo_subscription"
+ android:title="@string/userinfo_label_re_subscription" />
+ <item android:id="@+id/contact_list_context_menu_userinfo_block"
+ android:title="@string/userinfo_label_block" />
+ <item android:id="@+id/contact_list_context_menu_userinfo_delete"
+ android:title="@string/userinfo_label_delete" />
+ </menu>
+ </item>
</menu>
--- a/res/values-fr/strings.xml Fri Dec 04 14:25:30 2009 +0100
+++ b/res/values-fr/strings.xml Fri Dec 04 14:26:17 2009 +0100
@@ -254,7 +254,7 @@
-->
<string name="userinfo_label_alias">Alias</string>
<string name="userinfo_label_chg_group">Modifier groupe</string>
- <string name="userinfo_label_re_suscription">Renvoyer l\'invitation</string>
+ <string name="userinfo_label_re_subscription">Renvoyer l\'invitation</string>
<string name="userinfo_label_block">Bloquer</string>
<string name="userinfo_label_delete">Supprimer</string>
<string name="userinfo_resend">Souscription réenvoyée</string>
--- a/res/values/strings.xml Fri Dec 04 14:25:30 2009 +0100
+++ b/res/values/strings.xml Fri Dec 04 14:26:17 2009 +0100
@@ -234,10 +234,10 @@
<string name="contact_list_all_contact">All contacts</string>
<string name="contact_list_no_group">No group</string>
- <!-- UserInfo Activity -->
+ <!-- UserInfo dialog -->
<string name="userinfo_label_alias">Alias</string>
<string name="userinfo_label_chg_group">Manage groups</string>
- <string name="userinfo_label_re_suscription">Resend invit</string>
+ <string name="userinfo_label_re_subscription">Resend invit</string>
<string name="userinfo_label_block">Block</string>
<string name="userinfo_label_delete">Delete</string>
<string name="userinfo_resend">Suscription resend</string>
--- a/src/com/beem/project/beem/ui/ContactDialog.java Fri Dec 04 14:25:30 2009 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-package com.beem.project.beem.ui;
-
-import android.app.Activity;
-import android.app.Dialog;
-import android.app.Service;
-import android.content.ComponentName;
-import android.content.Context;
-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.R;
-import com.beem.project.beem.service.Contact;
-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 {
-
- private static final Intent SERVICE_INTENT = new Intent();
- private final Contact mContact;
- private final Context mContext;
- private IXmppFacade mXmppFacade;
- private final ServiceConnection mServConn = new BeemServiceConnection();
-
- static {
- SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
- }
-
- /**
- * 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;
- setTitle(curContact.getJID());
-
- Button button = (Button) findViewById(R.id.CDChat);
- button.setOnClickListener(new ChatListener());
- button = (Button) findViewById(R.id.CDInfos);
- button.setOnClickListener(new InfosListener());
- button = (Button) findViewById(R.id.CDCall);
- button.setOnClickListener(new CallListener());
- mContext.bindService(SERVICE_INTENT, mServConn, Service.BIND_AUTO_CREATE);
- }
-
- @Override
- protected void onStop() {
- // TODO Auto-generated method stub
- super.onStop();
- mContext.unbindService(mServConn);
- }
-
- @Override
- public void dismiss() {
- super.dismiss();
-
- }
-
- /**
- * 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.
- mXmppFacade.call(mContact.getJID() + "/psi");
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Event simple click on chat button.
- */
- class ChatListener implements View.OnClickListener {
-
- /**
- * Constructor.
- */
- public ChatListener() {
- }
-
- @Override
- public void onClick(View v) {
- Activity a = ContactDialog.this.getOwnerActivity();
- Intent i = new Intent(mContext, Chat.class);
- i.setData(mContact.toUri());
- a.startActivity(i);
- dismiss();
- }
-
- }
-
- /**
- * Event simple click on info button.
- */
- class InfosListener implements View.OnClickListener {
-
- /**
- * Constructor.
- */
- public InfosListener() {
- }
-
- @Override
- public void onClick(View v) {
- Activity a = ContactDialog.this.getOwnerActivity();
- Intent i = new Intent(mContext, UserInfo.class);
- Log.i("OOO", mContact.getJID());
- i.putExtra("contact_contactdialog", mContact.getJID());
- a.startActivity(i);
- dismiss();
- }
-
- }
-
- /**
- * The service connection used to connect to the Beem service.
- */
- private class BeemServiceConnection implements ServiceConnection {
-
- /**
- * Constructor.
- */
- public BeemServiceConnection() {
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mXmppFacade = IXmppFacade.Stub.asInterface(service);
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mXmppFacade = null;
- }
- }
-
-}
--- a/src/com/beem/project/beem/ui/ContactList.java Fri Dec 04 14:25:30 2009 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri Dec 04 14:26:17 2009 +0100
@@ -7,11 +7,15 @@
import java.util.List;
import java.util.Map;
+import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils;
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;
@@ -32,10 +36,13 @@
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
+import android.widget.EditText;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import com.beem.project.beem.R;
@@ -62,6 +69,7 @@
private final List<String> mListGroup = new ArrayList<String>();
private final Map<String, List<Contact>> mContactOnGroup = new HashMap<String, List<Contact>>();
private String mCurGroup;
+ private Contact mContact;
private Handler mHandler;
private IXmppFacade mXmppFacade;
private SharedPreferences mSettings;
@@ -69,7 +77,6 @@
private BeemBroadcastReceiver mReceiver;
private final Map<Integer, Bitmap> mIconsMap = new HashMap<Integer, Bitmap>();
private LayoutInflater mInflater;
- private ContactDialog mContactDialog;
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -137,9 +144,16 @@
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
- // TODO gere les info du context menu pour afficher que pour le bon long click
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.contactlist_context, menu);
+ AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
+ Contact c = mListContact.get(info.position);
+ try {
+ mContact = mRoster.getContact(c.getJID());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ menu.setHeaderTitle(mContact.getJID());
}
/**
@@ -147,34 +161,46 @@
*/
@Override
public boolean onContextItemSelected(MenuItem item) {
- ContextMenu.ContextMenuInfo i = item.getMenuInfo();
- if (i != null && i instanceof AdapterView.AdapterContextMenuInfo) {
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) i;
- Contact c = mListContact.get(info.position);
- Intent in;
- if (c != null) {
- switch (item.getItemId()) {
- case R.id.contact_list_context_menu_chat_item:
- in = new Intent(this, Chat.class);
- in.setData(c.toUri());
- startActivity(in);
+ Intent in;
+ if (mContact != null) {
+ switch (item.getItemId()) {
+ case R.id.contact_list_context_menu_chat_item:
+ in = new Intent(this, Chat.class);
+ in.setData(mContact.toUri());
+ startActivity(in);
+ return true;
+ case R.id.contact_list_context_menu_call_item:
+ try {
+ mXmppFacade.call(mContact.getJID() + "/psi");
return true;
- case R.id.contact_list_context_menu_call_item:
- try {
- mXmppFacade.call(c.getJID() + "/psi");
- return true;
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- case R.id.contact_list_context_menu_manage_user_item:
- in = new Intent(this, UserInfo.class);
- //TODO use in.setData(c.toUri()); a la place
- in.putExtra("contact_contactdialog", c.getJID());
- startActivity(in);
- return true;
- default:
- return super.onContextItemSelected(item);
- }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return true;
+ case R.id.contact_list_context_menu_user_info:
+ item.getSubMenu().setHeaderTitle(mContact.getJID());
+ return true;
+ case R.id.contact_list_context_menu_userinfo_alias:
+ Dialog alias = new DialogAlias(ContactList.this).create();
+ alias.show();
+ return true;
+ case R.id.contact_list_context_menu_userinfo_group:
+ in = new Intent(this, GroupList.class);
+ in.putExtra("contact", mContact);
+ startActivity(in);
+ return true;
+ case R.id.contact_list_context_menu_userinfo_subscription:
+ Dialog subscription = new DialogResendSubscription(ContactList.this).create();
+ subscription.show();
+ return true;
+ case R.id.contact_list_context_menu_userinfo_block:
+ return true;
+ case R.id.contact_list_context_menu_userinfo_delete:
+ Dialog delete = new DialogDelete(ContactList.this).create();
+ delete.show();
+ return true;
+ default:
+ return super.onContextItemSelected(item);
}
}
return super.onContextItemSelected(item);
@@ -188,7 +214,6 @@
mListContact.clear();
stopService(SERVICE_INTENT);
finish();
- // startActivity(new Intent(this, Login.class));
}
}
}
@@ -208,8 +233,6 @@
@Override
protected void onStop() {
super.onStop();
- if (mContactDialog != null)
- mContactDialog.dismiss();
if (mReceiver.isBinded()) {
unbindService(mServConn);
mReceiver.setBinded(false);
@@ -340,8 +363,7 @@
R.drawable.status_available));
mIconsMap.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT, BitmapFactory.decodeResource(getResources(),
R.drawable.status_available));
- mIconsMap
- .put(Status.CONTACT_STATUS_AWAY, BitmapFactory.decodeResource(getResources(), R.drawable.status_away));
+ mIconsMap.put(Status.CONTACT_STATUS_AWAY, BitmapFactory.decodeResource(getResources(), R.drawable.status_away));
mIconsMap.put(Status.CONTACT_STATUS_BUSY, BitmapFactory.decodeResource(getResources(), R.drawable.status_dnd));
mIconsMap.put(Status.CONTACT_STATUS_DISCONNECT, BitmapFactory.decodeResource(getResources(),
R.drawable.status_offline));
@@ -564,7 +586,6 @@
return position;
}
-
/**
* {@inheritDoc}
*/
@@ -671,6 +692,143 @@
}
/**
+ * Create dialog alias.
+ */
+ public class DialogAlias extends AlertDialog.Builder {
+ private EditText mEditTextAlias;
+
+ /**
+ * Constructor.
+ * @param context context activity.
+ */
+ public DialogAlias(final Context context) {
+ super(context);
+ LayoutInflater factory = LayoutInflater.from(context);
+ final View textEntryView = factory.inflate(R.layout.contactdialogaliasdialog, null);
+ setTitle(mContact.getJID());
+ setView(textEntryView);
+ mEditTextAlias = (EditText) textEntryView.findViewById(R.id.CDAliasDialogName);
+ mEditTextAlias.setText(mContact.getName());
+ setPositiveButton("OK", new ContactDialogAliasDialog());
+ setNegativeButton("Cancel", new ContactDialogAliasDialog());
+ }
+
+ /**
+ * Event click listener.
+ */
+ class ContactDialogAliasDialog implements DialogInterface.OnClickListener {
+
+ /**
+ * Constructor.
+ */
+ public ContactDialogAliasDialog() {
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == Dialog.BUTTON_POSITIVE) {
+ String name = mEditTextAlias.getText().toString();
+ if (name.length() == 0)
+ name = mContact.getJID();
+ try {
+ mRoster.setContactName(mContact.getJID(), name);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create dialog resend subscription.
+ */
+ public class DialogResendSubscription extends AlertDialog.Builder {
+
+ /**
+ * Constructor.
+ * @param context context activity
+ */
+ public DialogResendSubscription(final Context context) {
+ super(context);
+ setMessage(R.string.userinfo_sureresend);
+ DialogClickListener dl = new DialogClickListener();
+ setPositiveButton(R.string.userinfo_yes, dl);
+ setNegativeButton(R.string.userinfo_no, dl);
+ }
+
+ /**
+ * Event click listener.
+ */
+ class DialogClickListener implements DialogInterface.OnClickListener {
+
+ /**
+ * Constructor.
+ */
+ DialogClickListener() {
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == Dialog.BUTTON_POSITIVE) {
+ Presence presencePacket = new Presence(Presence.Type.subscribe);
+ presencePacket.setTo(mContact.getJID());
+ try {
+ mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket));
+ Toast.makeText(ContactList.this, getString(R.string.userinfo_resend), Toast.LENGTH_SHORT)
+ .show();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+ }
+
+ /**
+ * Create dialog delete.
+ */
+ public class DialogDelete extends AlertDialog.Builder {
+
+ /**
+ * Constructor.
+ * @param context context activity.
+ */
+ public DialogDelete(final Context context) {
+ super(context);
+ setMessage(R.string.userinfo_sure2delete);
+ DialogClickListener dl = new DialogClickListener();
+ setPositiveButton(R.string.userinfo_yes, dl);
+ setNegativeButton(R.string.userinfo_no, dl);
+ }
+
+ /**
+ * Event click listener.
+ */
+ private class DialogClickListener implements DialogInterface.OnClickListener {
+ /**
+ * Constructor.
+ */
+ public DialogClickListener() {
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == Dialog.BUTTON_POSITIVE) {
+ try {
+ mRoster.deleteContact(mContact);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ }
+
+ /**
* The service connection used to connect to the Beem service.
*/
private class BeemServiceConnection implements ServiceConnection {
--- a/src/com/beem/project/beem/ui/Settings.java Fri Dec 04 14:25:30 2009 +0100
+++ b/src/com/beem/project/beem/ui/Settings.java Fri Dec 04 14:26:17 2009 +0100
@@ -93,9 +93,7 @@
startActivity(i);
return true;
case R.id.settings_menu_privacy_lists:
- /*
- * i = new Intent(this, PrivacyList.class); startActivity(i);
- */
+ i = new Intent(this, PrivacyList.class); startActivity(i);
return true;
default:
return false;
--- a/src/com/beem/project/beem/ui/UserInfo.java Fri Dec 04 14:25:30 2009 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,371 +0,0 @@
-package com.beem.project.beem.ui;
-
-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.os.IBinder;
-import android.os.RemoteException;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-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.
- * @author marseille
- */
-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 IXmppFacade mXmppFacade;
- private BeemBroadcastReceiver mReceiver;
- private String mJID;
- private IRoster mRoster;
-
- static {
- SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
- }
-
- /**
- * Constructor.
- */
- public UserInfo() {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.userinfo);
- 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);
- this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onResume() {
- super.onResume();
- bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onPause() {
- super.onPause();
- if (mReceiver.isBinded()) {
- unbindService(mServConn);
- mReceiver.setBinded(false);
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- this.unregisterReceiver(mReceiver);
- }
-
- /**
- * 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 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("contact", mContact);
- startActivity(i);
- }
-
- }
-
- /**
- * Create dialog alias.
- */
- 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) {
- try {
- EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
- String name = nameText.getText().toString();
- if (name.length() == 0)
- name = mContact.getJID();
- mRoster.setContactName(mContact.getJID(), name);
- mContact.setName(name);
- mTextAlias.setText(name);
-
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- dismiss();
- }
- }
- }
-
- /**
- * Adapter group horizontal list.
- */
- public class BeemGroups extends BaseAdapter {
- private Context mContext;
- private List<String> mListGroup;
-
- /**
- * Constructor.
- * @param c context activity.
- * @param listGroup the user group list.
- */
- public BeemGroups(final Context c, final List<String> listGroup) {
- mContext = c;
- if (listGroup.size() == 0)
- listGroup.add(getString(R.string.contact_list_no_group));
- mListGroup = listGroup;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getCount() {
- return mListGroup.size();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Object getItem(int position) {
- return position;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- TextView textView = new TextView(mContext);
- textView.setText(mListGroup.get(position));
- return textView;
- }
-
- }
-
- /**
- * Event simple click on layout resend suscription.
- */
- private class ResendListener implements View.OnClickListener {
-
- /**
- * Constructor.
- */
- public ResendListener() {
- }
-
- @Override
- public void onClick(View v) {
-
- AlertDialog.Builder builder = new AlertDialog.Builder(UserInfo.this);
- builder.setMessage(UserInfo.this.getString(R.string.userinfo_sureresend)).setCancelable(false)
- .setPositiveButton(UserInfo.this.getString(R.string.userinfo_yes),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- Presence presencePacket = new Presence(Presence.Type.subscribe);
- presencePacket.setTo(mContact.getJID());
- try {
- mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket));
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- Toast.makeText(UserInfo.this, getString(R.string.userinfo_resend), Toast.LENGTH_SHORT)
- .show();
- }
- }).setNegativeButton(UserInfo.this.getString(R.string.userinfo_no),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- }
-
- }
-
- /**
- * Event simple click on layout delete.
- */
- private 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.userinfo_sure2delete)).setCancelable(false)
- .setPositiveButton(UserInfo.this.getString(R.string.userinfo_yes),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- try {
- mRoster.deleteContact(mContact);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- finish();
- }
- }).setNegativeButton(UserInfo.this.getString(R.string.userinfo_no),
- 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);
- mReceiver.setBinded(true);
- try {
- mRoster = mXmppFacade.getRoster();
- mJID = getIntent().getStringExtra("contact_contactdialog");
- mContact = mRoster.getContact(mJID);
- if (mContact.getName() != null)
- mTextAlias.setText(mContact.getName());
- else
- mTextAlias.setText(mContact.getJID());
- mGalleryGroups.setAdapter(new BeemGroups(UserInfo.this, mContact.getGroups()));
- setTitle(mJID);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mXmppFacade = null;
- }
- }
-}