2014-03-05 14:41:14 +00:00
|
|
|
package eu.siacs.conversations.ui;
|
|
|
|
|
|
|
|
import android.app.AlertDialog;
|
2014-05-09 18:47:03 +00:00
|
|
|
import android.app.PendingIntent;
|
2014-03-06 19:00:46 +00:00
|
|
|
import android.content.Context;
|
2014-03-05 14:41:14 +00:00
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
2014-05-09 18:47:03 +00:00
|
|
|
import android.content.IntentSender.SendIntentException;
|
2014-03-05 14:41:14 +00:00
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.provider.ContactsContract.CommonDataKinds;
|
|
|
|
import android.provider.ContactsContract.Contacts;
|
|
|
|
import android.provider.ContactsContract.Intents;
|
2014-03-06 19:00:46 +00:00
|
|
|
import android.view.LayoutInflater;
|
2014-03-05 14:41:14 +00:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
import android.widget.CheckBox;
|
2014-07-20 01:14:47 +00:00
|
|
|
import android.widget.CompoundButton;
|
2014-11-11 16:39:28 +00:00
|
|
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
2014-09-07 21:08:40 +00:00
|
|
|
import android.widget.ImageButton;
|
2014-03-06 19:00:46 +00:00
|
|
|
import android.widget.LinearLayout;
|
2014-03-05 14:41:14 +00:00
|
|
|
import android.widget.QuickContactBadge;
|
|
|
|
import android.widget.TextView;
|
2014-11-11 16:39:28 +00:00
|
|
|
|
|
|
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
2014-03-05 14:41:14 +00:00
|
|
|
import eu.siacs.conversations.R;
|
2014-05-09 18:47:03 +00:00
|
|
|
import eu.siacs.conversations.crypto.PgpEngine;
|
2014-05-19 13:15:09 +00:00
|
|
|
import eu.siacs.conversations.entities.Account;
|
2014-03-05 14:41:14 +00:00
|
|
|
import eu.siacs.conversations.entities.Contact;
|
|
|
|
import eu.siacs.conversations.entities.Presences;
|
2014-07-20 11:21:21 +00:00
|
|
|
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
2014-07-18 13:35:31 +00:00
|
|
|
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
2014-03-05 14:41:14 +00:00
|
|
|
import eu.siacs.conversations.utils.UIHelper;
|
2014-11-06 19:33:13 +00:00
|
|
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
|
|
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
2014-03-05 14:41:14 +00:00
|
|
|
|
2014-11-11 16:39:28 +00:00
|
|
|
public class ContactDetailsActivity extends XmppActivity implements OnAccountUpdate, OnRosterUpdate {
|
2014-03-05 14:41:14 +00:00
|
|
|
public static final String ACTION_VIEW_CONTACT = "view_contact";
|
|
|
|
|
|
|
|
private Contact contact;
|
|
|
|
private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2014-10-15 17:32:12 +00:00
|
|
|
ContactDetailsActivity.this.xmppConnectionService
|
|
|
|
.deleteContactOnServer(contact);
|
2014-10-08 14:37:43 +00:00
|
|
|
ContactDetailsActivity.this.finish();
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
};
|
2014-07-20 01:14:47 +00:00
|
|
|
private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView,
|
2014-11-11 16:39:28 +00:00
|
|
|
boolean isChecked) {
|
2014-07-20 01:14:47 +00:00
|
|
|
if (isChecked) {
|
2014-08-31 14:28:21 +00:00
|
|
|
if (contact
|
|
|
|
.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
2014-07-20 01:14:47 +00:00
|
|
|
xmppConnectionService.sendPresencePacket(contact
|
2014-11-11 16:39:28 +00:00
|
|
|
.getAccount(),
|
2014-07-20 01:14:47 +00:00
|
|
|
xmppConnectionService.getPresenceGenerator()
|
|
|
|
.sendPresenceUpdatesTo(contact));
|
|
|
|
} else {
|
|
|
|
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
|
|
|
|
xmppConnectionService.sendPresencePacket(contact.getAccount(),
|
|
|
|
xmppConnectionService.getPresenceGenerator()
|
|
|
|
.stopPresenceUpdatesTo(contact));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
private OnCheckedChangeListener mOnReceiveCheckedChange = new OnCheckedChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView,
|
2014-11-11 16:39:28 +00:00
|
|
|
boolean isChecked) {
|
2014-07-20 01:14:47 +00:00
|
|
|
if (isChecked) {
|
|
|
|
xmppConnectionService.sendPresencePacket(contact.getAccount(),
|
|
|
|
xmppConnectionService.getPresenceGenerator()
|
|
|
|
.requestPresenceUpdatesFrom(contact));
|
|
|
|
} else {
|
|
|
|
xmppConnectionService.sendPresencePacket(contact.getAccount(),
|
|
|
|
xmppConnectionService.getPresenceGenerator()
|
|
|
|
.stopPresenceUpdatesFrom(contact));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-11-11 16:39:28 +00:00
|
|
|
private Jid accountJid;
|
|
|
|
private Jid contactJid;
|
|
|
|
private TextView contactJidTv;
|
|
|
|
private TextView accountJidTv;
|
|
|
|
private TextView status;
|
|
|
|
private TextView lastseen;
|
|
|
|
private CheckBox send;
|
|
|
|
private CheckBox receive;
|
|
|
|
private QuickContactBadge badge;
|
|
|
|
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
2014-08-31 14:28:21 +00:00
|
|
|
|
2014-07-20 11:21:21 +00:00
|
|
|
@Override
|
2014-11-11 16:39:28 +00:00
|
|
|
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().toString());
|
|
|
|
intent.putExtra(Intents.Insert.IM_PROTOCOL,
|
|
|
|
CommonDataKinds.Im.PROTOCOL_JABBER);
|
|
|
|
intent.putExtra("finishActivityOnSaveCompleted", true);
|
|
|
|
ContactDetailsActivity.this.startActivityForResult(intent, 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
private OnClickListener onBadgeClick = new OnClickListener() {
|
2014-07-20 11:21:21 +00:00
|
|
|
|
2014-11-11 16:39:28 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
|
|
|
ContactDetailsActivity.this);
|
|
|
|
builder.setTitle(getString(R.string.action_add_phone_book));
|
|
|
|
builder.setMessage(getString(R.string.add_phone_book_text,
|
|
|
|
contact.getJid()));
|
|
|
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
|
|
|
builder.setPositiveButton(getString(R.string.add), addToPhonebook);
|
|
|
|
builder.create().show();
|
2014-07-20 11:21:21 +00:00
|
|
|
}
|
|
|
|
};
|
2014-11-11 16:39:28 +00:00
|
|
|
private LinearLayout keys;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRosterUpdate() {
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
populateView();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAccountUpdate() {
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
populateView();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-07-20 11:21:21 +00:00
|
|
|
|
2014-11-04 11:15:14 +00:00
|
|
|
@Override
|
|
|
|
protected String getShareableUri() {
|
2014-11-11 16:39:28 +00:00
|
|
|
if (contact != null) {
|
|
|
|
return "xmpp:" + contact.getJid();
|
2014-11-04 11:15:14 +00:00
|
|
|
} else {
|
2014-11-04 16:10:35 +00:00
|
|
|
return "";
|
2014-11-04 11:15:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-05 14:41:14 +00:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
|
2014-11-11 16:39:28 +00:00
|
|
|
try {
|
|
|
|
this.accountJid = Jid.fromString(getIntent().getExtras().getString("account"));
|
|
|
|
} catch (final InvalidJidException ignored) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
this.contactJid = Jid.fromString(getIntent().getExtras().getString("contact"));
|
|
|
|
} catch (final InvalidJidException ignored) {
|
|
|
|
}
|
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
setContentView(R.layout.activity_contact_details);
|
|
|
|
|
2014-05-19 13:15:09 +00:00
|
|
|
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
|
|
|
|
accountJidTv = (TextView) findViewById(R.id.details_account);
|
2014-03-05 14:41:14 +00:00
|
|
|
status = (TextView) findViewById(R.id.details_contactstatus);
|
2014-06-13 09:50:47 +00:00
|
|
|
lastseen = (TextView) findViewById(R.id.details_lastseen);
|
2014-03-05 14:41:14 +00:00
|
|
|
send = (CheckBox) findViewById(R.id.details_send_presence);
|
|
|
|
receive = (CheckBox) findViewById(R.id.details_receive_presence);
|
|
|
|
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
|
2014-03-06 19:00:46 +00:00
|
|
|
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
|
2014-03-05 14:41:14 +00:00
|
|
|
getActionBar().setHomeButtonEnabled(true);
|
|
|
|
getActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
2014-05-22 20:58:25 +00:00
|
|
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
2014-03-05 14:41:14 +00:00
|
|
|
switch (menuItem.getItemId()) {
|
2014-11-11 16:39:28 +00:00
|
|
|
case android.R.id.home:
|
|
|
|
finish();
|
|
|
|
break;
|
|
|
|
case R.id.action_delete_contact:
|
|
|
|
builder.setTitle(getString(R.string.action_delete_contact))
|
|
|
|
.setMessage(
|
|
|
|
getString(R.string.remove_contact_text,
|
|
|
|
contact.getJid()))
|
|
|
|
.setPositiveButton(getString(R.string.delete),
|
|
|
|
removeFromRoster).create().show();
|
|
|
|
break;
|
|
|
|
case R.id.action_edit_contact:
|
|
|
|
if (contact.getSystemAccount() == null) {
|
|
|
|
quickEdit(contact.getDisplayName(), new OnValueEdited() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onValueEdited(String value) {
|
|
|
|
contact.setServerName(value);
|
|
|
|
ContactDetailsActivity.this.xmppConnectionService
|
|
|
|
.pushContactToServer(contact);
|
|
|
|
populateView();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_EDIT);
|
|
|
|
String[] systemAccount = contact.getSystemAccount().split("#");
|
|
|
|
long id = Long.parseLong(systemAccount[0]);
|
|
|
|
Uri uri = Contacts.getLookupUri(id, systemAccount[1]);
|
|
|
|
intent.setDataAndType(uri, Contacts.CONTENT_ITEM_TYPE);
|
|
|
|
intent.putExtra("finishActivityOnSaveCompleted", true);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
break;
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(menuItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
getMenuInflater().inflate(R.menu.contact_details, menu);
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-07 19:36:04 +00:00
|
|
|
|
2014-03-05 14:41:14 +00:00
|
|
|
private void populateView() {
|
2014-07-21 13:17:01 +00:00
|
|
|
send.setOnCheckedChangeListener(null);
|
|
|
|
receive.setOnCheckedChangeListener(null);
|
2014-03-05 14:41:14 +00:00
|
|
|
setTitle(contact.getDisplayName());
|
2014-05-19 13:15:09 +00:00
|
|
|
if (contact.getOption(Contact.Options.FROM)) {
|
2014-07-20 01:14:47 +00:00
|
|
|
send.setText(R.string.send_presence_updates);
|
2014-03-05 14:41:14 +00:00
|
|
|
send.setChecked(true);
|
2014-07-20 01:14:47 +00:00
|
|
|
} else if (contact
|
|
|
|
.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
2014-07-11 11:52:27 +00:00
|
|
|
send.setChecked(false);
|
2014-07-20 01:14:47 +00:00
|
|
|
send.setText(R.string.send_presence_updates);
|
2014-03-05 14:41:14 +00:00
|
|
|
} else {
|
2014-05-13 09:23:11 +00:00
|
|
|
send.setText(R.string.preemptively_grant);
|
2014-07-20 01:14:47 +00:00
|
|
|
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
|
2014-03-05 14:41:14 +00:00
|
|
|
send.setChecked(true);
|
|
|
|
} else {
|
|
|
|
send.setChecked(false);
|
|
|
|
}
|
|
|
|
}
|
2014-05-19 13:15:09 +00:00
|
|
|
if (contact.getOption(Contact.Options.TO)) {
|
2014-07-20 01:14:47 +00:00
|
|
|
receive.setText(R.string.receive_presence_updates);
|
2014-03-05 14:41:14 +00:00
|
|
|
receive.setChecked(true);
|
|
|
|
} else {
|
2014-05-13 09:23:11 +00:00
|
|
|
receive.setText(R.string.ask_for_presence_updates);
|
2014-05-19 13:15:09 +00:00
|
|
|
if (contact.getOption(Contact.Options.ASKING)) {
|
2014-03-05 14:41:14 +00:00
|
|
|
receive.setChecked(true);
|
|
|
|
} else {
|
|
|
|
receive.setChecked(false);
|
|
|
|
}
|
|
|
|
}
|
2014-07-20 11:21:21 +00:00
|
|
|
if (contact.getAccount().getStatus() == Account.STATUS_ONLINE) {
|
|
|
|
receive.setEnabled(true);
|
|
|
|
send.setEnabled(true);
|
|
|
|
} else {
|
|
|
|
receive.setEnabled(false);
|
|
|
|
send.setEnabled(false);
|
|
|
|
}
|
2014-07-20 01:14:47 +00:00
|
|
|
|
2014-07-21 13:17:01 +00:00
|
|
|
send.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
|
|
|
receive.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
2014-08-31 14:28:21 +00:00
|
|
|
|
2014-07-20 01:14:47 +00:00
|
|
|
lastseen.setText(UIHelper.lastseen(getApplicationContext(),
|
|
|
|
contact.lastseen.time));
|
2014-03-05 14:41:14 +00:00
|
|
|
|
|
|
|
switch (contact.getMostAvailableStatus()) {
|
2014-11-11 16:39:28 +00:00
|
|
|
case Presences.CHAT:
|
|
|
|
status.setText(R.string.contact_status_free_to_chat);
|
|
|
|
status.setTextColor(mColorGreen);
|
|
|
|
break;
|
|
|
|
case Presences.ONLINE:
|
|
|
|
status.setText(R.string.contact_status_online);
|
|
|
|
status.setTextColor(mColorGreen);
|
|
|
|
break;
|
|
|
|
case Presences.AWAY:
|
|
|
|
status.setText(R.string.contact_status_away);
|
|
|
|
status.setTextColor(mColorOrange);
|
|
|
|
break;
|
|
|
|
case Presences.XA:
|
|
|
|
status.setText(R.string.contact_status_extended_away);
|
|
|
|
status.setTextColor(mColorOrange);
|
|
|
|
break;
|
|
|
|
case Presences.DND:
|
|
|
|
status.setText(R.string.contact_status_do_not_disturb);
|
|
|
|
status.setTextColor(mColorRed);
|
|
|
|
break;
|
|
|
|
case Presences.OFFLINE:
|
|
|
|
status.setText(R.string.contact_status_offline);
|
|
|
|
status.setTextColor(mSecondaryTextColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status.setText(R.string.contact_status_offline);
|
|
|
|
status.setTextColor(mSecondaryTextColor);
|
|
|
|
break;
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
2014-04-16 17:14:20 +00:00
|
|
|
if (contact.getPresences().size() > 1) {
|
2014-07-20 01:14:47 +00:00
|
|
|
contactJidTv.setText(contact.getJid() + " ("
|
|
|
|
+ contact.getPresences().size() + ")");
|
2014-04-16 17:14:20 +00:00
|
|
|
} else {
|
2014-11-06 19:33:13 +00:00
|
|
|
contactJidTv.setText(contact.getJid().toString());
|
2014-04-16 17:14:20 +00:00
|
|
|
}
|
2014-10-15 17:32:12 +00:00
|
|
|
accountJidTv.setText(getString(R.string.using_account, contact
|
2014-11-09 15:57:22 +00:00
|
|
|
.getAccount().getJid().toBareJid()));
|
2014-10-20 19:08:33 +00:00
|
|
|
prepareContactBadge(badge, contact);
|
2014-03-05 14:41:14 +00:00
|
|
|
if (contact.getSystemAccount() == null) {
|
|
|
|
badge.setOnClickListener(onBadgeClick);
|
|
|
|
}
|
2014-03-07 19:36:04 +00:00
|
|
|
|
2014-03-06 19:00:46 +00:00
|
|
|
keys.removeAllViews();
|
2014-10-13 10:36:41 +00:00
|
|
|
boolean hasKeys = false;
|
2014-03-06 19:00:46 +00:00
|
|
|
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
2014-03-07 19:36:04 +00:00
|
|
|
for (Iterator<String> iterator = contact.getOtrFingerprints()
|
2014-11-11 16:39:28 +00:00
|
|
|
.iterator(); iterator.hasNext(); ) {
|
2014-10-13 10:36:41 +00:00
|
|
|
hasKeys = true;
|
2014-09-07 21:08:40 +00:00
|
|
|
final String otrFingerprint = iterator.next();
|
2014-10-26 17:54:10 +00:00
|
|
|
View view = inflater.inflate(R.layout.contact_key, keys, false);
|
2014-03-06 19:00:46 +00:00
|
|
|
TextView key = (TextView) view.findViewById(R.id.key);
|
2014-03-07 19:36:04 +00:00
|
|
|
TextView keyType = (TextView) view.findViewById(R.id.key_type);
|
2014-09-08 21:58:37 +00:00
|
|
|
ImageButton remove = (ImageButton) view
|
|
|
|
.findViewById(R.id.button_remove);
|
2014-09-07 21:08:40 +00:00
|
|
|
remove.setVisibility(View.VISIBLE);
|
2014-03-06 19:00:46 +00:00
|
|
|
keyType.setText("OTR Fingerprint");
|
|
|
|
key.setText(otrFingerprint);
|
|
|
|
keys.addView(view);
|
2014-09-07 21:08:40 +00:00
|
|
|
remove.setOnClickListener(new OnClickListener() {
|
2014-09-08 21:58:37 +00:00
|
|
|
|
2014-09-07 21:08:40 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
confirmToDeleteFingerprint(otrFingerprint);
|
|
|
|
}
|
|
|
|
});
|
2014-03-06 19:00:46 +00:00
|
|
|
}
|
2014-03-07 19:36:04 +00:00
|
|
|
if (contact.getPgpKeyId() != 0) {
|
2014-10-13 10:36:41 +00:00
|
|
|
hasKeys = true;
|
2014-10-26 17:54:10 +00:00
|
|
|
View view = inflater.inflate(R.layout.contact_key, keys, false);
|
2014-03-06 19:00:46 +00:00
|
|
|
TextView key = (TextView) view.findViewById(R.id.key);
|
2014-03-07 19:36:04 +00:00
|
|
|
TextView keyType = (TextView) view.findViewById(R.id.key_type);
|
2014-03-06 19:00:46 +00:00
|
|
|
keyType.setText("PGP Key ID");
|
2014-05-09 18:47:03 +00:00
|
|
|
key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
|
|
|
|
view.setOnClickListener(new OnClickListener() {
|
2014-07-20 01:14:47 +00:00
|
|
|
|
2014-05-09 18:47:03 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2014-10-08 14:37:43 +00:00
|
|
|
PgpEngine pgp = ContactDetailsActivity.this.xmppConnectionService
|
2014-07-20 01:14:47 +00:00
|
|
|
.getPgpEngine();
|
|
|
|
if (pgp != null) {
|
2014-05-09 18:47:03 +00:00
|
|
|
PendingIntent intent = pgp.getIntentForKey(contact);
|
2014-07-20 01:14:47 +00:00
|
|
|
if (intent != null) {
|
2014-05-09 18:47:03 +00:00
|
|
|
try {
|
2014-07-20 01:14:47 +00:00
|
|
|
startIntentSenderForResult(
|
|
|
|
intent.getIntentSender(), 0, null, 0,
|
|
|
|
0, 0);
|
2014-05-09 18:47:03 +00:00
|
|
|
} catch (SendIntentException e) {
|
2014-07-20 01:14:47 +00:00
|
|
|
|
2014-05-09 18:47:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-03-06 19:00:46 +00:00
|
|
|
keys.addView(view);
|
|
|
|
}
|
2014-10-13 10:36:41 +00:00
|
|
|
if (hasKeys) {
|
|
|
|
keys.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
keys.setVisibility(View.GONE);
|
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
2014-09-08 21:58:37 +00:00
|
|
|
|
2014-10-20 19:08:33 +00:00
|
|
|
private void prepareContactBadge(QuickContactBadge badge, Contact contact) {
|
|
|
|
if (contact.getSystemAccount() != null) {
|
|
|
|
String[] systemAccount = contact.getSystemAccount().split("#");
|
|
|
|
long id = Long.parseLong(systemAccount[0]);
|
|
|
|
badge.assignContactUri(Contacts.getLookupUri(id, systemAccount[1]));
|
|
|
|
}
|
2014-10-21 12:57:16 +00:00
|
|
|
badge.setImageBitmap(avatarService().get(contact, getPixel(72)));
|
2014-10-20 19:08:33 +00:00
|
|
|
}
|
|
|
|
|
2014-09-07 21:08:40 +00:00
|
|
|
protected void confirmToDeleteFingerprint(final String fingerprint) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
builder.setTitle(R.string.delete_fingerprint);
|
|
|
|
builder.setMessage(R.string.sure_delete_fingerprint);
|
|
|
|
builder.setNegativeButton(R.string.cancel, null);
|
2014-09-08 21:58:37 +00:00
|
|
|
builder.setPositiveButton(R.string.delete,
|
|
|
|
new android.content.DialogInterface.OnClickListener() {
|
2014-09-07 21:08:40 +00:00
|
|
|
|
2014-09-08 21:58:37 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
if (contact.deleteOtrFingerprint(fingerprint)) {
|
|
|
|
populateView();
|
|
|
|
xmppConnectionService.syncRosterToDisk(contact
|
|
|
|
.getAccount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2014-09-07 21:08:40 +00:00
|
|
|
builder.create().show();
|
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackendConnected() {
|
2014-07-20 01:14:47 +00:00
|
|
|
if ((accountJid != null) && (contactJid != null)) {
|
|
|
|
Account account = xmppConnectionService
|
|
|
|
.findAccountByJid(accountJid);
|
|
|
|
if (account == null) {
|
2014-05-19 13:15:09 +00:00
|
|
|
return;
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
2014-05-19 13:15:09 +00:00
|
|
|
this.contact = account.getRoster().getContact(contactJid);
|
|
|
|
populateView();
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|