aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/ui
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/de/gultsch/chat/ui/ConversationActivity.java19
-rw-r--r--src/de/gultsch/chat/ui/ConversationFragment.java3
-rw-r--r--src/de/gultsch/chat/ui/DialogContactDetails.java42
3 files changed, 58 insertions, 6 deletions
diff --git a/src/de/gultsch/chat/ui/ConversationActivity.java b/src/de/gultsch/chat/ui/ConversationActivity.java
index 37a988fb..c5c03b12 100644
--- a/src/de/gultsch/chat/ui/ConversationActivity.java
+++ b/src/de/gultsch/chat/ui/ConversationActivity.java
@@ -37,6 +37,8 @@ public class ConversationActivity extends XmppActivity {
public static final String VIEW_CONVERSATION = "viewConversation";
public static final String CONVERSATION = "conversationUuid";
+
+ public static final int INSERT_CONTACT = 0x9889;
protected SlidingPaneLayout spl;
@@ -83,6 +85,7 @@ public class ConversationActivity extends XmppActivity {
});
}
};
+ private boolean contactInserted = false;
public List<Conversation> getConversationList() {
@@ -229,6 +232,8 @@ public class ConversationActivity extends XmppActivity {
if (this.getSelectedConversation()!=null) {
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
((MenuItem) menu.findItem(R.id.action_security)).setVisible(false);
+ ((MenuItem) menu.findItem(R.id.action_details)).setVisible(false);
+ ((MenuItem) menu.findItem(R.id.action_archive)).setTitle("Leave conference");
}
}
}
@@ -322,6 +327,13 @@ public class ConversationActivity extends XmppActivity {
@Override
void onBackendConnected() {
+
+ if (contactInserted) {
+ Log.d("xmppService","merge phone contacts with roster");
+ contactInserted = false;
+ xmppConnectionService.mergePhoneContactsWithRoster();
+ }
+
xmppConnectionService.setOnConversationListChangedListener(this.onConvChanged);
if (conversationList.size()==0) {
@@ -375,4 +387,11 @@ public class ConversationActivity extends XmppActivity {
}
}
}
+
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode==INSERT_CONTACT) {
+ Log.d("xmppService","contact inserted");
+ this.contactInserted = true;
+ }
+ }
}
diff --git a/src/de/gultsch/chat/ui/ConversationFragment.java b/src/de/gultsch/chat/ui/ConversationFragment.java
index 13e617fd..20451869 100644
--- a/src/de/gultsch/chat/ui/ConversationFragment.java
+++ b/src/de/gultsch/chat/ui/ConversationFragment.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import de.gultsch.chat.R;
+import de.gultsch.chat.entities.Contact;
import de.gultsch.chat.entities.Conversation;
import de.gultsch.chat.entities.Message;
import de.gultsch.chat.utils.UIHelper;
@@ -32,6 +33,7 @@ public class ConversationFragment extends Fragment {
protected LayoutInflater inflater;
protected List<Message> messageList = new ArrayList<Message>();
protected ArrayAdapter<Message> messageListAdapter;
+ protected Contact contact;
@Override
public View onCreateView(final LayoutInflater inflater,
@@ -40,7 +42,6 @@ public class ConversationFragment extends Fragment {
this.inflater = inflater;
-
final View view = inflater.inflate(R.layout.fragment_conversation,
container, false);
((ImageButton) view.findViewById(R.id.textSendButton))
diff --git a/src/de/gultsch/chat/ui/DialogContactDetails.java b/src/de/gultsch/chat/ui/DialogContactDetails.java
index 58e5f67f..88bded87 100644
--- a/src/de/gultsch/chat/ui/DialogContactDetails.java
+++ b/src/de/gultsch/chat/ui/DialogContactDetails.java
@@ -7,12 +7,19 @@ import de.gultsch.chat.utils.UIHelper;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.provider.ContactsContract.CommonDataKinds;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.Intents;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.ImageView;
+import android.widget.QuickContactBadge;
import android.widget.TextView;
public class DialogContactDetails extends DialogFragment {
@@ -34,7 +41,8 @@ public class DialogContactDetails extends DialogFragment {
TextView status = (TextView) view.findViewById(R.id.details_contactstatus);
CheckBox send = (CheckBox) view.findViewById(R.id.details_send_presence);
CheckBox receive = (CheckBox) view.findViewById(R.id.details_receive_presence);
- ImageView contactPhoto = (ImageView) view.findViewById(R.id.details_contact_picture);
+ //ImageView contactPhoto = (ImageView) view.findViewById(R.id.details_contact_picture);
+ QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.details_contact_badge);
boolean subscriptionSend = false;
boolean subscriptionReceive = false;
@@ -84,11 +92,35 @@ public class DialogContactDetails extends DialogFragment {
receive.setChecked(subscriptionReceive);
contactJid.setText(contact.getJid());
accountJid.setText(contact.getAccount().getJid());
+
+ UIHelper.prepareContactBadge(getActivity(), badge, contact);
- if (contact.getProfilePhoto()!=null) {
- contactPhoto.setImageURI(Uri.parse(contact.getProfilePhoto()));
- } else {
- contactPhoto.setImageBitmap(UIHelper.getUnknownContactPicture(contact.getDisplayName(), 300));
+ if (contact.getSystemAccount()==null) {
+ final DialogContactDetails details = this;
+ badge.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setTitle("Add to contacts");
+ builder.setMessage("Do you want to add "+contact.getJid()+" to your contact list?");
+ builder.setNegativeButton("Cancel", null);
+ builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
+ intent.setType(Contacts.CONTENT_ITEM_TYPE);
+ intent.putExtra(Intents.Insert.IM_HANDLE,contact.getJid());
+ intent.putExtra(Intents.Insert.IM_PROTOCOL,CommonDataKinds.Im.PROTOCOL_JABBER);
+ intent.putExtra("finishActivityOnSaveCompleted", true);
+ getActivity().startActivityForResult(intent,ConversationActivity.INSERT_CONTACT);
+ details.dismiss();
+ }
+ });
+ builder.create().show();
+ }
+ });
}
builder.setView(view);