Merge.
authorVincent Veronis <veroni_v@epitech.net>
Sat, 03 Oct 2009 12:40:08 +0200
changeset 442 8a6ed83557c8
parent 441 de9f5da0a294 (current diff)
parent 439 bd4ab0cd1a34 (diff)
child 444 5fedf5cec9c9
Merge.
--- a/src/com/beem/project/beem/ui/ContactDialog.java	Sat Oct 03 12:39:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java	Sat Oct 03 12:40:08 2009 +0200
@@ -119,7 +119,7 @@
 	public void onClick(View v) {
 	    Activity a = ContactDialog.this.getOwnerActivity();
 	    Intent i = new Intent(mContext, UserInfo.class);
-	    i.setData(mContact.toUri());
+	    i.putExtra("contact", mContact);
 	    a.startActivity(i);
 	    dismiss();
 	}
--- a/src/com/beem/project/beem/ui/GroupList.java	Sat Oct 03 12:39:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/GroupList.java	Sat Oct 03 12:40:08 2009 +0200
@@ -9,7 +9,9 @@
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.View;
+import android.view.View.OnKeyListener;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
 import android.widget.TextView;
@@ -35,9 +37,7 @@
     private IRoster mRoster;
     private String mJID;
     private ArrayAdapter<String> mGroups;
-
     private Contact mContact;
-
     private TextView mText;
 
     static {
@@ -55,13 +55,15 @@
 	super.onCreate(savedInstanceState);
 	setContentView(R.layout.group_list);
 	mReceiver = new BeemBroadcastReceiver(mServConn);
-	mJID = getIntent().getStringExtra("JID");
+	mContact = getIntent().getParcelableExtra("contact");
+	mJID = mContact.getJID();
 	final ListView listView = getListView();
 
 	listView.setItemsCanFocus(false);
 	listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
 
 	mText = (TextView) findViewById(R.id.GroupListText);
+	mText.setOnKeyListener(new GroupListOnKeyListener());
     }
 
     /**
@@ -115,6 +117,25 @@
 	}
     }
 
+    private class GroupListOnKeyListener implements OnKeyListener {
+
+	@Override
+	public boolean onKey(View v, int keyCode, KeyEvent event) {
+	    if (event.getAction() == KeyEvent.ACTION_DOWN) {
+		switch (keyCode) {
+		    case KeyEvent.KEYCODE_DPAD_CENTER:
+		    case KeyEvent.KEYCODE_ENTER:
+			Log.d("GROUPLIST", "ADD GROUP");
+			return true;
+		    default:
+			return false;
+		}
+	    }
+	    return false;
+	}
+
+    }
+
     /**
      * The ServiceConnection used to connect to the Beem service.
      */
--- a/src/com/beem/project/beem/ui/UserInfo.java	Sat Oct 03 12:39:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/UserInfo.java	Sat Oct 03 12:40:08 2009 +0200
@@ -47,6 +47,7 @@
     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"));
@@ -76,7 +77,12 @@
 	mTextAlias = (TextView) findViewById(R.id.userinfo_alias);
 	mGalleryGroups = (Gallery) findViewById(R.id.userinfo_groups);
 	mReceiver = new BeemBroadcastReceiver(mServConn);
-	mJID = getIntent().getData().getEncodedSchemeSpecificPart();
+
+	mContact = getIntent().getParcelableExtra("contact");
+	mJID = mContact.getJID();
+	mTextAlias.setText(mContact.getName());
+	mGalleryGroups.setAdapter(new BeemGroups(UserInfo.this, mContact.getGroups()));
+	setTitle(mJID);
     }
 
     /**
@@ -116,7 +122,6 @@
 	    Dialog d = new DialogAlias();
 	    d.show();
 	}
-
     }
 
     /**
@@ -132,7 +137,7 @@
 	@Override
 	public void onClick(View v) {
 	    Intent i = new Intent(UserInfo.this, GroupList.class);
-	    i.putExtra("JID", mContact.getJID());
+	    i.putExtra("contact", mContact);
 	    startActivity(i);
 	}
 
@@ -172,18 +177,15 @@
 
 	    @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);
-		    }
+		    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();
 		}
@@ -263,25 +265,25 @@
 
 	    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();
-			}
-		    });
+	    .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();
 	}
@@ -303,21 +305,21 @@
 	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 {
-				mXmppFacade.getRoster().deleteContact(mContact);
-			    } catch (RemoteException e) {
-				e.printStackTrace();
-			    }
-			}
-		    }).setNegativeButton(UserInfo.this.getString(R.string.userinfo_no),
-		    new DialogInterface.OnClickListener() {
-			public void onClick(DialogInterface dialog, int id) {
-			    dialog.cancel();
-			}
-		    });
+	    .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();
+		    }
+		}
+	    }).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();
 	}
@@ -341,14 +343,7 @@
 	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()));
-		}
+		mRoster = mXmppFacade.getRoster();		
 	    } catch (RemoteException e) {
 		e.printStackTrace();
 	    }