|
|
|
@ -155,13 +155,14 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository;
|
|
|
|
|
import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
|
|
|
|
|
import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel;
|
|
|
|
|
import org.thoughtcrime.securesms.logging.Log;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.database.LokiMessageDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.database.LokiThreadDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.database.LokiThreadDatabaseDelegate;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.database.LokiUserDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.protocol.FriendRequestProtocol;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.views.FriendRequestViewDelegate;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.views.MentionCandidateSelectionView;
|
|
|
|
|
import org.thoughtcrime.securesms.loki.views.SessionRestoreBannerView;
|
|
|
|
@ -232,7 +233,7 @@ import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChat;
|
|
|
|
|
import org.whispersystems.signalservice.loki.protocol.mentions.Mention;
|
|
|
|
|
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager;
|
|
|
|
|
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink;
|
|
|
|
|
import org.whispersystems.signalservice.loki.protocol.multidevice.LokiDeviceLinkUtilities;
|
|
|
|
|
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol;
|
|
|
|
|
import org.whispersystems.signalservice.loki.protocol.todo.LokiMessageFriendRequestStatus;
|
|
|
|
|
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus;
|
|
|
|
|
import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation;
|
|
|
|
@ -326,7 +327,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
private MenuItem searchViewItem;
|
|
|
|
|
private ProgressBar messageStatusProgressBar;
|
|
|
|
|
private ImageView muteIndicatorImageView;
|
|
|
|
|
private TextView subtitleTextView;
|
|
|
|
|
private TextView subtitleTextView;
|
|
|
|
|
|
|
|
|
|
private AttachmentTypeSelector attachmentTypeSelector;
|
|
|
|
|
private AttachmentManager attachmentManager;
|
|
|
|
@ -357,7 +358,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
private final DynamicNoActionBarTheme dynamicTheme = new DynamicNoActionBarTheme();
|
|
|
|
|
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
|
|
|
|
|
|
|
|
|
// Message Status Bar
|
|
|
|
|
// Message status bar
|
|
|
|
|
private ArrayList<BroadcastReceiver> broadcastReceivers = new ArrayList<>();
|
|
|
|
|
private String messageStatus = null;
|
|
|
|
|
|
|
|
|
@ -368,9 +369,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
private ArrayList<Mention> mentions = new ArrayList<>();
|
|
|
|
|
private String oldText = "";
|
|
|
|
|
|
|
|
|
|
// Multi Device
|
|
|
|
|
private boolean isFriendsWithAnyDevice = false;
|
|
|
|
|
|
|
|
|
|
// Restoration
|
|
|
|
|
protected SessionRestoreBannerView sessionRestoreBannerView;
|
|
|
|
|
|
|
|
|
@ -559,6 +557,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
markThreadAsRead();
|
|
|
|
|
|
|
|
|
|
DatabaseFactory.getLokiThreadDatabase(this).setDelegate(this);
|
|
|
|
|
|
|
|
|
|
updateInputPanel();
|
|
|
|
|
|
|
|
|
|
updateSessionRestoreBanner();
|
|
|
|
@ -887,7 +886,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
case R.id.menu_invite: handleInviteLink(); return true;
|
|
|
|
|
case R.id.menu_mute_notifications: handleMuteNotifications(); return true;
|
|
|
|
|
case R.id.menu_unmute_notifications: handleUnmuteNotifications(); return true;
|
|
|
|
|
// case R.id.menu_conversation_settings: handleConversationSettings(); return true;
|
|
|
|
|
// case R.id.menu_conversation_settings: handleConversationSettings(); return true;
|
|
|
|
|
case R.id.menu_expiring_messages_off:
|
|
|
|
|
case R.id.menu_expiring_messages: handleSelectMessageExpiration(); return true;
|
|
|
|
|
case android.R.id.home: handleReturnToConversationList(); return true;
|
|
|
|
@ -1240,11 +1239,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
private boolean handleDisplayQuickContact() {
|
|
|
|
|
return !recipient.getAddress().isGroup();
|
|
|
|
|
|
|
|
|
|
// if (recipient.getContactUri() != null) {
|
|
|
|
|
// ContactsContract.QuickContact.showQuickContact(ConversationActivity.this, titleView, recipient.getContactUri(), ContactsContract.QuickContact.MODE_LARGE, null);
|
|
|
|
|
// } else {
|
|
|
|
|
// handleAddToContacts();
|
|
|
|
|
// }
|
|
|
|
|
/*
|
|
|
|
|
if (recipient.getContactUri() != null) {
|
|
|
|
|
ContactsContract.QuickContact.showQuickContact(ConversationActivity.this, titleView, recipient.getContactUri(), ContactsContract.QuickContact.MODE_LARGE, null);
|
|
|
|
|
} else {
|
|
|
|
|
handleAddToContacts();
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleAddAttachment() {
|
|
|
|
@ -1531,7 +1532,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void updateSessionRestoreBanner() {
|
|
|
|
|
private void updateSessionRestoreBanner() {
|
|
|
|
|
Set<String> devices = DatabaseFactory.getLokiThreadDatabase(this).getSessionRestoreDevices(threadId);
|
|
|
|
|
if (devices.size() > 0) {
|
|
|
|
|
sessionRestoreBannerView.update(recipient);
|
|
|
|
@ -1617,30 +1618,30 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initializeViews() {
|
|
|
|
|
titleTextView = findViewById(R.id.titleTextView);
|
|
|
|
|
buttonToggle = ViewUtil.findById(this, R.id.button_toggle);
|
|
|
|
|
sendButton = ViewUtil.findById(this, R.id.send_button);
|
|
|
|
|
attachButton = ViewUtil.findById(this, R.id.attach_button);
|
|
|
|
|
composeText = ViewUtil.findById(this, R.id.embedded_text_editor);
|
|
|
|
|
charactersLeft = ViewUtil.findById(this, R.id.space_left);
|
|
|
|
|
emojiDrawerStub = ViewUtil.findStubById(this, R.id.emoji_drawer_stub);
|
|
|
|
|
unblockButton = ViewUtil.findById(this, R.id.unblock_button);
|
|
|
|
|
makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button);
|
|
|
|
|
registerButton = ViewUtil.findById(this, R.id.register_button);
|
|
|
|
|
container = ViewUtil.findById(this, R.id.layout_container);
|
|
|
|
|
reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
|
|
|
|
|
unverifiedBannerView = ViewUtil.findStubById(this, R.id.unverified_banner_stub);
|
|
|
|
|
groupShareProfileView = ViewUtil.findStubById(this, R.id.group_share_profile_view_stub);
|
|
|
|
|
quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
|
|
|
|
|
inlineAttachmentToggle = ViewUtil.findById(this, R.id.inline_attachment_container);
|
|
|
|
|
inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
|
|
|
|
|
searchNav = ViewUtil.findById(this, R.id.conversation_search_nav);
|
|
|
|
|
titleTextView = findViewById(R.id.titleTextView);
|
|
|
|
|
buttonToggle = ViewUtil.findById(this, R.id.button_toggle);
|
|
|
|
|
sendButton = ViewUtil.findById(this, R.id.send_button);
|
|
|
|
|
attachButton = ViewUtil.findById(this, R.id.attach_button);
|
|
|
|
|
composeText = ViewUtil.findById(this, R.id.embedded_text_editor);
|
|
|
|
|
charactersLeft = ViewUtil.findById(this, R.id.space_left);
|
|
|
|
|
emojiDrawerStub = ViewUtil.findStubById(this, R.id.emoji_drawer_stub);
|
|
|
|
|
unblockButton = ViewUtil.findById(this, R.id.unblock_button);
|
|
|
|
|
makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button);
|
|
|
|
|
registerButton = ViewUtil.findById(this, R.id.register_button);
|
|
|
|
|
container = ViewUtil.findById(this, R.id.layout_container);
|
|
|
|
|
reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
|
|
|
|
|
unverifiedBannerView = ViewUtil.findStubById(this, R.id.unverified_banner_stub);
|
|
|
|
|
groupShareProfileView = ViewUtil.findStubById(this, R.id.group_share_profile_view_stub);
|
|
|
|
|
quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
|
|
|
|
|
inlineAttachmentToggle = ViewUtil.findById(this, R.id.inline_attachment_container);
|
|
|
|
|
inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
|
|
|
|
|
searchNav = ViewUtil.findById(this, R.id.conversation_search_nav);
|
|
|
|
|
mentionCandidateSelectionViewContainer = ViewUtil.findById(this, R.id.mentionCandidateSelectionViewContainer);
|
|
|
|
|
mentionCandidateSelectionView = ViewUtil.findById(this, R.id.userSelectionView);
|
|
|
|
|
sessionRestoreBannerView = ViewUtil.findById(this, R.id.sessionRestoreBannerView);
|
|
|
|
|
messageStatusProgressBar = ViewUtil.findById(this, R.id.messageStatusProgressBar);
|
|
|
|
|
muteIndicatorImageView = ViewUtil.findById(this, R.id.muteIndicatorImageView);
|
|
|
|
|
subtitleTextView = ViewUtil.findById(this, R.id.subtitleTextView);
|
|
|
|
|
mentionCandidateSelectionView = ViewUtil.findById(this, R.id.userSelectionView);
|
|
|
|
|
sessionRestoreBannerView = ViewUtil.findById(this, R.id.sessionRestoreBannerView);
|
|
|
|
|
messageStatusProgressBar = ViewUtil.findById(this, R.id.messageStatusProgressBar);
|
|
|
|
|
muteIndicatorImageView = ViewUtil.findById(this, R.id.muteIndicatorImageView);
|
|
|
|
|
subtitleTextView = ViewUtil.findById(this, R.id.subtitleTextView);
|
|
|
|
|
|
|
|
|
|
ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle);
|
|
|
|
|
ImageButton inlineAttachmentButton = ViewUtil.findById(this, R.id.inline_attachment_button);
|
|
|
|
@ -2249,72 +2250,39 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void handleThreadFriendRequestStatusChanged(long threadID) {
|
|
|
|
|
if (threadID != this.threadId) {
|
|
|
|
|
Recipient threadRecipient = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID);
|
|
|
|
|
if (threadRecipient != null && !threadRecipient.isGroupRecipient()) {
|
|
|
|
|
LokiDeviceLinkUtilities.INSTANCE.getAllLinkedDeviceHexEncodedPublicKeys(threadRecipient.getAddress().serialize()).success(devices -> {
|
|
|
|
|
// We should update our input if this thread is a part of the other threads device
|
|
|
|
|
if (devices.contains(recipient.getAddress().serialize())) {
|
|
|
|
|
this.updateInputPanel();
|
|
|
|
|
}
|
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
if (recipient.isGroupRecipient()) { return; }
|
|
|
|
|
boolean isUpdateNeeded = false;
|
|
|
|
|
if (threadID == this.threadId) {
|
|
|
|
|
isUpdateNeeded = true;
|
|
|
|
|
} else {
|
|
|
|
|
String thisThreadPublicKey = recipient.getAddress().serialize();
|
|
|
|
|
Set<String> thisThreadAssociatedDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(thisThreadPublicKey);
|
|
|
|
|
Recipient changedThreadRecipient = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID);
|
|
|
|
|
String changedThreadPublicKey = changedThreadRecipient.getAddress().serialize();
|
|
|
|
|
for (String device : thisThreadAssociatedDevices) {
|
|
|
|
|
if (device.equals(changedThreadPublicKey)) { isUpdateNeeded = true; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.updateInputPanel();
|
|
|
|
|
}
|
|
|
|
|
if (isUpdateNeeded) {
|
|
|
|
|
updateInputPanel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void handleSessionRestoreDevicesChanged(long threadId) {
|
|
|
|
|
if (threadId == this.threadId) {
|
|
|
|
|
public void handleSessionRestoreDevicesChanged(long threadID) {
|
|
|
|
|
if (threadID == this.threadId) {
|
|
|
|
|
runOnUiThread(this::updateSessionRestoreBanner);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateInputPanel() {
|
|
|
|
|
/*
|
|
|
|
|
isFriendsWithAnyDevice reflects whether we are friends with any of the other user's devices.
|
|
|
|
|
|
|
|
|
|
This fixes the case where the input panel disables and enables rapidly, which can occur when we are
|
|
|
|
|
not friends with the current thread BUT multi device tells us that we are friends with another one of their devices.
|
|
|
|
|
*/
|
|
|
|
|
if (recipient.isGroupRecipient() || isNoteToSelf() || isFriendsWithAnyDevice) { setInputPanelEnabled(true); return; }
|
|
|
|
|
|
|
|
|
|
// Disable the input panel if a friend request is pending
|
|
|
|
|
LokiThreadFriendRequestStatus friendRequestStatus = DatabaseFactory.getLokiThreadDatabase(this).getFriendRequestStatus(threadId);
|
|
|
|
|
boolean isPending = friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENDING || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENT || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_RECEIVED;
|
|
|
|
|
setInputPanelEnabled(!isPending);
|
|
|
|
|
|
|
|
|
|
// Always enable the input panel if we are friends with the current user
|
|
|
|
|
isFriendsWithAnyDevice = (friendRequestStatus == LokiThreadFriendRequestStatus.FRIENDS);
|
|
|
|
|
|
|
|
|
|
if (!isFriendsWithAnyDevice) {
|
|
|
|
|
// Enable the input panel if we don't have any pending friend requests OR we are friends with one of the user's linked devices
|
|
|
|
|
MultiDeviceUtilities.hasPendingFriendRequestWithAnyLinkedDevice(this, recipient).success( hasPendingRequests -> {
|
|
|
|
|
if (!hasPendingRequests) {
|
|
|
|
|
setInputPanelEnabled(true);
|
|
|
|
|
} else {
|
|
|
|
|
MultiDeviceUtilities.isFriendsWithAnyLinkedDevice(this, recipient).success( isFriends -> {
|
|
|
|
|
// Enable the input panel if we're friends with any of the user's devices
|
|
|
|
|
isFriendsWithAnyDevice = isFriends;
|
|
|
|
|
setInputPanelEnabled(isFriends);
|
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setInputPanelEnabled(boolean enabled) {
|
|
|
|
|
boolean shouldInputPanelBeEnabled = FriendRequestProtocol.shouldInputPanelBeEnabled(threadId);
|
|
|
|
|
Util.runOnMain(() -> {
|
|
|
|
|
updateToggleButtonState();
|
|
|
|
|
String hint = enabled ? "Message" : "Pending session request";
|
|
|
|
|
String hint = shouldInputPanelBeEnabled ? "Message" : "Pending session request";
|
|
|
|
|
inputPanel.setHint(hint);
|
|
|
|
|
inputPanel.setEnabled(enabled);
|
|
|
|
|
if (enabled && inputPanel.getVisibility() == View.VISIBLE) {
|
|
|
|
|
inputPanel.setEnabled(shouldInputPanelBeEnabled);
|
|
|
|
|
if (shouldInputPanelBeEnabled && inputPanel.getVisibility() == View.VISIBLE) {
|
|
|
|
|
inputPanel.composeText.requestFocus();
|
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
|
|
|
|
inputMethodManager.showSoftInput(inputPanel.composeText, 0);
|
|
|
|
@ -2508,8 +2476,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateToggleButtonState() {
|
|
|
|
|
// Don't allow attachments if we're not friends with any of the user's devices
|
|
|
|
|
if (!isNoteToSelf() && !recipient.isGroupRecipient() && !isFriendsWithAnyDevice) {
|
|
|
|
|
if (!FriendRequestProtocol.shouldAttachmentsButtonBeEnabled(threadId)) {
|
|
|
|
|
buttonToggle.display(sendButton);
|
|
|
|
|
quickAttachmentToggle.hide();
|
|
|
|
|
inlineAttachmentToggle.hide();
|
|
|
|
@ -2745,7 +2712,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
private void silentlySetComposeText(String text) {
|
|
|
|
|
typingTextWatcher.setEnabled(false);
|
|
|
|
|
composeText.setText(text);
|
|
|
|
|
if (text.isEmpty()) resetMentions();
|
|
|
|
|
if (text.isEmpty()) { resetMentions(); }
|
|
|
|
|
typingTextWatcher.setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3106,17 +3073,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
|
|
|
|
|
// region Loki
|
|
|
|
|
private void updateTitleTextView(Recipient recipient) {
|
|
|
|
|
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
|
|
|
|
Set<DeviceLink> deviceLinks = DatabaseFactory.getLokiAPIDatabase(this).getDeviceLinks(userHexEncodedPublicKey);
|
|
|
|
|
HashSet<String> userLinkedDeviceHexEncodedPublicKeys = new HashSet<>();
|
|
|
|
|
for (DeviceLink deviceLink : deviceLinks) {
|
|
|
|
|
userLinkedDeviceHexEncodedPublicKeys.add(deviceLink.getMasterHexEncodedPublicKey().toLowerCase());
|
|
|
|
|
userLinkedDeviceHexEncodedPublicKeys.add(deviceLink.getSlaveHexEncodedPublicKey().toLowerCase());
|
|
|
|
|
}
|
|
|
|
|
userLinkedDeviceHexEncodedPublicKeys.add(userHexEncodedPublicKey.toLowerCase());
|
|
|
|
|
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
|
|
|
|
|
Set<String> allUserDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey);
|
|
|
|
|
if (recipient == null) {
|
|
|
|
|
titleTextView.setText("Compose");
|
|
|
|
|
} else if (userLinkedDeviceHexEncodedPublicKeys.contains(recipient.getAddress().toString().toLowerCase())) {
|
|
|
|
|
} else if (allUserDevices.contains(recipient.getAddress().toString().toLowerCase())) {
|
|
|
|
|
titleTextView.setText("Note to Self");
|
|
|
|
|
} else {
|
|
|
|
|
boolean hasName = (recipient.getName() != null && !recipient.getName().isEmpty());
|
|
|
|
@ -3229,51 +3190,5 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
updateSubtitleTextView();
|
|
|
|
|
updateMessageStatusProgressBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void acceptFriendRequest(@NotNull MessageRecord friendRequest) {
|
|
|
|
|
// Send the accept to the original friend request thread ID
|
|
|
|
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(this);
|
|
|
|
|
long originalThreadID = lokiMessageDatabase.getOriginalThreadID(friendRequest.id);
|
|
|
|
|
long threadID = originalThreadID < 0 ? this.threadId : originalThreadID;
|
|
|
|
|
Recipient contact = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID);
|
|
|
|
|
Address address = contact.getAddress();
|
|
|
|
|
String contactHexEncodedPublicKey = address.serialize();
|
|
|
|
|
DatabaseFactory.getLokiThreadDatabase(this).setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS);
|
|
|
|
|
lokiMessageDatabase.setFriendRequestStatus(friendRequest.id, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
|
|
|
|
DatabaseFactory.getRecipientDatabase(this).setProfileSharing(contact, true);
|
|
|
|
|
MessageSender.sendBackgroundMessageToAllDevices(this, contactHexEncodedPublicKey);
|
|
|
|
|
MessageSender.syncContact(this, address);
|
|
|
|
|
updateInputPanel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void rejectFriendRequest(@NotNull MessageRecord friendRequest) {
|
|
|
|
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(this);
|
|
|
|
|
long originalThreadID = lokiMessageDatabase.getOriginalThreadID(friendRequest.id);
|
|
|
|
|
long threadID = originalThreadID < 0 ? this.threadId : originalThreadID;
|
|
|
|
|
DatabaseFactory.getLokiThreadDatabase(this).setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.NONE);
|
|
|
|
|
String contactID = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID).getAddress().toString();
|
|
|
|
|
DatabaseFactory.getLokiPreKeyBundleDatabase(this).removePreKeyBundle(contactID);
|
|
|
|
|
updateInputPanel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isNoteToSelf() {
|
|
|
|
|
return TextSecurePreferences.getLocalNumber(this).equals(recipient.getAddress().serialize());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void restoreSession() {
|
|
|
|
|
if (recipient.isGroupRecipient()) { return; }
|
|
|
|
|
LokiThreadDatabase lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(this);
|
|
|
|
|
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(this);
|
|
|
|
|
Set<String> devices = lokiThreadDatabase.getSessionRestoreDevices(threadId);
|
|
|
|
|
for (String device : devices) { MessageSender.sendRestoreSessionMessage(this, device); }
|
|
|
|
|
long messageID = smsDatabase.insertMessageOutbox(threadId, new OutgoingTextMessage(recipient,"", 0, 0), false, System.currentTimeMillis(), null);
|
|
|
|
|
if (messageID > -1) {
|
|
|
|
|
smsDatabase.markAsSentLokiSessionRestorationRequest(messageID);
|
|
|
|
|
}
|
|
|
|
|
lokiThreadDatabase.removeAllSessionRestoreDevices(threadId);
|
|
|
|
|
updateSessionRestoreBanner();
|
|
|
|
|
}
|
|
|
|
|
// endregion
|
|
|
|
|
}
|
|
|
|
|