mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 21:08:26 +00:00
Clean
This commit is contained in:
parent
ed2ab2d78a
commit
8e53383ab9
@ -332,7 +332,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onAvatarModified(RecipientAvatarModifiedEvent event) {
|
||||
Recipient recipient = event.getRecipient();
|
||||
if (recipient.isLocalNumber() || recipient.isOurMasterDevice()) {
|
||||
if (recipient.isLocalNumber() || recipient.isUserMasterDevice()) {
|
||||
initializeProfileIcon(recipient);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ public class LinkPreviewView extends FrameLayout {
|
||||
container.setBackgroundColor(Color.TRANSPARENT);
|
||||
container.setPadding(0, 0, 0, 0);
|
||||
divider.setVisibility(VISIBLE);
|
||||
// closeButton.setVisibility(VISIBLE);
|
||||
|
||||
closeButton.setOnClickListener(v -> {
|
||||
if (closeClickedListener != null) {
|
||||
|
@ -108,11 +108,7 @@ public class SendButton extends AppCompatImageButton
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
// if (isEnabled() && transportOptions.getEnabledTransports().size() > 1) {
|
||||
// getTransportOptionsPopup().display(transportOptions.getEnabledTransports());
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// Loki - Do nothing
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,6 @@ public class TransferControlView extends FrameLayout {
|
||||
|
||||
if (view != null) {
|
||||
view.setVisibility(VISIBLE);
|
||||
// setVisibility(VISIBLE);
|
||||
} else {
|
||||
setVisibility(GONE);
|
||||
}
|
||||
|
@ -9,17 +9,16 @@ import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.jobs.TypingSendJob;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.LokiDeviceLinkUtilities;
|
||||
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
@SuppressLint("UseSparseArrays")
|
||||
public class TypingStatusSender {
|
||||
|
||||
@ -82,24 +81,15 @@ public class TypingStatusSender {
|
||||
}
|
||||
|
||||
private void sendTyping(long threadId, boolean typingStarted) {
|
||||
LokiFileServerAPI storageAPI = LokiFileServerAPI.Companion.getShared();
|
||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||
Recipient recipient = threadDatabase.getRecipientForThreadId(threadId);
|
||||
|
||||
if (recipient == null) {
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(threadId, typingStarted));
|
||||
return;
|
||||
if (!SessionMetaProtocol.shouldSendTypingIndicator(recipient, context)) { return; }
|
||||
Set<String> linkedDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(recipient.getAddress().serialize());
|
||||
for (String device : linkedDevices) {
|
||||
Recipient deviceAsRecipient = Recipient.from(context, Address.fromSerialized(device), false);
|
||||
long deviceThreadID = threadDatabase.getThreadIdFor(deviceAsRecipient)
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(deviceThreadID, typingStarted));
|
||||
}
|
||||
LokiDeviceLinkUtilities.INSTANCE.getAllLinkedDeviceHexEncodedPublicKeys(recipient.getAddress().serialize()).success(devices -> {
|
||||
for (String device : devices) {
|
||||
Recipient deviceRecipient = Recipient.from(context, Address.fromSerialized(device), false);
|
||||
long deviceThreadID = threadDatabase.getThreadIdIfExistsFor(deviceRecipient);
|
||||
if (deviceThreadID > -1) {
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(deviceThreadID, typingStarted));
|
||||
}
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
private class StartRunnable implements Runnable {
|
||||
|
@ -8,9 +8,9 @@ import android.provider.Telephony;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
public class DefaultSmsReminder extends Reminder {
|
||||
|
||||
@ -40,14 +40,5 @@ public class DefaultSmsReminder extends Reminder {
|
||||
|
||||
public static boolean isEligible(Context context) {
|
||||
return false;
|
||||
// Loki - Original code
|
||||
// ========
|
||||
// final boolean isDefault = Util.isDefaultSmsProvider(context);
|
||||
// if (isDefault) {
|
||||
// TextSecurePreferences.setPromptedDefaultSmsProvider(context, false);
|
||||
// }
|
||||
//
|
||||
// return !isDefault && !TextSecurePreferences.hasPromptedDefaultSmsProvider(context);
|
||||
// ========
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.thoughtcrime.securesms.RegistrationActivity;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
public class PushRegistrationReminder extends Reminder {
|
||||
|
||||
@ -30,9 +30,5 @@ public class PushRegistrationReminder extends Reminder {
|
||||
|
||||
public static boolean isEligible(Context context) {
|
||||
return false;
|
||||
// Loki - Original code
|
||||
// ========
|
||||
// return !TextSecurePreferences.isPushRegistered(context);
|
||||
// ========
|
||||
}
|
||||
}
|
||||
|
@ -49,8 +49,6 @@ public class ConversationPopupActivity extends ConversationActivity {
|
||||
else getWindow().setLayout((int) (width * .7), (int) (height * .75));
|
||||
|
||||
super.onCreate(bundle, ready);
|
||||
|
||||
// titleView.setOnClickListener(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,10 +160,11 @@ public class GroupDatabase extends Database {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
public boolean signalGroupsHaveMember(String hexEncodedPublicKey) {
|
||||
public boolean isClosedGroupMember(String hexEncodedPublicKey) {
|
||||
try {
|
||||
Address address = Address.fromSerialized(hexEncodedPublicKey);
|
||||
Reader reader = DatabaseFactory.getGroupDatabase(context).getGroups();
|
||||
|
||||
GroupRecord record;
|
||||
while ((record = reader.getNext()) != null) {
|
||||
if (record.isSignalGroup() && record.members.contains(address)) {
|
||||
|
@ -537,7 +537,7 @@ public class ThreadDatabase extends Database {
|
||||
}
|
||||
|
||||
public @Nullable Recipient getRecipientForThreadId(long threadId) {
|
||||
// Loki - Cache the address.
|
||||
// Loki - Cache the address
|
||||
if (addressCache.containsKey(threadId) && addressCache.get(threadId) != null) {
|
||||
return Recipient.from(context, addressCache.get(threadId), false);
|
||||
}
|
||||
|
@ -181,8 +181,8 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
@Override
|
||||
public void onConfigure(SQLiteDatabase db) {
|
||||
super.onConfigure(db);
|
||||
// Loki: Enable Write Ahead Logging Mode, increase the cache size
|
||||
// This should be disabled if we ever run into serious race condition bugs
|
||||
// Loki - Enable write ahead logging mode and increase the cache size.
|
||||
// This should be disabled if we ever run into serious race condition bugs.
|
||||
db.enableWriteAheadLogging();
|
||||
db.execSQL("PRAGMA cache_size = 10000");
|
||||
}
|
||||
@ -555,7 +555,7 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate rss feeds from __textsecure_group__ to __loki_rss_feed_group__
|
||||
// Migrate RSS feeds from __textsecure_group__ to __loki_rss_feed_group__
|
||||
String[] rssFeedIds = new String[] { "loki.network.feed", "loki.network.messenger-updates.feed" };
|
||||
for (String groupId : rssFeedIds) {
|
||||
String oldId = GroupUtil.getEncodedId(groupId.getBytes(), false);
|
||||
|
@ -199,7 +199,8 @@ public class AttachmentDownloadJob extends BaseJob implements InjectableType {
|
||||
return new SignalServiceAttachmentPointer(id, null, new byte[0],
|
||||
Optional.of(Util.toIntExact(attachment.getSize())),
|
||||
Optional.absent(),
|
||||
0, 0,
|
||||
0,
|
||||
0,
|
||||
Optional.fromNullable(attachment.getDigest()),
|
||||
Optional.fromNullable(attachment.getFileName()),
|
||||
attachment.isVoiceNote(),
|
||||
|
@ -84,8 +84,7 @@ public class MultiDeviceBlockedUpdateJob extends BaseJob implements InjectableTy
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blockedIndividuals, blockedGroups)),
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blockedIndividuals, blockedGroups)),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +91,7 @@ public class MultiDeviceConfigurationUpdateJob extends BaseJob implements Inject
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forConfiguration(new ConfigurationMessage(Optional.of(readReceiptsEnabled),
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forConfiguration(new ConfigurationMessage(Optional.of(readReceiptsEnabled),
|
||||
Optional.of(unidentifiedDeliveryIndicatorsEnabled),
|
||||
Optional.of(typingIndicatorsEnabled),
|
||||
Optional.of(linkPreviewsEnabled))),
|
||||
|
@ -23,7 +23,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStre
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.DeviceGroup;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.DeviceGroupsOutputStream;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@ -126,7 +125,6 @@ public class MultiDeviceGroupUpdateJob extends BaseJob implements InjectableType
|
||||
@Override
|
||||
public boolean onShouldRetry(@NonNull Exception exception) {
|
||||
// Loki - Disabled because we have our own retrying
|
||||
// if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -145,7 +143,7 @@ public class MultiDeviceGroupUpdateJob extends BaseJob implements InjectableType
|
||||
.withLength(contactsFile.length())
|
||||
.build();
|
||||
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forGroups(attachmentStream),
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,9 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob implements Injectabl
|
||||
.withLength(baos.toByteArray().length)
|
||||
.build();
|
||||
|
||||
SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false));
|
||||
SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false));
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendMessage(0, syncMessage, UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
messageSender.sendMessage(syncMessage, UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,8 +94,7 @@ public class MultiDeviceReadUpdateJob extends BaseJob implements InjectableType
|
||||
readMessages.add(new ReadMessage(messageId.sender, messageId.timestamp));
|
||||
}
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forRead(readMessages), UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages), UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,7 +94,7 @@ public class MultiDeviceStickerPackOperationJob extends BaseJob implements Injec
|
||||
|
||||
StickerPackOperationMessage stickerPackOperation = new StickerPackOperationMessage(packIdBytes, packKeyBytes, remoteType);
|
||||
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forStickerPackOperations(Collections.singletonList(stickerPackOperation)), // The message ID doesn't matter
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forStickerPackOperations(Collections.singletonList(stickerPackOperation)),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class MultiDeviceStickerPackSyncJob extends BaseJob implements Injectable
|
||||
}
|
||||
}
|
||||
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forStickerPackOperations(operations), // The message ID doesn't matter
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forStickerPackOperations(operations),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
||||
|
@ -104,8 +104,7 @@ public class MultiDeviceVerifiedUpdateJob extends BaseJob implements InjectableT
|
||||
VerifiedMessage.VerifiedState verifiedState = getVerifiedState(verifiedStatus);
|
||||
VerifiedMessage verifiedMessage = new VerifiedMessage(canonicalDestination.toPhoneString(), new IdentityKey(identityKey, 0), verifiedState, timestamp);
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forVerified(verifiedMessage),
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forVerified(verifiedMessage),
|
||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.fromSerialized(destination), false)));
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new IOException(e);
|
||||
|
@ -1294,7 +1294,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, Address.fromSerialized(sender), false));
|
||||
LokiThreadFriendRequestStatus threadFriendRequestStatus = DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID);
|
||||
boolean isOurFriend = threadFriendRequestStatus == LokiThreadFriendRequestStatus.FRIENDS;
|
||||
boolean isInOneOfOurGroups = DatabaseFactory.getGroupDatabase(context).signalGroupsHaveMember(sender);
|
||||
boolean isInOneOfOurGroups = DatabaseFactory.getGroupDatabase(context).isClosedGroupMember(sender);
|
||||
boolean shouldAcceptSessionRequest = isOurFriend || isInOneOfOurGroups;
|
||||
if (shouldAcceptSessionRequest) {
|
||||
MessageSender.sendBackgroundMessage(context, content.getSender()); // Send a background message to acknowledge
|
||||
@ -1581,7 +1581,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new RetrieveProfileAvatarJob(recipient, url));
|
||||
|
||||
// Loki - If the recipient is our master device then we need to go and update our avatar mappings on the public chats
|
||||
if (recipient.isOurMasterDevice()) {
|
||||
if (recipient.isUserMasterDevice()) {
|
||||
ApplicationContext.getInstance(context).updatePublicChatProfilePictureIfNeeded();
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,6 @@ public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
||||
.withExpiration(groupRecipient.getExpireMessages())
|
||||
.build();
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendMessage(0, new SignalServiceAddress(source),
|
||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.fromSerialized(source), false)),
|
||||
message);
|
||||
|
@ -2,16 +2,11 @@ package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionManagementProtocol;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||
@ -54,15 +49,7 @@ public class RefreshPreKeysJob extends BaseJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException {
|
||||
if (TextSecurePreferences.isSignedPreKeyRegistered(context)) {
|
||||
Log.d("Loki", "A signed pre key has already been registered.");
|
||||
} else {
|
||||
Log.d("Loki", "Registering a new signed pre key.");
|
||||
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context);
|
||||
PreKeyUtil.generateSignedPreKey(context, identityKey, true);
|
||||
TextSecurePreferences.setSignedPreKeyRegistered(context, true);
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new CleanPreKeysJob());
|
||||
}
|
||||
SessionManagementProtocol.refreshSignedPreKey(context);
|
||||
}
|
||||
|
||||
/* Loki - Original code
|
||||
|
@ -79,7 +79,6 @@ public class RequestGroupInfoJob extends BaseJob implements InjectableType {
|
||||
.withTimestamp(System.currentTimeMillis())
|
||||
.build();
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendMessage(0, new SignalServiceAddress(source),
|
||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.fromExternal(context, source), false)),
|
||||
message);
|
||||
|
@ -77,7 +77,7 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException, InvalidKeyException {
|
||||
// Loki - Disable retrieve profile
|
||||
// Loki - Do nothing
|
||||
/*
|
||||
try {
|
||||
if (recipient.isGroupRecipient()) handleGroupRecipient(recipient);
|
||||
|
@ -56,10 +56,12 @@ public class RotateCertificateJob extends BaseJob implements InjectableType {
|
||||
@Override
|
||||
public void onRun() throws IOException {
|
||||
// Loki - Do nothing
|
||||
// synchronized (RotateCertificateJob.class) {
|
||||
// byte[] certificate = accountManager.getSenderCertificate();
|
||||
// TextSecurePreferences.setUnidentifiedAccessCertificate(context, certificate);
|
||||
// }
|
||||
/*
|
||||
synchronized (RotateCertificateJob.class) {
|
||||
byte[] certificate = accountManager.getSenderCertificate();
|
||||
TextSecurePreferences.setUnidentifiedAccessCertificate(context, certificate);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,8 +83,7 @@ public class SendDeliveryReceiptJob extends BaseJob implements InjectableType {
|
||||
Collections.singletonList(messageId),
|
||||
timestamp);
|
||||
|
||||
// TODO: Message ID
|
||||
messageSender.sendReceipt(0, remoteAddress,
|
||||
messageSender.sendReceipt(remoteAddress,
|
||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.fromSerialized(address), false)),
|
||||
receiptMessage);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@ -20,8 +20,6 @@ import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage.Action;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus;
|
||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -99,16 +97,8 @@ public class TypingSendJob extends BaseJob implements InjectableType {
|
||||
List<Optional<UnidentifiedAccessPair>> unidentifiedAccess = Stream.of(recipients).map(r -> UnidentifiedAccessUtil.getAccessFor(context, r)).toList();
|
||||
SignalServiceTypingMessage typingMessage = new SignalServiceTypingMessage(typing ? Action.STARTED : Action.STOPPED, System.currentTimeMillis(), groupId);
|
||||
|
||||
// Loki - Don't send typing indicators in group chats or to ourselves
|
||||
if (recipient.isGroupRecipient()) { return; }
|
||||
|
||||
|
||||
LokiThreadFriendRequestStatus friendRequestStatus = DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadId);
|
||||
if (friendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) { return; }
|
||||
|
||||
boolean isOurDevice = PromiseUtil.get(MultiDeviceUtilities.isOneOfOurDevices(context, recipient.getAddress()), false);
|
||||
if (!isOurDevice) {
|
||||
messageSender.sendTyping(0, addresses, unidentifiedAccess, typingMessage);
|
||||
if (SessionMetaProtocol.shouldSendTypingIndicator(recipient, context)) {
|
||||
messageSender.sendTyping(addresses, unidentifiedAccess, typingMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,8 @@ import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
||||
import com.bumptech.glide.request.FutureTarget;
|
||||
|
||||
import com.bumptech.glide.util.ByteBufferUtil;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||
@ -73,7 +71,7 @@ public class LinkPreviewRepository implements InjectableType {
|
||||
ApplicationContext.getInstance(context).injectDependencies(this);
|
||||
}
|
||||
|
||||
public RequestController getLinkPreview(@NonNull Context context, @NonNull String url, @NonNull Callback<Optional<LinkPreview>> callback) {
|
||||
RequestController getLinkPreview(@NonNull Context context, @NonNull String url, @NonNull Callback<Optional<LinkPreview>> callback) {
|
||||
CompositeRequestController compositeController = new CompositeRequestController();
|
||||
|
||||
if (!LinkPreviewUtil.isWhitelistedLinkUrl(url)) {
|
||||
@ -152,28 +150,6 @@ public class LinkPreviewRepository implements InjectableType {
|
||||
return new CallRequestController(call);
|
||||
}
|
||||
|
||||
public @NonNull RequestController fetchGIF(@NonNull Context context, @NonNull String url, @NonNull Callback<Optional<Attachment>> callback) {
|
||||
FutureTarget<GifDrawable> future = GlideApp.with(context).asGif().load(new ChunkedImageUrl(url)).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.centerInside().submit(1024, 1024);
|
||||
RequestController controller = () -> future.cancel(false);
|
||||
SignalExecutors.UNBOUNDED.execute(() -> {
|
||||
try {
|
||||
GifDrawable gif = future.get();
|
||||
byte[] bytes = ByteBufferUtil.toBytes(gif.getBuffer());
|
||||
Uri uri = BlobProvider.getInstance().forData(bytes).createForSingleSessionInMemory();
|
||||
Optional<Attachment> thumbnail = Optional.of(new UriAttachment(uri, uri, MediaUtil.IMAGE_GIF, AttachmentDatabase.TRANSFER_PROGRESS_DONE,
|
||||
bytes.length, gif.getIntrinsicWidth(), gif.getIntrinsicHeight(), null, null, false, false, null, null));
|
||||
callback.onComplete(thumbnail);
|
||||
} catch (CancellationException | ExecutionException | InterruptedException e) {
|
||||
controller.cancel();
|
||||
callback.onComplete(Optional.absent());
|
||||
} finally {
|
||||
future.cancel(false);
|
||||
}
|
||||
});
|
||||
return () -> future.cancel(true);
|
||||
}
|
||||
|
||||
private @NonNull RequestController fetchThumbnail(@NonNull Context context, @NonNull String imageUrl, @NonNull Callback<Optional<Attachment>> callback) {
|
||||
FutureTarget<Bitmap> bitmapFuture = GlideApp.with(context).asBitmap()
|
||||
.load(new ChunkedImageUrl(imageUrl))
|
||||
@ -317,7 +293,7 @@ public class LinkPreviewRepository implements InjectableType {
|
||||
}
|
||||
}
|
||||
|
||||
public interface Callback<T> {
|
||||
interface Callback<T> {
|
||||
void onComplete(@NonNull T result);
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,9 @@ import org.thoughtcrime.securesms.conversation.ConversationActivity
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||
import org.thoughtcrime.securesms.loki.getColorWithID
|
||||
import org.thoughtcrime.securesms.loki.dialogs.PNModeBottomSheet
|
||||
import org.thoughtcrime.securesms.loki.getColorWithID
|
||||
import org.thoughtcrime.securesms.loki.protocol.ClosedGroupsProtocol
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.show
|
||||
import org.thoughtcrime.securesms.loki.views.ConversationView
|
||||
@ -41,7 +42,6 @@ import org.thoughtcrime.securesms.loki.views.SeedReminderViewDelegate
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier
|
||||
import org.thoughtcrime.securesms.util.GroupUtil
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import kotlin.math.abs
|
||||
|
||||
@ -272,7 +272,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
||||
val isClosedGroup = recipient.address.isClosedGroup
|
||||
// Send a leave group message if this is an active closed group
|
||||
if (isClosedGroup && DatabaseFactory.getGroupDatabase(activity).isActive(recipient.address.toGroupString())) {
|
||||
if (!GroupUtil.leaveGroup(activity, recipient)) {
|
||||
if (!ClosedGroupsProtocol.leaveGroup(activity, recipient)) {
|
||||
Toast.makeText(activity, "Couldn't leave group", Toast.LENGTH_LONG).show()
|
||||
clearView(activity.recyclerView, viewHolder)
|
||||
return@setPositiveButton
|
||||
|
@ -6,8 +6,8 @@ import org.thoughtcrime.securesms.devicelist.Device
|
||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.LokiDeviceLinkUtilities
|
||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
||||
import java.io.File
|
||||
|
||||
class LinkedDevicesLoader(context: Context) : AsyncLoader<List<Device>>(context) {
|
||||
@ -19,12 +19,12 @@ class LinkedDevicesLoader(context: Context) : AsyncLoader<List<Device>>(context)
|
||||
|
||||
override fun loadInBackground(): List<Device>? {
|
||||
try {
|
||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
val slaveDeviceHexEncodedPublicKeys = LokiDeviceLinkUtilities.getSlaveHexEncodedPublicKeys(userHexEncodedPublicKey).get()
|
||||
return slaveDeviceHexEncodedPublicKeys.map { hexEncodedPublicKey ->
|
||||
val shortID = MnemonicUtilities.getFirst3Words(mnemonicCodec, hexEncodedPublicKey)
|
||||
val name = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(hexEncodedPublicKey)
|
||||
Device(hexEncodedPublicKey, shortID, name)
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
val slaveDevices = MultiDeviceProtocol.shared.getSlaveDevices(userPublicKey)
|
||||
return slaveDevices.map { device ->
|
||||
val shortID = MnemonicUtilities.getFirst3Words(mnemonicCodec, device)
|
||||
val name = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(device)
|
||||
Device(device, shortID, name)
|
||||
}.sortedBy { it.name }
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
|
@ -205,7 +205,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
}
|
||||
// If we got a message from our master device then make sure our mapping stays in sync
|
||||
val recipient = Recipient.from(context, Address.fromSerialized(message.hexEncodedPublicKey), false)
|
||||
if (recipient.isOurMasterDevice && message.profilePicture != null) {
|
||||
if (recipient.isUserMasterDevice && message.profilePicture != null) {
|
||||
val profileKey = message.profilePicture!!.profileKey
|
||||
val url = message.profilePicture!!.url
|
||||
if (recipient.profileKey == null || !MessageDigest.isEqual(recipient.profileKey, profileKey)) {
|
||||
|
@ -11,18 +11,18 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
object ClosedGroupsProtocol {
|
||||
|
||||
fun leaveGroup(context: Context, recipient: Recipient): Boolean {
|
||||
if (!recipient.address.isClosedGroup) { return true }
|
||||
if (!recipient.address.isClosedGroup) { return true }
|
||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient)
|
||||
val message = GroupUtil.createGroupLeaveMessage(context, recipient)
|
||||
if (threadID < 0 || !message.isPresent) { return false }
|
||||
MessageSender.send(context, message.get(), threadID, false, null)
|
||||
// Remove the *master* device from the group
|
||||
val masterHexPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||
val userPublicKey = masterHexPublicKey ?: TextSecurePreferences.getLocalNumber(context)
|
||||
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||
val publicKeyToUse = masterPublicKey ?: TextSecurePreferences.getLocalNumber(context)
|
||||
val groupDatabase = DatabaseFactory.getGroupDatabase(context)
|
||||
val groupID = recipient.address.toGroupString()
|
||||
groupDatabase.setActive(groupID, false)
|
||||
groupDatabase.remove(groupID, Address.fromSerialized(userPublicKey))
|
||||
groupDatabase.remove(groupID, Address.fromSerialized(publicKeyToUse))
|
||||
return true
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package org.thoughtcrime.securesms.loki.protocol
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil
|
||||
import org.thoughtcrime.securesms.jobs.CleanPreKeysJob
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
|
||||
object SessionManagementProtocol {
|
||||
|
||||
@JvmStatic
|
||||
fun refreshSignedPreKey(context: Context) {
|
||||
if (TextSecurePreferences.isSignedPreKeyRegistered(context)) {
|
||||
Log.d("Loki", "Skipping signed pre key refresh; using existing signed pre key.")
|
||||
} else {
|
||||
Log.d("Loki", "Signed pre key refreshed successfully.")
|
||||
val identityKeyPair = IdentityKeyUtil.getIdentityKeyPair(context)
|
||||
PreKeyUtil.generateSignedPreKey(context, identityKeyPair, true)
|
||||
TextSecurePreferences.setSignedPreKeyRegistered(context, true)
|
||||
ApplicationContext.getInstance(context).jobManager.add(CleanPreKeysJob())
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.thoughtcrime.securesms.loki.protocol
|
||||
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus
|
||||
|
||||
object SessionMetaProtocol {
|
||||
|
||||
@JvmStatic
|
||||
fun canUserReplyToNotification(recipient: Recipient, context: Context): Boolean {
|
||||
val isGroup = recipient.isGroupRecipient
|
||||
if (isGroup) { return !recipient.address.isRSSFeed }
|
||||
val linkedDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(recipient.address.serialize())
|
||||
return linkedDevices.any { device ->
|
||||
val recipient = Recipient.from(context, Address.fromSerialized(device), false)
|
||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient)
|
||||
DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID) == LokiThreadFriendRequestStatus.FRIENDS
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun shouldSendReadReceipt(publicKey: String, context: Context): Boolean {
|
||||
val recipient = Recipient.from(context, Address.fromSerialized(publicKey),false)
|
||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient)
|
||||
return DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID) == LokiThreadFriendRequestStatus.FRIENDS
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun shouldSendTypingIndicator(recipient: Recipient, context: Context): Boolean {
|
||||
if (recipient.isGroupRecipient) { return false }
|
||||
val recipient = Recipient.from(context, Address.fromSerialized(recipient.address.serialize()),false)
|
||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient)
|
||||
return DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID) == LokiThreadFriendRequestStatus.FRIENDS
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package org.thoughtcrime.securesms.loki.protocol
|
||||
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
|
||||
object SyncMessagesProtocol {
|
||||
|
||||
@JvmStatic
|
||||
fun shouldSyncReadReceipt(address: Address): Boolean {
|
||||
return !address.isOpenGroup
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
@file:JvmName("NotificationUtilities")
|
||||
package org.thoughtcrime.securesms.notifications
|
||||
package org.thoughtcrime.securesms.loki.utilities
|
||||
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
@ -21,16 +21,18 @@ import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.SendReadReceiptJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SyncMessagesProtocol;
|
||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.contracts.Returns;
|
||||
|
||||
public class MarkReadReceiver extends BroadcastReceiver {
|
||||
|
||||
@ -78,7 +80,8 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
||||
|
||||
for (MarkedMessageInfo messageInfo : markedReadMessages) {
|
||||
scheduleDeletion(context, messageInfo.getExpirationInfo());
|
||||
if (!messageInfo.getSyncMessageId().getAddress().isGroup()) {
|
||||
|
||||
if (SyncMessagesProtocol.shouldSyncReadReceipt(messageInfo.getSyncMessageId().getAddress())) {
|
||||
syncMessageIds.add(messageInfo.getSyncMessageId());
|
||||
}
|
||||
}
|
||||
@ -93,17 +96,13 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
||||
|
||||
for (Address address : addressMap.keySet()) {
|
||||
List<Long> timestamps = Stream.of(addressMap.get(address)).map(SyncMessageId::getTimetamp).toList();
|
||||
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, address.serialize()).success(devices -> {
|
||||
for (Map.Entry<String, Boolean> entry : devices.entrySet()) {
|
||||
String device = entry.getKey();
|
||||
boolean isFriend = entry.getValue();
|
||||
// Loki - This also prevents read receipts from being sent in group chats as they don't maintain a friend request status
|
||||
if (isFriend) {
|
||||
Util.runOnMain(() -> ApplicationContext.getInstance(context).getJobManager().add(new SendReadReceiptJob(Address.fromSerialized(device), timestamps)));
|
||||
}
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
Set<String> linkedDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(address.serialize());
|
||||
for (String device : linkedDevices) {
|
||||
if (!SessionMetaProtocol.shouldSendReadReceipt(device, context)) { continue; }
|
||||
ApplicationContext.getInstance(context)
|
||||
.getJobManager()
|
||||
.add(new SendReadReceiptJob(address, timestamps));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.service.IncomingMessageObserver;
|
||||
@ -75,7 +76,6 @@ import me.leolin.shortcutbadger.ShortcutBadger;
|
||||
import network.loki.messenger.R;
|
||||
import nl.komponents.kovenant.Promise;
|
||||
|
||||
|
||||
/**
|
||||
* Handles posting system notifications for new messages.
|
||||
*
|
||||
@ -320,25 +320,11 @@ public class MessageNotifier {
|
||||
long timestamp = notifications.get(0).getTimestamp();
|
||||
if (timestamp != 0) builder.setWhen(timestamp);
|
||||
|
||||
long threadId = notifications.get(0).getThreadId();
|
||||
long threadID = notifications.get(0).getThreadId();
|
||||
|
||||
ReplyMethod replyMethod = ReplyMethod.forRecipient(context, recipient);
|
||||
|
||||
|
||||
// We can only reply if we are friends with the user or we're messaging a group
|
||||
boolean isGroup = recipient.isGroupRecipient();
|
||||
boolean isRSSFeed = isGroup && recipient.getAddress().isRSSFeed();
|
||||
boolean isFriend = false;
|
||||
if (!isGroup) {
|
||||
isFriend = DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadId) == LokiThreadFriendRequestStatus.FRIENDS;
|
||||
// If we're not friends then we need to check if we're friends with any of the linked devices
|
||||
if (!isFriend) {
|
||||
Promise<Boolean, Exception> promise = PromiseUtil.timeout(MultiDeviceUtilities.isFriendsWithAnyLinkedDevice(context, recipient), 5000);
|
||||
isFriend = PromiseUtil.get(promise, false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean canReply = (isGroup && !isRSSFeed) || isFriend;
|
||||
boolean canReply = SessionMetaProtocol.canUserReplyToNotification(recipient, context);
|
||||
|
||||
PendingIntent quickReplyIntent = canReply ? notificationState.getQuickReplyIntent(context, recipient) : null;
|
||||
PendingIntent remoteReplyIntent = canReply ? notificationState.getRemoteReplyIntent(context, recipient, replyMethod) : null;
|
||||
|
@ -10,6 +10,7 @@ import android.support.v4.app.NotificationCompat;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.utilities.NotificationUtilities;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@ -52,8 +53,7 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
||||
displayName = NotificationUtilities.getOpenGroupDisplayName(recipient, threadRecipient, context);
|
||||
}
|
||||
if (privacy.isDisplayContact()) {
|
||||
setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s,
|
||||
displayName));
|
||||
setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s, displayName));
|
||||
}
|
||||
|
||||
if (recipient.getNotificationChannel() != null) {
|
||||
|
@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.utilities.NotificationUtilities;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
@ -170,24 +171,20 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
String actionName = context.getString(R.string.MessageNotifier_reply);
|
||||
String label = context.getString(replyMethodLongDescription(replyMethod));
|
||||
|
||||
Action replyAction = new Action(R.drawable.ic_reply_white_36dp,
|
||||
actionName,
|
||||
quickReplyIntent);
|
||||
Action replyAction = new Action(R.drawable.ic_reply_white_36dp, actionName, quickReplyIntent);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
replyAction = new Action.Builder(R.drawable.ic_reply_white_36dp,
|
||||
actionName,
|
||||
wearableReplyIntent)
|
||||
.addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY)
|
||||
.setLabel(label).build())
|
||||
.addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY).setLabel(label).build())
|
||||
.build();
|
||||
}
|
||||
|
||||
Action wearableReplyAction = new Action.Builder(R.drawable.ic_reply,
|
||||
actionName,
|
||||
wearableReplyIntent)
|
||||
.addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY)
|
||||
.setLabel(label).build())
|
||||
.addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY).setLabel(label).build())
|
||||
.build();
|
||||
|
||||
|
||||
@ -244,12 +241,12 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
Bitmap recipientPhotoBitmap = BitmapUtil.createFromDrawable(drawable, largeIconTargetSize, largeIconTargetSize);
|
||||
|
||||
if (recipientPhotoBitmap != null) {
|
||||
setLargeIcon(getCircleBitmap(recipientPhotoBitmap));
|
||||
setLargeIcon(getCircularBitmap(recipientPhotoBitmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap getCircleBitmap(Bitmap bitmap) {
|
||||
private Bitmap getCircularBitmap(Bitmap bitmap) {
|
||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
||||
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
final Canvas canvas = new Canvas(output);
|
||||
|
@ -34,8 +34,8 @@ import network.loki.messenger.R;
|
||||
|
||||
public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment implements InjectableType {
|
||||
|
||||
// private static final String PREFERENCE_CATEGORY_BLOCKED = "preference_category_blocked";
|
||||
// private static final String PREFERENCE_UNIDENTIFIED_LEARN_MORE = "pref_unidentified_learn_more";
|
||||
// private static final String PREFERENCE_CATEGORY_BLOCKED = "preference_category_blocked";
|
||||
// private static final String PREFERENCE_UNIDENTIFIED_LEARN_MORE = "pref_unidentified_learn_more";
|
||||
|
||||
private CheckBoxPreference disablePassphrase;
|
||||
|
||||
@ -54,7 +54,7 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
||||
|
||||
disablePassphrase = (CheckBoxPreference) this.findPreference("pref_enable_passphrase_temporary");
|
||||
|
||||
// this.findPreference(TextSecurePreferences.REGISTRATION_LOCK_PREF).setOnPreferenceClickListener(new AccountLockClickListener());
|
||||
// this.findPreference(TextSecurePreferences.REGISTRATION_LOCK_PREF).setOnPreferenceClickListener(new AccountLockClickListener());
|
||||
this.findPreference(TextSecurePreferences.SCREEN_LOCK).setOnPreferenceChangeListener(new ScreenLockListener());
|
||||
this.findPreference(TextSecurePreferences.SCREEN_LOCK_TIMEOUT).setOnPreferenceClickListener(new ScreenLockTimeoutListener());
|
||||
|
||||
@ -63,10 +63,10 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
||||
this.findPreference(TextSecurePreferences.READ_RECEIPTS_PREF).setOnPreferenceChangeListener(new ReadReceiptToggleListener());
|
||||
this.findPreference(TextSecurePreferences.TYPING_INDICATORS).setOnPreferenceChangeListener(new TypingIndicatorsToggleListener());
|
||||
this.findPreference(TextSecurePreferences.LINK_PREVIEWS).setOnPreferenceChangeListener(new LinkPreviewToggleListener());
|
||||
// this.findPreference(PREFERENCE_CATEGORY_BLOCKED).setOnPreferenceClickListener(new BlockedContactsClickListener());
|
||||
// this.findPreference(TextSecurePreferences.SHOW_UNIDENTIFIED_DELIVERY_INDICATORS).setOnPreferenceChangeListener(new ShowUnidentifiedDeliveryIndicatorsChangedListener());
|
||||
// this.findPreference(TextSecurePreferences.UNIVERSAL_UNIDENTIFIED_ACCESS).setOnPreferenceChangeListener(new UniversalUnidentifiedAccessChangedListener());
|
||||
// this.findPreference(PREFERENCE_UNIDENTIFIED_LEARN_MORE).setOnPreferenceClickListener(new UnidentifiedLearnMoreClickListener());
|
||||
// this.findPreference(PREFERENCE_CATEGORY_BLOCKED).setOnPreferenceClickListener(new BlockedContactsClickListener());
|
||||
// this.findPreference(TextSecurePreferences.SHOW_UNIDENTIFIED_DELIVERY_INDICATORS).setOnPreferenceChangeListener(new ShowUnidentifiedDeliveryIndicatorsChangedListener());
|
||||
// this.findPreference(TextSecurePreferences.UNIVERSAL_UNIDENTIFIED_ACCESS).setOnPreferenceChangeListener(new UniversalUnidentifiedAccessChangedListener());
|
||||
// this.findPreference(PREFERENCE_UNIDENTIFIED_LEARN_MORE).setOnPreferenceClickListener(new UnidentifiedLearnMoreClickListener());
|
||||
disablePassphrase.setOnPreferenceChangeListener(new DisablePassphraseClickListener());
|
||||
|
||||
initializeVisibility();
|
||||
|
@ -127,9 +127,9 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
}
|
||||
|
||||
initializeRingtoneSummary(findPreference(TextSecurePreferences.RINGTONE_PREF));
|
||||
// initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||
// initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||
initializeMessageVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.VIBRATE_PREF));
|
||||
// initializeCallVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.CALL_VIBRATE_PREF));
|
||||
// initializeCallVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.CALL_VIBRATE_PREF));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,7 +161,7 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
TextSecurePreferences.setCallNotificationRingtone(getContext(), uri != null ? uri.toString() : Uri.EMPTY.toString());
|
||||
}
|
||||
|
||||
// initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||
// initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.SecurityEvent;
|
||||
import org.thoughtcrime.securesms.loki.FriendRequestHandler;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
@ -23,13 +22,6 @@ public class MessageSenderEventListener implements SignalServiceMessageSender.Ev
|
||||
SecurityEvent.broadcastSecurityUpdateEvent(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSyncEvent(long messageID, long timestamp, byte[] message, int ttl) {
|
||||
if (messageID >= 0 && timestamp > 0 && message != null && ttl > 0) {
|
||||
MessageSender.sendSyncMessageToOurDevices(context, messageID, timestamp, message, ttl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFriendRequestSending(long messageID, long threadID) {
|
||||
FriendRequestHandler.updateFriendRequestState(context, FriendRequestHandler.ActionType.Sending, messageID, threadID);
|
||||
}
|
||||
|
@ -277,9 +277,9 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return isLocalNumber;
|
||||
}
|
||||
|
||||
public boolean isOurMasterDevice() {
|
||||
String ourMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||
return ourMasterDevice != null && ourMasterDevice.equals(getAddress().serialize());
|
||||
public boolean isUserMasterDevice() {
|
||||
String userMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||
return userMasterDevice != null && userMasterDevice.equals(getAddress().serialize());
|
||||
}
|
||||
|
||||
public synchronized @Nullable Uri getContactUri() {
|
||||
@ -467,11 +467,11 @@ public class Recipient implements RecipientModifiedListener {
|
||||
if (isResolving()) return new TransparentContactPhoto();
|
||||
else if (isGroupRecipient()) return new GeneratedContactPhoto(name, R.drawable.ic_profile_default);
|
||||
else {
|
||||
String currentUser = TextSecurePreferences.getLocalNumber(context);
|
||||
String recipientAddress = address.serialize();
|
||||
String primaryAddress = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||
String profileAddress = (recipientAddress.equalsIgnoreCase(currentUser) && primaryAddress != null) ? primaryAddress : recipientAddress;
|
||||
return new JazzIdenticonContactPhoto(profileAddress);
|
||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||
String publicKey = address.serialize();
|
||||
String masterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||
String publicKeyToUse = (publicKey.equalsIgnoreCase(userPublicKey) && masterDevice != null) ? masterDevice : publicKey;
|
||||
return new JazzIdenticonContactPhoto(publicKeyToUse);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ public class WelcomeActivity extends BaseActionBarActivity {
|
||||
builder.setMessage(R.string.dialog_device_unlink_message);
|
||||
builder.setPositiveButton(R.string.ok, null);
|
||||
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
TextSecurePreferences.setNeedDatabaseResetFromUnlink(getBaseContext(), false);
|
||||
@ -57,7 +58,7 @@ public class WelcomeActivity extends BaseActionBarActivity {
|
||||
.ifNecessary()
|
||||
.withRationaleDialog(getString(R.string.activity_landing_permission_dialog_message), R.drawable.ic_folder_white_48dp)
|
||||
.onAnyResult(() -> {
|
||||
// TextSecurePreferences.setHasSeenWelcomeScreen(WelcomeActivity.this, true);
|
||||
// TextSecurePreferences.setHasSeenWelcomeScreen(WelcomeActivity.this, true);
|
||||
|
||||
Intent nextIntent = getIntent().getParcelableExtra("next_intent");
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class KeyCachingService extends Service {
|
||||
if (masterSecret == null && (TextSecurePreferences.isPasswordDisabled(context) && !TextSecurePreferences.isScreenLockEnabled(context))) {
|
||||
try {
|
||||
// Loki - Cache the secret.
|
||||
// Don't know if this will affect any other signal code :( but it makes it so we're not wasting time re-fetching the same secret from the database
|
||||
// TODO: Don't know if this will affect any other Signal code but it makes it so we're not wasting time re-fetching the same secret from the database
|
||||
if (cachedSecret == null || cacheTime < System.currentTimeMillis()) {
|
||||
cachedSecret = MasterSecretUtil.getMasterSecret(context, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
||||
cacheTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5);
|
||||
|
@ -384,7 +384,7 @@ public class WebRtcCallService extends Service implements InjectableType,
|
||||
if (Permissions.hasAny(WebRtcCallService.this, Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)) {
|
||||
isSystemContact = ContactAccessor.getInstance().isSystemContact(WebRtcCallService.this, recipient.getAddress().serialize());
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
boolean isAlwaysTurn = TextSecurePreferences.isTurnOnly(WebRtcCallService.this);
|
||||
|
||||
@ -1011,7 +1011,7 @@ public class WebRtcCallService extends Service implements InjectableType,
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
// TODO: Message ID
|
||||
messageSender.sendCallMessage(0, new SignalServiceAddress(recipient.getAddress().toPhoneString()),
|
||||
messageSender.sendCallMessage(new SignalServiceAddress(recipient.getAddress().toPhoneString()),
|
||||
UnidentifiedAccessUtil.getAccessFor(WebRtcCallService.this, recipient),
|
||||
callMessage);
|
||||
return true;
|
||||
|
@ -15,7 +15,6 @@ import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@ -111,17 +110,9 @@ public class AttachmentUtil {
|
||||
try (Cursor messageCursor = DatabaseFactory.getMmsDatabase(context).getMessage(attachment.getMmsId())) {
|
||||
message = DatabaseFactory.getMmsDatabase(context).readerFor(messageCursor).getNext();
|
||||
}
|
||||
|
||||
if (message == null) { return true; }
|
||||
|
||||
// TODO: Fix this so we can detect whether attachment is from a public group or not
|
||||
// We don't allow attachments to be sent unless we're friends with someone or the attachment is sent
|
||||
// in a group context. Auto-downloading attachments is therefore fine.
|
||||
return false;
|
||||
|
||||
/*
|
||||
// check to see if we're friends with the person
|
||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdIfExistsFor(message.getRecipient());
|
||||
boolean isFriend = threadId >= 0 && DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadId) == LokiThreadFriendRequestStatus.FRIENDS;
|
||||
return (!isFriend && !message.isOutgoing() && !Util.isOwnNumber(context, message.getRecipient().getAddress()));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user