2014-03-05 14:41:14 +00:00
|
|
|
package eu.siacs.conversations.ui;
|
|
|
|
|
2018-02-17 17:58:56 +00:00
|
|
|
import android.databinding.DataBindingUtil;
|
2018-02-16 12:29:38 +00:00
|
|
|
import android.support.v7.app.AlertDialog;
|
2014-03-05 14:41:14 +00:00
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
2014-11-18 13:24:06 +00:00
|
|
|
import android.content.SharedPreferences;
|
2014-03-05 14:41:14 +00:00
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
2014-11-18 13:24:06 +00:00
|
|
|
import android.preference.PreferenceManager;
|
2014-03-05 14:41:14 +00:00
|
|
|
import android.provider.ContactsContract.CommonDataKinds;
|
|
|
|
import android.provider.ContactsContract.Contacts;
|
|
|
|
import android.provider.ContactsContract.Intents;
|
2017-03-29 16:30:28 +00:00
|
|
|
import android.support.v4.content.ContextCompat;
|
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;
|
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-03-05 14:41:14 +00:00
|
|
|
import android.widget.TextView;
|
2015-12-23 21:30:14 +00:00
|
|
|
import android.widget.Toast;
|
2014-11-11 16:39:28 +00:00
|
|
|
|
2016-08-26 14:34:42 +00:00
|
|
|
|
2014-11-11 16:39:28 +00:00
|
|
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
|
|
|
|
2014-11-18 13:24:06 +00:00
|
|
|
import java.util.List;
|
2014-11-11 16:39:28 +00:00
|
|
|
|
2015-08-03 20:58:17 +00:00
|
|
|
import eu.siacs.conversations.Config;
|
2014-03-05 14:41:14 +00:00
|
|
|
import eu.siacs.conversations.R;
|
2015-10-17 12:09:26 +00:00
|
|
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
2016-12-30 12:17:45 +00:00
|
|
|
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
|
2016-11-18 20:49:52 +00:00
|
|
|
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
2018-02-17 17:58:56 +00:00
|
|
|
import eu.siacs.conversations.databinding.ActivityContactDetailsBinding;
|
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;
|
2014-11-18 13:24:06 +00:00
|
|
|
import eu.siacs.conversations.entities.ListItem;
|
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;
|
2018-03-08 21:02:19 +00:00
|
|
|
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
|
2014-03-05 14:41:14 +00:00
|
|
|
import eu.siacs.conversations.utils.UIHelper;
|
2016-11-28 14:11:44 +00:00
|
|
|
import eu.siacs.conversations.utils.XmppUri;
|
2017-03-20 16:58:58 +00:00
|
|
|
import eu.siacs.conversations.xml.Namespace;
|
2015-07-21 12:18:16 +00:00
|
|
|
import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
|
2014-12-21 20:43:58 +00:00
|
|
|
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
2015-01-21 14:31:40 +00:00
|
|
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
2018-03-05 17:30:40 +00:00
|
|
|
import rocks.xmpp.addr.Jid;
|
2014-03-05 14:41:14 +00:00
|
|
|
|
2016-11-15 19:00:52 +00:00
|
|
|
public class ContactDetailsActivity extends OmemoActivity implements OnAccountUpdate, OnRosterUpdate, OnUpdateBlocklist, OnKeyStatusUpdated {
|
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) {
|
2015-01-21 14:31:40 +00:00
|
|
|
xmppConnectionService.deleteContactOnServer(contact);
|
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-12-21 20:43:58 +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-12-21 20:43:58 +00:00
|
|
|
.getAccount(),
|
2014-07-20 01:14:47 +00:00
|
|
|
xmppConnectionService.getPresenceGenerator()
|
2014-12-21 20:43:58 +00:00
|
|
|
.sendPresenceUpdatesTo(contact));
|
2014-07-20 01:14:47 +00:00
|
|
|
} else {
|
|
|
|
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
|
|
|
|
xmppConnectionService.sendPresencePacket(contact.getAccount(),
|
|
|
|
xmppConnectionService.getPresenceGenerator()
|
2014-12-21 20:43:58 +00:00
|
|
|
.stopPresenceUpdatesTo(contact));
|
2014-07-20 01:14:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
private OnCheckedChangeListener mOnReceiveCheckedChange = new OnCheckedChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView,
|
2014-12-21 20:43:58 +00:00
|
|
|
boolean isChecked) {
|
2014-07-20 01:14:47 +00:00
|
|
|
if (isChecked) {
|
|
|
|
xmppConnectionService.sendPresencePacket(contact.getAccount(),
|
|
|
|
xmppConnectionService.getPresenceGenerator()
|
2014-12-21 20:43:58 +00:00
|
|
|
.requestPresenceUpdatesFrom(contact));
|
2014-07-20 01:14:47 +00:00
|
|
|
} else {
|
|
|
|
xmppConnectionService.sendPresencePacket(contact.getAccount(),
|
|
|
|
xmppConnectionService.getPresenceGenerator()
|
2014-12-21 20:43:58 +00:00
|
|
|
.stopPresenceUpdatesFrom(contact));
|
2014-07-20 01:14:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-02-17 17:58:56 +00:00
|
|
|
|
|
|
|
ActivityContactDetailsBinding binding;
|
|
|
|
|
2014-11-11 16:39:28 +00:00
|
|
|
private Jid accountJid;
|
|
|
|
private Jid contactJid;
|
2016-06-04 14:16:14 +00:00
|
|
|
private boolean showDynamicTags = false;
|
|
|
|
private boolean showLastSeen = false;
|
2016-12-30 12:17:45 +00:00
|
|
|
private boolean showInactiveOmemo = false;
|
2015-07-29 18:21:37 +00:00
|
|
|
private String messageFingerprint;
|
2014-11-18 13:24:06 +00:00
|
|
|
|
2014-11-11 16:39:28 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
2014-11-18 13:24:06 +00:00
|
|
|
|
2014-11-11 16:39:28 +00:00
|
|
|
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) {
|
2016-08-26 11:35:01 +00:00
|
|
|
Uri systemAccount = contact.getSystemAccount();
|
|
|
|
if (systemAccount == null) {
|
2015-06-03 12:05:54 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
|
|
|
ContactDetailsActivity.this);
|
|
|
|
builder.setTitle(getString(R.string.action_add_phone_book));
|
2018-03-08 13:02:48 +00:00
|
|
|
builder.setMessage(getString(R.string.add_phone_book_text, contact.getJid().toString()));
|
2015-06-03 12:05:54 +00:00
|
|
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
|
|
|
builder.setPositiveButton(getString(R.string.add), addToPhonebook);
|
|
|
|
builder.create().show();
|
|
|
|
} else {
|
2016-08-26 11:35:01 +00:00
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
intent.setData(systemAccount);
|
|
|
|
startActivity(intent);
|
2015-06-03 12:05:54 +00:00
|
|
|
}
|
2014-07-20 11:21:21 +00:00
|
|
|
}
|
|
|
|
};
|
2014-11-11 16:39:28 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRosterUpdate() {
|
2015-02-17 13:18:35 +00:00
|
|
|
refreshUi();
|
2014-11-11 16:39:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAccountUpdate() {
|
2015-02-17 13:18:35 +00:00
|
|
|
refreshUi();
|
|
|
|
}
|
2014-11-11 16:39:28 +00:00
|
|
|
|
2015-07-20 13:48:58 +00:00
|
|
|
@Override
|
|
|
|
public void OnUpdateBlocklist(final Status status) {
|
|
|
|
refreshUi();
|
|
|
|
}
|
|
|
|
|
2015-02-17 13:18:35 +00:00
|
|
|
@Override
|
|
|
|
protected void refreshUiReal() {
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
populateView();
|
2014-11-11 16:39:28 +00:00
|
|
|
}
|
2014-07-20 11:21:21 +00:00
|
|
|
|
2014-11-04 11:15:14 +00:00
|
|
|
@Override
|
2017-09-19 14:28:01 +00:00
|
|
|
protected String getShareableUri(boolean http) {
|
|
|
|
final String prefix = http ? "https://conversations.im/i/" : "xmpp:";
|
2014-11-11 16:39:28 +00:00
|
|
|
if (contact != null) {
|
2018-03-05 17:30:40 +00:00
|
|
|
return prefix+contact.getJid().asBareJid().toString();
|
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
|
2014-12-21 20:43:58 +00:00
|
|
|
protected void onCreate(final Bundle savedInstanceState) {
|
2014-03-05 14:41:14 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
2016-12-30 12:17:45 +00:00
|
|
|
showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo",false);
|
2014-03-05 14:41:14 +00:00
|
|
|
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
|
2014-11-11 16:39:28 +00:00
|
|
|
try {
|
2018-03-05 17:30:40 +00:00
|
|
|
this.accountJid = Jid.of(getIntent().getExtras().getString(EXTRA_ACCOUNT));
|
|
|
|
} catch (final IllegalArgumentException ignored) {
|
2014-11-11 16:39:28 +00:00
|
|
|
}
|
|
|
|
try {
|
2018-03-05 17:30:40 +00:00
|
|
|
this.contactJid = Jid.of(getIntent().getExtras().getString("contact"));
|
|
|
|
} catch (final IllegalArgumentException ignored) {
|
2014-11-11 16:39:28 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-29 18:21:37 +00:00
|
|
|
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
|
2018-02-17 17:58:56 +00:00
|
|
|
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details);
|
|
|
|
|
2018-02-16 11:30:46 +00:00
|
|
|
if (getSupportActionBar() != null) {
|
|
|
|
getSupportActionBar().setHomeButtonEnabled(true);
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
2014-12-21 20:43:58 +00:00
|
|
|
}
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.showInactiveDevices.setOnClickListener(v -> {
|
2018-02-17 17:07:20 +00:00
|
|
|
showInactiveOmemo = !showInactiveOmemo;
|
|
|
|
populateView();
|
2016-12-30 12:17:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSaveInstanceState(final Bundle savedInstanceState) {
|
|
|
|
savedInstanceState.putBoolean("show_inactive_omemo",showInactiveOmemo);
|
|
|
|
super.onSaveInstanceState(savedInstanceState);
|
2016-06-04 14:16:14 +00:00
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
|
2016-06-04 14:16:14 +00:00
|
|
|
@Override
|
|
|
|
public void onStart() {
|
|
|
|
super.onStart();
|
2016-09-18 18:26:47 +00:00
|
|
|
final int theme = findTheme();
|
|
|
|
if (this.mTheme != theme) {
|
|
|
|
recreate();
|
|
|
|
} else {
|
|
|
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
2017-06-05 12:57:09 +00:00
|
|
|
this.showDynamicTags = preferences.getBoolean(SettingsActivity.SHOW_DYNAMIC_TAGS, false);
|
2016-09-18 18:26:47 +00:00
|
|
|
this.showLastSeen = preferences.getBoolean("last_activity", false);
|
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-12-21 20:43:58 +00:00
|
|
|
public boolean onOptionsItemSelected(final MenuItem menuItem) {
|
2015-01-16 00:08:12 +00:00
|
|
|
final 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;
|
2017-09-19 14:28:01 +00:00
|
|
|
case R.id.action_share_http:
|
|
|
|
shareLink(true);
|
|
|
|
break;
|
|
|
|
case R.id.action_share_uri:
|
|
|
|
shareLink(false);
|
2016-06-24 13:16:01 +00:00
|
|
|
break;
|
2014-11-11 16:39:28 +00:00
|
|
|
case R.id.action_delete_contact:
|
|
|
|
builder.setTitle(getString(R.string.action_delete_contact))
|
2018-03-08 13:02:48 +00:00
|
|
|
.setMessage(getString(R.string.remove_contact_text, contact.getJid().toString()))
|
2014-12-21 20:43:58 +00:00
|
|
|
.setPositiveButton(getString(R.string.delete),
|
|
|
|
removeFromRoster).create().show();
|
2014-11-11 16:39:28 +00:00
|
|
|
break;
|
|
|
|
case R.id.action_edit_contact:
|
2016-08-26 11:35:01 +00:00
|
|
|
Uri systemAccount = contact.getSystemAccount();
|
|
|
|
if (systemAccount == null) {
|
2016-05-22 16:20:57 +00:00
|
|
|
quickEdit(contact.getDisplayName(), 0, new OnValueEdited() {
|
2014-11-11 16:39:28 +00:00
|
|
|
|
|
|
|
@Override
|
2017-12-09 17:46:21 +00:00
|
|
|
public String onValueEdited(String value) {
|
2014-11-11 16:39:28 +00:00
|
|
|
contact.setServerName(value);
|
2017-12-09 17:46:21 +00:00
|
|
|
ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
|
2014-11-11 16:39:28 +00:00
|
|
|
populateView();
|
2017-12-09 17:46:21 +00:00
|
|
|
return null;
|
2014-11-11 16:39:28 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_EDIT);
|
2016-08-26 11:35:01 +00:00
|
|
|
intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE);
|
2014-11-11 16:39:28 +00:00
|
|
|
intent.putExtra("finishActivityOnSaveCompleted", true);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
break;
|
2015-01-16 00:08:12 +00:00
|
|
|
case R.id.action_block:
|
2017-03-06 15:53:54 +00:00
|
|
|
BlockContactDialog.show(this, contact);
|
2015-01-16 00:08:12 +00:00
|
|
|
break;
|
|
|
|
case R.id.action_unblock:
|
2017-03-06 15:53:54 +00:00
|
|
|
BlockContactDialog.show(this, contact);
|
2015-01-16 00:08:12 +00:00
|
|
|
break;
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(menuItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-16 00:08:12 +00:00
|
|
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
2014-03-05 14:41:14 +00:00
|
|
|
getMenuInflater().inflate(R.menu.contact_details, menu);
|
2015-01-21 14:31:40 +00:00
|
|
|
MenuItem block = menu.findItem(R.id.action_block);
|
|
|
|
MenuItem unblock = menu.findItem(R.id.action_unblock);
|
|
|
|
MenuItem edit = menu.findItem(R.id.action_edit_contact);
|
|
|
|
MenuItem delete = menu.findItem(R.id.action_delete_contact);
|
2015-04-28 11:31:33 +00:00
|
|
|
if (contact == null) {
|
|
|
|
return true;
|
|
|
|
}
|
2015-01-21 14:31:40 +00:00
|
|
|
final XmppConnection connection = contact.getAccount().getXmppConnection();
|
|
|
|
if (connection != null && connection.getFeatures().blocking()) {
|
|
|
|
if (this.contact.isBlocked()) {
|
2015-04-28 11:31:33 +00:00
|
|
|
block.setVisible(false);
|
2015-01-21 14:31:40 +00:00
|
|
|
} else {
|
2015-04-28 11:31:33 +00:00
|
|
|
unblock.setVisible(false);
|
2015-01-21 14:31:40 +00:00
|
|
|
}
|
2015-01-16 00:08:12 +00:00
|
|
|
} else {
|
2015-04-28 11:31:33 +00:00
|
|
|
unblock.setVisible(false);
|
|
|
|
block.setVisible(false);
|
2015-01-21 14:31:40 +00:00
|
|
|
}
|
|
|
|
if (!contact.showInRoster()) {
|
|
|
|
edit.setVisible(false);
|
|
|
|
delete.setVisible(false);
|
2015-01-16 00:08:12 +00:00
|
|
|
}
|
2016-02-27 09:25:31 +00:00
|
|
|
return super.onCreateOptionsMenu(menu);
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
2014-03-07 19:36:04 +00:00
|
|
|
|
2014-03-05 14:41:14 +00:00
|
|
|
private void populateView() {
|
2016-08-20 08:44:50 +00:00
|
|
|
if (contact == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-04-28 11:31:33 +00:00
|
|
|
invalidateOptionsMenu();
|
2014-03-05 14:41:14 +00:00
|
|
|
setTitle(contact.getDisplayName());
|
2015-01-21 14:31:40 +00:00
|
|
|
if (contact.showInRoster()) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsSendPresence.setVisibility(View.VISIBLE);
|
|
|
|
binding.detailsReceivePresence.setVisibility(View.VISIBLE);
|
|
|
|
binding.addContactButton.setVisibility(View.GONE);
|
|
|
|
binding.detailsSendPresence.setOnCheckedChangeListener(null);
|
|
|
|
binding.detailsReceivePresence.setOnCheckedChangeListener(null);
|
2015-01-21 14:31:40 +00:00
|
|
|
|
2016-04-23 10:19:00 +00:00
|
|
|
List<String> statusMessages = contact.getPresences().getStatusMessages();
|
|
|
|
if (statusMessages.size() == 0) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.statusMessage.setVisibility(View.GONE);
|
2016-04-23 10:19:00 +00:00
|
|
|
} else {
|
|
|
|
StringBuilder builder = new StringBuilder();
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.statusMessage.setVisibility(View.VISIBLE);
|
2016-04-23 10:19:00 +00:00
|
|
|
int s = statusMessages.size();
|
|
|
|
for(int i = 0; i < s; ++i) {
|
|
|
|
if (s > 1) {
|
|
|
|
builder.append("• ");
|
|
|
|
}
|
|
|
|
builder.append(statusMessages.get(i));
|
|
|
|
if (i < s - 1) {
|
|
|
|
builder.append("\n");
|
|
|
|
}
|
|
|
|
}
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.statusMessage.setText(builder);
|
2016-04-23 10:19:00 +00:00
|
|
|
}
|
|
|
|
|
2015-01-21 14:31:40 +00:00
|
|
|
if (contact.getOption(Contact.Options.FROM)) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsSendPresence.setText(R.string.send_presence_updates);
|
|
|
|
binding.detailsSendPresence.setChecked(true);
|
2015-01-21 14:31:40 +00:00
|
|
|
} else if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsSendPresence.setChecked(false);
|
|
|
|
binding.detailsSendPresence.setText(R.string.send_presence_updates);
|
2015-01-21 14:31:40 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsSendPresence.setText(R.string.preemptively_grant);
|
2015-01-21 14:31:40 +00:00
|
|
|
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsSendPresence.setChecked(true);
|
2015-01-21 14:31:40 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsSendPresence.setChecked(false);
|
2015-01-21 14:31:40 +00:00
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
2015-01-21 14:31:40 +00:00
|
|
|
if (contact.getOption(Contact.Options.TO)) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsReceivePresence.setText(R.string.receive_presence_updates);
|
|
|
|
binding.detailsReceivePresence.setChecked(true);
|
2014-03-05 14:41:14 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsReceivePresence.setText(R.string.ask_for_presence_updates);
|
2015-01-21 14:31:40 +00:00
|
|
|
if (contact.getOption(Contact.Options.ASKING)) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsReceivePresence.setChecked(true);
|
2015-01-21 14:31:40 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsReceivePresence.setChecked(false);
|
2015-01-21 14:31:40 +00:00
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
2015-01-21 14:31:40 +00:00
|
|
|
if (contact.getAccount().isOnlineAndConnected()) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsReceivePresence.setEnabled(true);
|
|
|
|
binding.detailsSendPresence.setEnabled(true);
|
2015-01-21 14:31:40 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsReceivePresence.setEnabled(false);
|
|
|
|
binding.detailsSendPresence.setEnabled(false);
|
2015-01-21 14:31:40 +00:00
|
|
|
}
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsSendPresence.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
|
|
|
binding.detailsReceivePresence.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
2014-07-20 11:21:21 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.addContactButton.setVisibility(View.VISIBLE);
|
|
|
|
binding.detailsSendPresence.setVisibility(View.GONE);
|
|
|
|
binding.detailsReceivePresence.setVisibility(View.GONE);
|
|
|
|
binding.statusMessage.setVisibility(View.GONE);
|
2014-07-20 11:21:21 +00:00
|
|
|
}
|
2014-07-20 01:14:47 +00:00
|
|
|
|
2016-06-04 14:16:14 +00:00
|
|
|
if (contact.isBlocked() && !this.showDynamicTags) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsLastseen.setVisibility(View.VISIBLE);
|
|
|
|
binding.detailsLastseen.setText(R.string.contact_blocked);
|
2016-06-04 14:16:14 +00:00
|
|
|
} else {
|
2017-03-20 16:58:58 +00:00
|
|
|
if (showLastSeen
|
|
|
|
&& contact.getLastseen() > 0
|
|
|
|
&& contact.getPresences().allOrNonSupport(Namespace.IDLE)) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsLastseen.setVisibility(View.VISIBLE);
|
|
|
|
binding.detailsLastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.isActive(), contact.getLastseen()));
|
2016-06-04 14:16:14 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsLastseen.setVisibility(View.GONE);
|
2016-06-04 14:16:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-08 21:02:19 +00:00
|
|
|
binding.detailsContactjid.setText(IrregularUnicodeDetector.style(this,contact.getJid()));
|
2015-08-03 20:58:17 +00:00
|
|
|
String account;
|
|
|
|
if (Config.DOMAIN_LOCK != null) {
|
2018-03-05 17:30:40 +00:00
|
|
|
account = contact.getAccount().getJid().getLocal();
|
2015-08-03 20:58:17 +00:00
|
|
|
} else {
|
2018-03-05 17:30:40 +00:00
|
|
|
account = contact.getAccount().getJid().asBareJid().toString();
|
2015-08-03 20:58:17 +00:00
|
|
|
}
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsAccount.setText(getString(R.string.using_account, account));
|
|
|
|
binding.detailsContactBadge.setImageBitmap(avatarService().get(contact, getPixel(72)));
|
|
|
|
binding.detailsContactBadge.setOnClickListener(this.onBadgeClick);
|
2014-03-07 19:36:04 +00:00
|
|
|
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsContactKeys.removeAllViews();
|
2014-10-13 10:36:41 +00:00
|
|
|
boolean hasKeys = false;
|
2018-02-19 12:55:48 +00:00
|
|
|
final LayoutInflater inflater = getLayoutInflater();
|
2018-02-19 16:26:38 +00:00
|
|
|
final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
|
|
|
|
if (Config.supportOmemo() && axolotlService != null) {
|
2016-12-30 12:17:45 +00:00
|
|
|
boolean skippedInactive = false;
|
|
|
|
boolean showsInactive = false;
|
2018-02-19 16:26:38 +00:00
|
|
|
for (final XmppAxolotlSession session : axolotlService.findSessionsForContact(contact)) {
|
2016-12-30 12:17:45 +00:00
|
|
|
final FingerprintStatus trust = session.getTrust();
|
2017-03-01 11:50:46 +00:00
|
|
|
hasKeys |= !trust.isCompromised();
|
2016-12-30 12:17:45 +00:00
|
|
|
if (!trust.isActive()) {
|
|
|
|
if (showInactiveOmemo) {
|
|
|
|
showsInactive = true;
|
|
|
|
} else {
|
|
|
|
skippedInactive = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!trust.isCompromised()) {
|
2016-11-18 20:49:52 +00:00
|
|
|
boolean highlight = session.getFingerprint().equals(messageFingerprint);
|
2018-02-17 17:58:56 +00:00
|
|
|
addFingerprintRow(binding.detailsContactKeys, session, highlight);
|
2016-11-18 20:49:52 +00:00
|
|
|
}
|
2016-05-25 20:12:13 +00:00
|
|
|
}
|
2016-12-30 12:17:45 +00:00
|
|
|
if (showsInactive || skippedInactive) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.showInactiveDevices.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices);
|
|
|
|
binding.showInactiveDevices.setVisibility(View.VISIBLE);
|
2016-12-30 12:17:45 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.showInactiveDevices.setVisibility(View.GONE);
|
2016-12-30 12:17:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.showInactiveDevices.setVisibility(View.GONE);
|
2015-06-25 15:01:42 +00:00
|
|
|
}
|
2018-02-26 14:44:50 +00:00
|
|
|
binding.scanButton.setVisibility(hasKeys ? View.VISIBLE : View.GONE);
|
|
|
|
if (hasKeys) {
|
|
|
|
binding.scanButton.setOnClickListener((v)-> ScanActivity.scan(this));
|
|
|
|
}
|
2016-05-25 20:12:13 +00:00
|
|
|
if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) {
|
2014-10-13 10:36:41 +00:00
|
|
|
hasKeys = true;
|
2018-02-17 17:58:56 +00:00
|
|
|
View view = inflater.inflate(R.layout.contact_key, binding.detailsContactKeys, 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);
|
2016-06-16 10:12:24 +00:00
|
|
|
keyType.setText(R.string.openpgp_key_id);
|
|
|
|
if ("pgp".equals(messageFingerprint)) {
|
2017-03-29 16:30:28 +00:00
|
|
|
keyType.setTextColor(ContextCompat.getColor(this, R.color.accent));
|
2016-06-16 10:12:24 +00:00
|
|
|
}
|
2014-05-09 18:47:03 +00:00
|
|
|
key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
|
2018-02-19 17:17:43 +00:00
|
|
|
final OnClickListener openKey = v -> launchOpenKeyChain(contact.getPgpKeyId());
|
2017-04-25 13:23:01 +00:00
|
|
|
view.setOnClickListener(openKey);
|
|
|
|
key.setOnClickListener(openKey);
|
|
|
|
keyType.setOnClickListener(openKey);
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.detailsContactKeys.addView(view);
|
2014-03-06 19:00:46 +00:00
|
|
|
}
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.keysWrapper.setVisibility(hasKeys ? View.VISIBLE : View.GONE);
|
2014-11-18 13:24:06 +00:00
|
|
|
|
2016-04-22 19:25:06 +00:00
|
|
|
List<ListItem.Tag> tagList = contact.getTags(this);
|
2014-11-18 13:24:06 +00:00
|
|
|
if (tagList.size() == 0 || !this.showDynamicTags) {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.tags.setVisibility(View.GONE);
|
2014-11-18 13:24:06 +00:00
|
|
|
} else {
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.tags.setVisibility(View.VISIBLE);
|
|
|
|
binding.tags.removeAllViewsInLayout();
|
2014-12-21 20:43:58 +00:00
|
|
|
for(final ListItem.Tag tag : tagList) {
|
2018-02-17 17:58:56 +00:00
|
|
|
final TextView tv = (TextView) inflater.inflate(R.layout.list_item_tag,binding.tags,false);
|
2014-11-18 13:24:06 +00:00
|
|
|
tv.setText(tag.getName());
|
|
|
|
tv.setBackgroundColor(tag.getColor());
|
2018-02-17 17:58:56 +00:00
|
|
|
binding.tags.addView(tv);
|
2014-11-18 13:24:06 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
2014-09-08 21:58:37 +00:00
|
|
|
|
2014-03-05 14:41:14 +00:00
|
|
|
public void onBackendConnected() {
|
2016-11-28 14:11:44 +00:00
|
|
|
if (accountJid != null && contactJid != null) {
|
|
|
|
Account account = xmppConnectionService.findAccountByJid(accountJid);
|
2014-07-20 01:14:47 +00:00
|
|
|
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);
|
2016-11-28 14:11:44 +00:00
|
|
|
if (mPendingFingerprintVerificationUri != null) {
|
|
|
|
processFingerprintVerification(mPendingFingerprintVerificationUri);
|
|
|
|
mPendingFingerprintVerificationUri = null;
|
|
|
|
}
|
2014-05-19 13:15:09 +00:00
|
|
|
populateView();
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-21 12:18:16 +00:00
|
|
|
|
|
|
|
@Override
|
2015-10-17 12:09:26 +00:00
|
|
|
public void onKeyStatusUpdated(AxolotlService.FetchStatus report) {
|
2015-07-21 12:18:16 +00:00
|
|
|
refreshUi();
|
|
|
|
}
|
2016-11-28 14:11:44 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void processFingerprintVerification(XmppUri uri) {
|
2018-03-05 17:30:40 +00:00
|
|
|
if (contact != null && contact.getJid().asBareJid().equals(uri.getJid()) && uri.hasFingerprints()) {
|
2016-11-28 14:11:44 +00:00
|
|
|
if (xmppConnectionService.verifyFingerprints(contact,uri.getFingerprints())) {
|
|
|
|
Toast.makeText(this,R.string.verified_fingerprints,Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Toast.makeText(this,R.string.invalid_barcode,Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
2014-03-05 14:41:14 +00:00
|
|
|
}
|