use of org.thoughtcrime.securesms.recipients.LiveRecipient in project Signal-Android by WhisperSystems.
the class SharedContactDetailsActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState, boolean ready) {
setContentView(R.layout.activity_shared_contact_details);
if (getIntent() == null) {
throw new IllegalStateException("You must supply arguments to this activity. Please use the #getIntent() method.");
}
contact = getIntent().getParcelableExtra(KEY_CONTACT);
if (contact == null) {
throw new IllegalStateException("You must supply a contact to this activity. Please use the #getIntent() method.");
}
initToolbar();
initViews();
presentContact(contact);
presentActionButtons(ContactUtil.getRecipients(this, contact));
presentAvatar(contact.getAvatarAttachment() != null ? contact.getAvatarAttachment().getUri() : null);
for (LiveRecipient recipient : activeRecipients.values()) {
recipient.observe(this, r -> presentActionButtons(Collections.singletonList(r.getId())));
}
}
use of org.thoughtcrime.securesms.recipients.LiveRecipient in project Signal-Android by WhisperSystems.
the class SharedContactDetailsActivity method presentActionButtons.
private void presentActionButtons(@NonNull List<RecipientId> recipients) {
for (RecipientId recipientId : recipients) {
activeRecipients.put(recipientId, Recipient.live(recipientId));
}
List<Recipient> pushUsers = new ArrayList<>(recipients.size());
List<Recipient> systemUsers = new ArrayList<>(recipients.size());
for (LiveRecipient recipient : activeRecipients.values()) {
if (recipient.get().getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) {
pushUsers.add(recipient.get());
} else if (recipient.get().isSystemContact()) {
systemUsers.add(recipient.get());
}
}
if (!pushUsers.isEmpty()) {
engageContainerView.setVisibility(View.VISIBLE);
inviteButtonView.setVisibility(View.GONE);
messageButtonView.setOnClickListener(v -> {
ContactUtil.selectRecipientThroughDialog(this, pushUsers, dynamicLanguage.getCurrentLocale(), recipient -> {
CommunicationActions.startConversation(this, recipient, null);
});
});
callButtonView.setOnClickListener(v -> {
ContactUtil.selectRecipientThroughDialog(this, pushUsers, dynamicLanguage.getCurrentLocale(), recipient -> CommunicationActions.startVoiceCall(this, recipient));
});
} else if (!systemUsers.isEmpty()) {
inviteButtonView.setVisibility(View.VISIBLE);
engageContainerView.setVisibility(View.GONE);
inviteButtonView.setOnClickListener(v -> {
ContactUtil.selectRecipientThroughDialog(this, systemUsers, dynamicLanguage.getCurrentLocale(), recipient -> {
CommunicationActions.composeSmsThroughDefaultApp(this, recipient, getString(R.string.InviteActivity_lets_switch_to_signal, getString(R.string.install_url)));
});
});
} else {
inviteButtonView.setVisibility(View.GONE);
engageContainerView.setVisibility(View.GONE);
}
}
use of org.thoughtcrime.securesms.recipients.LiveRecipient in project Signal-Android by WhisperSystems.
the class MessageRequestRepository method blockMessageRequest.
void blockMessageRequest(@NonNull LiveRecipient liveRecipient, @NonNull Runnable onMessageRequestBlocked, @NonNull GroupChangeErrorCallback error) {
executor.execute(() -> {
Recipient recipient = liveRecipient.resolve();
try {
RecipientUtil.block(context, recipient);
} catch (GroupChangeException | IOException e) {
Log.w(TAG, e);
error.onError(GroupChangeFailureReason.fromException(e));
return;
}
liveRecipient.refresh();
if (TextSecurePreferences.isMultiDevice(context)) {
ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forBlock(liveRecipient.getId()));
}
onMessageRequestBlocked.run();
});
}
Aggregations