show toast if no address book app is installed
This commit is contained in:
parent
e27e3ecf92
commit
53a9930837
|
@ -1,5 +1,6 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -48,432 +49,440 @@ import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class ContactDetailsActivity extends OmemoActivity implements OnAccountUpdate, OnRosterUpdate, OnUpdateBlocklist, OnKeyStatusUpdated {
|
public class ContactDetailsActivity extends OmemoActivity implements OnAccountUpdate, OnRosterUpdate, OnUpdateBlocklist, OnKeyStatusUpdated {
|
||||||
public static final String ACTION_VIEW_CONTACT = "view_contact";
|
public static final String ACTION_VIEW_CONTACT = "view_contact";
|
||||||
ActivityContactDetailsBinding binding;
|
ActivityContactDetailsBinding binding;
|
||||||
private Contact contact;
|
private Contact contact;
|
||||||
private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() {
|
private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
xmppConnectionService.deleteContactOnServer(contact);
|
xmppConnectionService.deleteContactOnServer(contact);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() {
|
private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
||||||
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().sendPresenceUpdatesTo(contact));
|
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().sendPresenceUpdatesTo(contact));
|
||||||
} else {
|
} else {
|
||||||
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
|
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
|
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
|
||||||
xmppConnectionService.sendPresencePacket(contact.getAccount(),xmppConnectionService.getPresenceGenerator().stopPresenceUpdatesTo(contact));
|
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().stopPresenceUpdatesTo(contact));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private OnCheckedChangeListener mOnReceiveCheckedChange = new OnCheckedChangeListener() {
|
private OnCheckedChangeListener mOnReceiveCheckedChange = new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().requestPresenceUpdatesFrom(contact));
|
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().requestPresenceUpdatesFrom(contact));
|
||||||
} else {
|
} else {
|
||||||
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().stopPresenceUpdatesFrom(contact));
|
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().stopPresenceUpdatesFrom(contact));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private Jid accountJid;
|
private Jid accountJid;
|
||||||
private Jid contactJid;
|
private Jid contactJid;
|
||||||
private boolean showDynamicTags = false;
|
private boolean showDynamicTags = false;
|
||||||
private boolean showLastSeen = false;
|
private boolean showLastSeen = false;
|
||||||
private boolean showInactiveOmemo = false;
|
private boolean showInactiveOmemo = false;
|
||||||
private String messageFingerprint;
|
private String messageFingerprint;
|
||||||
|
|
||||||
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
||||||
intent.setType(Contacts.CONTENT_ITEM_TYPE);
|
intent.setType(Contacts.CONTENT_ITEM_TYPE);
|
||||||
intent.putExtra(Intents.Insert.IM_HANDLE, contact.getJid().toString());
|
intent.putExtra(Intents.Insert.IM_HANDLE, contact.getJid().toEscapedString());
|
||||||
intent.putExtra(Intents.Insert.IM_PROTOCOL,
|
intent.putExtra(Intents.Insert.IM_PROTOCOL, CommonDataKinds.Im.PROTOCOL_JABBER);
|
||||||
CommonDataKinds.Im.PROTOCOL_JABBER);
|
intent.putExtra("finishActivityOnSaveCompleted", true);
|
||||||
intent.putExtra("finishActivityOnSaveCompleted", true);
|
try {
|
||||||
ContactDetailsActivity.this.startActivityForResult(intent, 0);
|
ContactDetailsActivity.this.startActivityForResult(intent, 0);
|
||||||
}
|
} catch (ActivityNotFoundException e) {
|
||||||
};
|
Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private OnClickListener onBadgeClick = new OnClickListener() {
|
private OnClickListener onBadgeClick = new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Uri systemAccount = contact.getSystemAccount();
|
Uri systemAccount = contact.getSystemAccount();
|
||||||
if (systemAccount == null) {
|
if (systemAccount == null) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
ContactDetailsActivity.this);
|
ContactDetailsActivity.this);
|
||||||
builder.setTitle(getString(R.string.action_add_phone_book));
|
builder.setTitle(getString(R.string.action_add_phone_book));
|
||||||
builder.setMessage(getString(R.string.add_phone_book_text, contact.getJid().toString()));
|
builder.setMessage(getString(R.string.add_phone_book_text, contact.getJid().toString()));
|
||||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||||
builder.setPositiveButton(getString(R.string.add), addToPhonebook);
|
builder.setPositiveButton(getString(R.string.add), addToPhonebook);
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(systemAccount);
|
intent.setData(systemAccount);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRosterUpdate() {
|
public void onRosterUpdate() {
|
||||||
refreshUi();
|
refreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountUpdate() {
|
public void onAccountUpdate() {
|
||||||
refreshUi();
|
refreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void OnUpdateBlocklist(final Status status) {
|
public void OnUpdateBlocklist(final Status status) {
|
||||||
refreshUi();
|
refreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void refreshUiReal() {
|
protected void refreshUiReal() {
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
populateView();
|
populateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getShareableUri(boolean http) {
|
protected String getShareableUri(boolean http) {
|
||||||
if (http) {
|
if (http) {
|
||||||
return "https://conversations.im/j/" + XmppUri.lameUrlEncode(contact.getJid().asBareJid().toEscapedString());
|
return "https://conversations.im/j/" + XmppUri.lameUrlEncode(contact.getJid().asBareJid().toEscapedString());
|
||||||
} else {
|
} else {
|
||||||
return "xmpp:" + contact.getJid().asBareJid().toEscapedString();
|
return "xmpp:" + contact.getJid().asBareJid().toEscapedString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo", false);
|
showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo", false);
|
||||||
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
|
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
|
||||||
try {
|
try {
|
||||||
this.accountJid = Jid.of(getIntent().getExtras().getString(EXTRA_ACCOUNT));
|
this.accountJid = Jid.of(getIntent().getExtras().getString(EXTRA_ACCOUNT));
|
||||||
} catch (final IllegalArgumentException ignored) {
|
} catch (final IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.contactJid = Jid.of(getIntent().getExtras().getString("contact"));
|
this.contactJid = Jid.of(getIntent().getExtras().getString("contact"));
|
||||||
} catch (final IllegalArgumentException ignored) {
|
} catch (final IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
|
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
|
||||||
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details);
|
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details);
|
||||||
|
|
||||||
setSupportActionBar((Toolbar) binding.toolbar);
|
setSupportActionBar((Toolbar) binding.toolbar);
|
||||||
configureActionBar(getSupportActionBar());
|
configureActionBar(getSupportActionBar());
|
||||||
binding.showInactiveDevices.setOnClickListener(v -> {
|
binding.showInactiveDevices.setOnClickListener(v -> {
|
||||||
showInactiveOmemo = !showInactiveOmemo;
|
showInactiveOmemo = !showInactiveOmemo;
|
||||||
populateView();
|
populateView();
|
||||||
});
|
});
|
||||||
binding.addContactButton.setOnClickListener(v -> showAddToRosterDialog(contact));
|
binding.addContactButton.setOnClickListener(v -> showAddToRosterDialog(contact));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(final Bundle savedInstanceState) {
|
public void onSaveInstanceState(final Bundle savedInstanceState) {
|
||||||
savedInstanceState.putBoolean("show_inactive_omemo", showInactiveOmemo);
|
savedInstanceState.putBoolean("show_inactive_omemo", showInactiveOmemo);
|
||||||
super.onSaveInstanceState(savedInstanceState);
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
final int theme = findTheme();
|
final int theme = findTheme();
|
||||||
if (this.mTheme != theme) {
|
if (this.mTheme != theme) {
|
||||||
recreate();
|
recreate();
|
||||||
} else {
|
} else {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
this.showDynamicTags = preferences.getBoolean(SettingsActivity.SHOW_DYNAMIC_TAGS, false);
|
this.showDynamicTags = preferences.getBoolean(SettingsActivity.SHOW_DYNAMIC_TAGS, false);
|
||||||
this.showLastSeen = preferences.getBoolean("last_activity", false);
|
this.showLastSeen = preferences.getBoolean("last_activity", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(final MenuItem menuItem) {
|
public boolean onOptionsItemSelected(final MenuItem menuItem) {
|
||||||
if (MenuDoubleTabUtil.shouldIgnoreTap()) {
|
if (MenuDoubleTabUtil.shouldIgnoreTap()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
case R.id.action_share_http:
|
case R.id.action_share_http:
|
||||||
shareLink(true);
|
shareLink(true);
|
||||||
break;
|
break;
|
||||||
case R.id.action_share_uri:
|
case R.id.action_share_uri:
|
||||||
shareLink(false);
|
shareLink(false);
|
||||||
break;
|
break;
|
||||||
case R.id.action_delete_contact:
|
case R.id.action_delete_contact:
|
||||||
builder.setTitle(getString(R.string.action_delete_contact))
|
builder.setTitle(getString(R.string.action_delete_contact))
|
||||||
.setMessage(getString(R.string.remove_contact_text, contact.getJid().toString()))
|
.setMessage(getString(R.string.remove_contact_text, contact.getJid().toString()))
|
||||||
.setPositiveButton(getString(R.string.delete),
|
.setPositiveButton(getString(R.string.delete),
|
||||||
removeFromRoster).create().show();
|
removeFromRoster).create().show();
|
||||||
break;
|
break;
|
||||||
case R.id.action_edit_contact:
|
case R.id.action_edit_contact:
|
||||||
Uri systemAccount = contact.getSystemAccount();
|
Uri systemAccount = contact.getSystemAccount();
|
||||||
if (systemAccount == null) {
|
if (systemAccount == null) {
|
||||||
quickEdit(contact.getServerName(), R.string.contact_name, value -> {
|
quickEdit(contact.getServerName(), R.string.contact_name, value -> {
|
||||||
contact.setServerName(value);
|
contact.setServerName(value);
|
||||||
ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
|
ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
|
||||||
populateView();
|
populateView();
|
||||||
return null;
|
return null;
|
||||||
}, true);
|
}, true);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_EDIT);
|
Intent intent = new Intent(Intent.ACTION_EDIT);
|
||||||
intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE);
|
intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE);
|
||||||
intent.putExtra("finishActivityOnSaveCompleted", true);
|
intent.putExtra("finishActivityOnSaveCompleted", true);
|
||||||
startActivity(intent);
|
try {
|
||||||
}
|
startActivity(intent);
|
||||||
break;
|
} catch (ActivityNotFoundException e) {
|
||||||
case R.id.action_block:
|
Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show();
|
||||||
BlockContactDialog.show(this, contact);
|
}
|
||||||
break;
|
|
||||||
case R.id.action_unblock:
|
|
||||||
BlockContactDialog.show(this, contact);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(menuItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
break;
|
||||||
getMenuInflater().inflate(R.menu.contact_details, menu);
|
case R.id.action_block:
|
||||||
MenuItem block = menu.findItem(R.id.action_block);
|
BlockContactDialog.show(this, contact);
|
||||||
MenuItem unblock = menu.findItem(R.id.action_unblock);
|
break;
|
||||||
MenuItem edit = menu.findItem(R.id.action_edit_contact);
|
case R.id.action_unblock:
|
||||||
MenuItem delete = menu.findItem(R.id.action_delete_contact);
|
BlockContactDialog.show(this, contact);
|
||||||
if (contact == null) {
|
break;
|
||||||
return true;
|
}
|
||||||
}
|
return super.onOptionsItemSelected(menuItem);
|
||||||
final XmppConnection connection = contact.getAccount().getXmppConnection();
|
}
|
||||||
if (connection != null && connection.getFeatures().blocking()) {
|
|
||||||
if (this.contact.isBlocked()) {
|
|
||||||
block.setVisible(false);
|
|
||||||
} else {
|
|
||||||
unblock.setVisible(false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unblock.setVisible(false);
|
|
||||||
block.setVisible(false);
|
|
||||||
}
|
|
||||||
if (!contact.showInRoster()) {
|
|
||||||
edit.setVisible(false);
|
|
||||||
delete.setVisible(false);
|
|
||||||
}
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateView() {
|
@Override
|
||||||
if (contact == null) {
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||||
return;
|
getMenuInflater().inflate(R.menu.contact_details, menu);
|
||||||
}
|
MenuItem block = menu.findItem(R.id.action_block);
|
||||||
invalidateOptionsMenu();
|
MenuItem unblock = menu.findItem(R.id.action_unblock);
|
||||||
setTitle(contact.getDisplayName());
|
MenuItem edit = menu.findItem(R.id.action_edit_contact);
|
||||||
if (contact.showInRoster()) {
|
MenuItem delete = menu.findItem(R.id.action_delete_contact);
|
||||||
binding.detailsSendPresence.setVisibility(View.VISIBLE);
|
if (contact == null) {
|
||||||
binding.detailsReceivePresence.setVisibility(View.VISIBLE);
|
return true;
|
||||||
binding.addContactButton.setVisibility(View.GONE);
|
}
|
||||||
binding.detailsSendPresence.setOnCheckedChangeListener(null);
|
final XmppConnection connection = contact.getAccount().getXmppConnection();
|
||||||
binding.detailsReceivePresence.setOnCheckedChangeListener(null);
|
if (connection != null && connection.getFeatures().blocking()) {
|
||||||
|
if (this.contact.isBlocked()) {
|
||||||
|
block.setVisible(false);
|
||||||
|
} else {
|
||||||
|
unblock.setVisible(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unblock.setVisible(false);
|
||||||
|
block.setVisible(false);
|
||||||
|
}
|
||||||
|
if (!contact.showInRoster()) {
|
||||||
|
edit.setVisible(false);
|
||||||
|
delete.setVisible(false);
|
||||||
|
}
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> statusMessages = contact.getPresences().getStatusMessages();
|
private void populateView() {
|
||||||
if (statusMessages.size() == 0) {
|
if (contact == null) {
|
||||||
binding.statusMessage.setVisibility(View.GONE);
|
return;
|
||||||
} else {
|
}
|
||||||
StringBuilder builder = new StringBuilder();
|
invalidateOptionsMenu();
|
||||||
binding.statusMessage.setVisibility(View.VISIBLE);
|
setTitle(contact.getDisplayName());
|
||||||
int s = statusMessages.size();
|
if (contact.showInRoster()) {
|
||||||
for (int i = 0; i < s; ++i) {
|
binding.detailsSendPresence.setVisibility(View.VISIBLE);
|
||||||
if (s > 1) {
|
binding.detailsReceivePresence.setVisibility(View.VISIBLE);
|
||||||
builder.append("• ");
|
binding.addContactButton.setVisibility(View.GONE);
|
||||||
}
|
binding.detailsSendPresence.setOnCheckedChangeListener(null);
|
||||||
builder.append(statusMessages.get(i));
|
binding.detailsReceivePresence.setOnCheckedChangeListener(null);
|
||||||
if (i < s - 1) {
|
|
||||||
builder.append("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.statusMessage.setText(builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.getOption(Contact.Options.FROM)) {
|
List<String> statusMessages = contact.getPresences().getStatusMessages();
|
||||||
binding.detailsSendPresence.setText(R.string.send_presence_updates);
|
if (statusMessages.size() == 0) {
|
||||||
binding.detailsSendPresence.setChecked(true);
|
binding.statusMessage.setVisibility(View.GONE);
|
||||||
} else if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
} else {
|
||||||
binding.detailsSendPresence.setChecked(false);
|
StringBuilder builder = new StringBuilder();
|
||||||
binding.detailsSendPresence.setText(R.string.send_presence_updates);
|
binding.statusMessage.setVisibility(View.VISIBLE);
|
||||||
} else {
|
int s = statusMessages.size();
|
||||||
binding.detailsSendPresence.setText(R.string.preemptively_grant);
|
for (int i = 0; i < s; ++i) {
|
||||||
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
|
if (s > 1) {
|
||||||
binding.detailsSendPresence.setChecked(true);
|
builder.append("• ");
|
||||||
} else {
|
}
|
||||||
binding.detailsSendPresence.setChecked(false);
|
builder.append(statusMessages.get(i));
|
||||||
}
|
if (i < s - 1) {
|
||||||
}
|
builder.append("\n");
|
||||||
if (contact.getOption(Contact.Options.TO)) {
|
}
|
||||||
binding.detailsReceivePresence.setText(R.string.receive_presence_updates);
|
}
|
||||||
binding.detailsReceivePresence.setChecked(true);
|
binding.statusMessage.setText(builder);
|
||||||
} else {
|
}
|
||||||
binding.detailsReceivePresence.setText(R.string.ask_for_presence_updates);
|
|
||||||
if (contact.getOption(Contact.Options.ASKING)) {
|
|
||||||
binding.detailsReceivePresence.setChecked(true);
|
|
||||||
} else {
|
|
||||||
binding.detailsReceivePresence.setChecked(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (contact.getAccount().isOnlineAndConnected()) {
|
|
||||||
binding.detailsReceivePresence.setEnabled(true);
|
|
||||||
binding.detailsSendPresence.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
binding.detailsReceivePresence.setEnabled(false);
|
|
||||||
binding.detailsSendPresence.setEnabled(false);
|
|
||||||
}
|
|
||||||
binding.detailsSendPresence.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
|
||||||
binding.detailsReceivePresence.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
|
||||||
} else {
|
|
||||||
binding.addContactButton.setVisibility(View.VISIBLE);
|
|
||||||
binding.detailsSendPresence.setVisibility(View.GONE);
|
|
||||||
binding.detailsReceivePresence.setVisibility(View.GONE);
|
|
||||||
binding.statusMessage.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.isBlocked() && !this.showDynamicTags) {
|
if (contact.getOption(Contact.Options.FROM)) {
|
||||||
binding.detailsLastseen.setVisibility(View.VISIBLE);
|
binding.detailsSendPresence.setText(R.string.send_presence_updates);
|
||||||
binding.detailsLastseen.setText(R.string.contact_blocked);
|
binding.detailsSendPresence.setChecked(true);
|
||||||
} else {
|
} else if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
||||||
if (showLastSeen
|
binding.detailsSendPresence.setChecked(false);
|
||||||
&& contact.getLastseen() > 0
|
binding.detailsSendPresence.setText(R.string.send_presence_updates);
|
||||||
&& contact.getPresences().allOrNonSupport(Namespace.IDLE)) {
|
} else {
|
||||||
binding.detailsLastseen.setVisibility(View.VISIBLE);
|
binding.detailsSendPresence.setText(R.string.preemptively_grant);
|
||||||
binding.detailsLastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.isActive(), contact.getLastseen()));
|
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
|
||||||
} else {
|
binding.detailsSendPresence.setChecked(true);
|
||||||
binding.detailsLastseen.setVisibility(View.GONE);
|
} else {
|
||||||
}
|
binding.detailsSendPresence.setChecked(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (contact.getOption(Contact.Options.TO)) {
|
||||||
|
binding.detailsReceivePresence.setText(R.string.receive_presence_updates);
|
||||||
|
binding.detailsReceivePresence.setChecked(true);
|
||||||
|
} else {
|
||||||
|
binding.detailsReceivePresence.setText(R.string.ask_for_presence_updates);
|
||||||
|
if (contact.getOption(Contact.Options.ASKING)) {
|
||||||
|
binding.detailsReceivePresence.setChecked(true);
|
||||||
|
} else {
|
||||||
|
binding.detailsReceivePresence.setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (contact.getAccount().isOnlineAndConnected()) {
|
||||||
|
binding.detailsReceivePresence.setEnabled(true);
|
||||||
|
binding.detailsSendPresence.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
binding.detailsReceivePresence.setEnabled(false);
|
||||||
|
binding.detailsSendPresence.setEnabled(false);
|
||||||
|
}
|
||||||
|
binding.detailsSendPresence.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
||||||
|
binding.detailsReceivePresence.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
||||||
|
} else {
|
||||||
|
binding.addContactButton.setVisibility(View.VISIBLE);
|
||||||
|
binding.detailsSendPresence.setVisibility(View.GONE);
|
||||||
|
binding.detailsReceivePresence.setVisibility(View.GONE);
|
||||||
|
binding.statusMessage.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
binding.detailsContactjid.setText(IrregularUnicodeDetector.style(this, contact.getJid()));
|
if (contact.isBlocked() && !this.showDynamicTags) {
|
||||||
String account;
|
binding.detailsLastseen.setVisibility(View.VISIBLE);
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
binding.detailsLastseen.setText(R.string.contact_blocked);
|
||||||
account = contact.getAccount().getJid().getLocal();
|
} else {
|
||||||
} else {
|
if (showLastSeen
|
||||||
account = contact.getAccount().getJid().asBareJid().toString();
|
&& contact.getLastseen() > 0
|
||||||
}
|
&& contact.getPresences().allOrNonSupport(Namespace.IDLE)) {
|
||||||
binding.detailsAccount.setText(getString(R.string.using_account, account));
|
binding.detailsLastseen.setVisibility(View.VISIBLE);
|
||||||
binding.detailsContactBadge.setImageBitmap(avatarService().get(contact, (int) getResources().getDimension(R.dimen.avatar_on_details_screen_size)));
|
binding.detailsLastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.isActive(), contact.getLastseen()));
|
||||||
binding.detailsContactBadge.setOnClickListener(this.onBadgeClick);
|
} else {
|
||||||
|
binding.detailsLastseen.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binding.detailsContactKeys.removeAllViews();
|
binding.detailsContactjid.setText(IrregularUnicodeDetector.style(this, contact.getJid()));
|
||||||
boolean hasKeys = false;
|
String account;
|
||||||
final LayoutInflater inflater = getLayoutInflater();
|
if (Config.DOMAIN_LOCK != null) {
|
||||||
final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
|
account = contact.getAccount().getJid().getLocal();
|
||||||
if (Config.supportOmemo() && axolotlService != null) {
|
} else {
|
||||||
boolean skippedInactive = false;
|
account = contact.getAccount().getJid().asBareJid().toString();
|
||||||
boolean showsInactive = false;
|
}
|
||||||
for (final XmppAxolotlSession session : axolotlService.findSessionsForContact(contact)) {
|
binding.detailsAccount.setText(getString(R.string.using_account, account));
|
||||||
final FingerprintStatus trust = session.getTrust();
|
binding.detailsContactBadge.setImageBitmap(avatarService().get(contact, (int) getResources().getDimension(R.dimen.avatar_on_details_screen_size)));
|
||||||
hasKeys |= !trust.isCompromised();
|
binding.detailsContactBadge.setOnClickListener(this.onBadgeClick);
|
||||||
if (!trust.isActive()) {
|
|
||||||
if (showInactiveOmemo) {
|
|
||||||
showsInactive = true;
|
|
||||||
} else {
|
|
||||||
skippedInactive = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!trust.isCompromised()) {
|
|
||||||
boolean highlight = session.getFingerprint().equals(messageFingerprint);
|
|
||||||
addFingerprintRow(binding.detailsContactKeys, session, highlight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (showsInactive || skippedInactive) {
|
|
||||||
binding.showInactiveDevices.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices);
|
|
||||||
binding.showInactiveDevices.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
binding.showInactiveDevices.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
binding.showInactiveDevices.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
binding.scanButton.setVisibility(hasKeys && isCameraFeatureAvailable() ? View.VISIBLE : View.GONE);
|
|
||||||
if (hasKeys) {
|
|
||||||
binding.scanButton.setOnClickListener((v) -> ScanActivity.scan(this));
|
|
||||||
}
|
|
||||||
if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) {
|
|
||||||
hasKeys = true;
|
|
||||||
View view = inflater.inflate(R.layout.contact_key, binding.detailsContactKeys, false);
|
|
||||||
TextView key = (TextView) view.findViewById(R.id.key);
|
|
||||||
TextView keyType = (TextView) view.findViewById(R.id.key_type);
|
|
||||||
keyType.setText(R.string.openpgp_key_id);
|
|
||||||
if ("pgp".equals(messageFingerprint)) {
|
|
||||||
keyType.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption_Highlight);
|
|
||||||
}
|
|
||||||
key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
|
|
||||||
final OnClickListener openKey = v -> launchOpenKeyChain(contact.getPgpKeyId());
|
|
||||||
view.setOnClickListener(openKey);
|
|
||||||
key.setOnClickListener(openKey);
|
|
||||||
keyType.setOnClickListener(openKey);
|
|
||||||
binding.detailsContactKeys.addView(view);
|
|
||||||
}
|
|
||||||
binding.keysWrapper.setVisibility(hasKeys ? View.VISIBLE : View.GONE);
|
|
||||||
|
|
||||||
List<ListItem.Tag> tagList = contact.getTags(this);
|
binding.detailsContactKeys.removeAllViews();
|
||||||
if (tagList.size() == 0 || !this.showDynamicTags) {
|
boolean hasKeys = false;
|
||||||
binding.tags.setVisibility(View.GONE);
|
final LayoutInflater inflater = getLayoutInflater();
|
||||||
} else {
|
final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
|
||||||
binding.tags.setVisibility(View.VISIBLE);
|
if (Config.supportOmemo() && axolotlService != null) {
|
||||||
binding.tags.removeAllViewsInLayout();
|
boolean skippedInactive = false;
|
||||||
for (final ListItem.Tag tag : tagList) {
|
boolean showsInactive = false;
|
||||||
final TextView tv = (TextView) inflater.inflate(R.layout.list_item_tag, binding.tags, false);
|
for (final XmppAxolotlSession session : axolotlService.findSessionsForContact(contact)) {
|
||||||
tv.setText(tag.getName());
|
final FingerprintStatus trust = session.getTrust();
|
||||||
tv.setBackgroundColor(tag.getColor());
|
hasKeys |= !trust.isCompromised();
|
||||||
binding.tags.addView(tv);
|
if (!trust.isActive()) {
|
||||||
}
|
if (showInactiveOmemo) {
|
||||||
}
|
showsInactive = true;
|
||||||
}
|
} else {
|
||||||
|
skippedInactive = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!trust.isCompromised()) {
|
||||||
|
boolean highlight = session.getFingerprint().equals(messageFingerprint);
|
||||||
|
addFingerprintRow(binding.detailsContactKeys, session, highlight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (showsInactive || skippedInactive) {
|
||||||
|
binding.showInactiveDevices.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices);
|
||||||
|
binding.showInactiveDevices.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
binding.showInactiveDevices.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
binding.showInactiveDevices.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
binding.scanButton.setVisibility(hasKeys && isCameraFeatureAvailable() ? View.VISIBLE : View.GONE);
|
||||||
|
if (hasKeys) {
|
||||||
|
binding.scanButton.setOnClickListener((v) -> ScanActivity.scan(this));
|
||||||
|
}
|
||||||
|
if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) {
|
||||||
|
hasKeys = true;
|
||||||
|
View view = inflater.inflate(R.layout.contact_key, binding.detailsContactKeys, false);
|
||||||
|
TextView key = (TextView) view.findViewById(R.id.key);
|
||||||
|
TextView keyType = (TextView) view.findViewById(R.id.key_type);
|
||||||
|
keyType.setText(R.string.openpgp_key_id);
|
||||||
|
if ("pgp".equals(messageFingerprint)) {
|
||||||
|
keyType.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption_Highlight);
|
||||||
|
}
|
||||||
|
key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
|
||||||
|
final OnClickListener openKey = v -> launchOpenKeyChain(contact.getPgpKeyId());
|
||||||
|
view.setOnClickListener(openKey);
|
||||||
|
key.setOnClickListener(openKey);
|
||||||
|
keyType.setOnClickListener(openKey);
|
||||||
|
binding.detailsContactKeys.addView(view);
|
||||||
|
}
|
||||||
|
binding.keysWrapper.setVisibility(hasKeys ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
public void onBackendConnected() {
|
List<ListItem.Tag> tagList = contact.getTags(this);
|
||||||
if (accountJid != null && contactJid != null) {
|
if (tagList.size() == 0 || !this.showDynamicTags) {
|
||||||
Account account = xmppConnectionService.findAccountByJid(accountJid);
|
binding.tags.setVisibility(View.GONE);
|
||||||
if (account == null) {
|
} else {
|
||||||
return;
|
binding.tags.setVisibility(View.VISIBLE);
|
||||||
}
|
binding.tags.removeAllViewsInLayout();
|
||||||
this.contact = account.getRoster().getContact(contactJid);
|
for (final ListItem.Tag tag : tagList) {
|
||||||
if (mPendingFingerprintVerificationUri != null) {
|
final TextView tv = (TextView) inflater.inflate(R.layout.list_item_tag, binding.tags, false);
|
||||||
processFingerprintVerification(mPendingFingerprintVerificationUri);
|
tv.setText(tag.getName());
|
||||||
mPendingFingerprintVerificationUri = null;
|
tv.setBackgroundColor(tag.getColor());
|
||||||
}
|
binding.tags.addView(tv);
|
||||||
populateView();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void onBackendConnected() {
|
||||||
public void onKeyStatusUpdated(AxolotlService.FetchStatus report) {
|
if (accountJid != null && contactJid != null) {
|
||||||
refreshUi();
|
Account account = xmppConnectionService.findAccountByJid(accountJid);
|
||||||
}
|
if (account == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.contact = account.getRoster().getContact(contactJid);
|
||||||
|
if (mPendingFingerprintVerificationUri != null) {
|
||||||
|
processFingerprintVerification(mPendingFingerprintVerificationUri);
|
||||||
|
mPendingFingerprintVerificationUri = null;
|
||||||
|
}
|
||||||
|
populateView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processFingerprintVerification(XmppUri uri) {
|
public void onKeyStatusUpdated(AxolotlService.FetchStatus report) {
|
||||||
if (contact != null && contact.getJid().asBareJid().equals(uri.getJid()) && uri.hasFingerprints()) {
|
refreshUi();
|
||||||
if (xmppConnectionService.verifyFingerprints(contact, uri.getFingerprints())) {
|
}
|
||||||
Toast.makeText(this, R.string.verified_fingerprints, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
@Override
|
||||||
} else {
|
protected void processFingerprintVerification(XmppUri uri) {
|
||||||
Toast.makeText(this, R.string.invalid_barcode, Toast.LENGTH_SHORT).show();
|
if (contact != null && contact.getJid().asBareJid().equals(uri.getJid()) && uri.hasFingerprints()) {
|
||||||
}
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,6 +328,7 @@
|
||||||
<string name="file_deleted">The file has been deleted</string>
|
<string name="file_deleted">The file has been deleted</string>
|
||||||
<string name="no_application_found_to_open_file">No application found to open file</string>
|
<string name="no_application_found_to_open_file">No application found to open file</string>
|
||||||
<string name="no_application_found_to_open_link">No application found to open link</string>
|
<string name="no_application_found_to_open_link">No application found to open link</string>
|
||||||
|
<string name="no_application_found_to_view_contact">No application found to view contact</string>
|
||||||
<string name="pref_show_dynamic_tags">Dynamic Tags</string>
|
<string name="pref_show_dynamic_tags">Dynamic Tags</string>
|
||||||
<string name="pref_show_dynamic_tags_summary">Display read-only tags underneath contacts</string>
|
<string name="pref_show_dynamic_tags_summary">Display read-only tags underneath contacts</string>
|
||||||
<string name="enable_notifications">Enable notifications</string>
|
<string name="enable_notifications">Enable notifications</string>
|
||||||
|
|
Loading…
Reference in a new issue