2014-02-09 00:47:11 +01:00
|
|
|
package de.gultsch.chat.ui;
|
|
|
|
|
|
|
|
import de.gultsch.chat.R;
|
|
|
|
import de.gultsch.chat.entities.Contact;
|
|
|
|
import de.gultsch.chat.entities.Presences;
|
2014-02-09 02:05:46 +01:00
|
|
|
import de.gultsch.chat.utils.UIHelper;
|
2014-02-09 00:47:11 +01:00
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.app.Dialog;
|
|
|
|
import android.app.DialogFragment;
|
2014-02-09 02:05:46 +01:00
|
|
|
import android.net.Uri;
|
2014-02-09 00:47:11 +01:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.CheckBox;
|
2014-02-09 02:05:46 +01:00
|
|
|
import android.widget.ImageView;
|
2014-02-09 00:47:11 +01:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
public class DialogContactDetails extends DialogFragment {
|
|
|
|
|
|
|
|
private Contact contact = null;
|
|
|
|
boolean displayingInRoster = false;
|
|
|
|
|
|
|
|
public void setContact(Contact contact) {
|
|
|
|
this.contact = contact;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
|
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
|
|
|
View view = inflater.inflate(R.layout.dialog_contact_details, null);
|
2014-02-09 02:05:46 +01:00
|
|
|
TextView contactJid = (TextView) view.findViewById(R.id.details_contactjid);
|
2014-02-09 00:47:11 +01:00
|
|
|
TextView accountJid = (TextView) view.findViewById(R.id.details_account);
|
2014-02-09 02:05:46 +01:00
|
|
|
TextView status = (TextView) view.findViewById(R.id.details_contactstatus);
|
2014-02-09 00:47:11 +01:00
|
|
|
CheckBox send = (CheckBox) view.findViewById(R.id.details_send_presence);
|
|
|
|
CheckBox receive = (CheckBox) view.findViewById(R.id.details_receive_presence);
|
2014-02-09 02:05:46 +01:00
|
|
|
ImageView contactPhoto = (ImageView) view.findViewById(R.id.details_contact_picture);
|
2014-02-09 00:47:11 +01:00
|
|
|
|
|
|
|
boolean subscriptionSend = false;
|
|
|
|
boolean subscriptionReceive = false;
|
2014-02-09 14:10:52 +01:00
|
|
|
if (contact.getSubscription()!=null) {
|
|
|
|
if (contact.getSubscription().equals("both")) {
|
|
|
|
subscriptionReceive = true;
|
|
|
|
subscriptionSend = true;
|
|
|
|
} else if (contact.getSubscription().equals("from")) {
|
|
|
|
subscriptionSend = true;
|
|
|
|
} else if (contact.getSubscription().equals("to")) {
|
|
|
|
subscriptionReceive = true;
|
|
|
|
}
|
2014-02-09 00:47:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (contact.getMostAvailableStatus()) {
|
|
|
|
case Presences.CHAT:
|
|
|
|
status.setText("free to chat");
|
2014-02-09 02:05:46 +01:00
|
|
|
status.setTextColor(0xFF83b600);
|
2014-02-09 00:47:11 +01:00
|
|
|
break;
|
|
|
|
case Presences.ONLINE:
|
|
|
|
status.setText("online");
|
2014-02-09 02:05:46 +01:00
|
|
|
status.setTextColor(0xFF83b600);
|
2014-02-09 00:47:11 +01:00
|
|
|
break;
|
|
|
|
case Presences.AWAY:
|
|
|
|
status.setText("away");
|
2014-02-09 02:05:46 +01:00
|
|
|
status.setTextColor(0xFFffa713);
|
2014-02-09 00:47:11 +01:00
|
|
|
break;
|
|
|
|
case Presences.XA:
|
|
|
|
status.setText("extended away");
|
2014-02-09 02:05:46 +01:00
|
|
|
status.setTextColor(0xFFffa713);
|
2014-02-09 00:47:11 +01:00
|
|
|
break;
|
|
|
|
case Presences.DND:
|
|
|
|
status.setText("do not disturb");
|
2014-02-09 02:05:46 +01:00
|
|
|
status.setTextColor(0xFFe92727);
|
2014-02-09 00:47:11 +01:00
|
|
|
break;
|
|
|
|
case Presences.OFFLINE:
|
|
|
|
status.setText("offline");
|
2014-02-09 02:05:46 +01:00
|
|
|
status.setTextColor(0xFFe92727);
|
2014-02-09 00:47:11 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status.setText("offline");
|
2014-02-09 02:05:46 +01:00
|
|
|
status.setTextColor(0xFFe92727);
|
2014-02-09 00:47:11 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
send.setChecked(subscriptionSend);
|
|
|
|
receive.setChecked(subscriptionReceive);
|
|
|
|
contactJid.setText(contact.getJid());
|
|
|
|
accountJid.setText(contact.getAccount().getJid());
|
|
|
|
|
2014-02-09 02:05:46 +01:00
|
|
|
if (contact.getProfilePhoto()!=null) {
|
|
|
|
contactPhoto.setImageURI(Uri.parse(contact.getProfilePhoto()));
|
|
|
|
} else {
|
|
|
|
contactPhoto.setImageBitmap(UIHelper.getUnknownContactPicture(contact.getDisplayName(), 300));
|
|
|
|
}
|
|
|
|
|
2014-02-09 00:47:11 +01:00
|
|
|
builder.setView(view);
|
|
|
|
builder.setTitle(contact.getDisplayName());
|
|
|
|
|
|
|
|
builder.setNeutralButton("Done", null);
|
|
|
|
builder.setPositiveButton("Remove from roster", null);
|
|
|
|
return builder.create();
|
|
|
|
}
|
|
|
|
}
|