diff --git a/app/src/main/java/org/thoughtcrime/securesms/contactshare/ContactModelMapper.java b/app/src/main/java/org/thoughtcrime/securesms/contactshare/ContactModelMapper.java index 7db10dcfdf..eeb88a02bf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/contactshare/ContactModelMapper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/contactshare/ContactModelMapper.java @@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.contactshare; import androidx.annotation.NonNull; import org.session.libsession.messaging.sending_receiving.attachments.Attachment; -import org.thoughtcrime.securesms.attachments.PointerAttachment; +import org.session.libsession.messaging.sending_receiving.attachments.PointerAttachment; import org.session.libsignal.libsignal.util.guava.Optional; import org.session.libsignal.service.api.messages.shared.SharedContact; @@ -11,7 +11,8 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import static org.thoughtcrime.securesms.contactshare.Contact.*; +import org.session.libsession.messaging.sending_receiving.contacts.Contact; +import static org.session.libsession.messaging.sending_receiving.contacts.Contact.*; public class ContactModelMapper { diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 2f41a71468..7a2374e53b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -146,19 +146,21 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context, } override fun getOpenGroupPublicKey(server: String): String? { - TODO("Not yet implemented") + return DatabaseFactory.getLokiAPIDatabase(context).getOpenGroupPublicKey(server) } override fun setOpenGroupPublicKey(server: String, newValue: String) { - TODO("Not yet implemented") + DatabaseFactory.getLokiAPIDatabase(context).setOpenGroupPublicKey(server, newValue) } override fun setOpenGroupDisplayName(publicKey: String, channel: Long, server: String, displayName: String) { - TODO("Not yet implemented") + val groupID = "$server.$channel" + DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(groupID, publicKey, displayName) } override fun getOpenGroupDisplayName(publicKey: String, channel: Long, server: String): String? { - TODO("Not yet implemented") + val groupID = "$server.$channel" + return DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(groupID, publicKey) } override fun getLastMessageServerID(group: Long, server: String): Long? { diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 7a93709098..fadf75ff4b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -27,17 +27,24 @@ import org.session.libsignal.metadata.ProtocolUntrustedIdentityException; import org.session.libsignal.metadata.SelfSendException; import org.session.libsignal.service.loki.api.crypto.SessionProtocol; import org.thoughtcrime.securesms.ApplicationContext; + +import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview; import org.session.libsession.messaging.sending_receiving.attachments.Attachment; -import org.thoughtcrime.securesms.attachments.DatabaseAttachment; -import org.thoughtcrime.securesms.attachments.PointerAttachment; -import org.thoughtcrime.securesms.attachments.UriAttachment; -import org.thoughtcrime.securesms.contactshare.Contact; +import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment; +import org.session.libsession.messaging.sending_receiving.attachments.PointerAttachment; +import org.session.libsession.messaging.sending_receiving.attachments.UriAttachment; +import org.session.libsession.messaging.sending_receiving.contacts.Contact; +import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel; +import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator; +import org.session.libsession.messaging.threads.Address; +import org.session.libsession.messaging.threads.recipients.Recipient; +import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier; + import org.thoughtcrime.securesms.contactshare.ContactModelMapper; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; import org.thoughtcrime.securesms.crypto.SecurityEvent; import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil; import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl; -import org.session.libsession.messaging.threads.Address; import org.thoughtcrime.securesms.database.AttachmentDatabase; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.GroupDatabase; @@ -60,7 +67,6 @@ import org.thoughtcrime.securesms.jobmanager.Data; import org.thoughtcrime.securesms.jobmanager.Job; import org.thoughtcrime.securesms.jobmanager.JobManager; import org.thoughtcrime.securesms.linkpreview.Link; -import org.thoughtcrime.securesms.linkpreview.LinkPreview; import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil; import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.loki.activities.HomeActivity; @@ -80,19 +86,15 @@ import org.thoughtcrime.securesms.mms.MmsException; import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage; -import org.thoughtcrime.securesms.mms.QuoteModel; import org.thoughtcrime.securesms.mms.SlideDeck; import org.thoughtcrime.securesms.mms.StickerSlide; -import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.NotificationChannels; -import org.session.libsession.messaging.threads.recipients.Recipient; import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage; import org.thoughtcrime.securesms.sms.IncomingEndSessionMessage; import org.thoughtcrime.securesms.sms.IncomingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage; import org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage; -import org.thoughtcrime.securesms.stickers.StickerLocator; import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.Hex; import org.thoughtcrime.securesms.util.MediaUtil; @@ -111,7 +113,6 @@ import org.session.libsignal.service.api.messages.SignalServiceReceiptMessage; import org.session.libsignal.service.api.messages.SignalServiceTypingMessage; import org.session.libsignal.service.api.messages.multidevice.SentTranscriptMessage; import org.session.libsignal.service.api.messages.multidevice.StickerPackOperationMessage; -import org.session.libsignal.service.api.messages.multidevice.VerifiedMessage; import org.session.libsignal.service.api.messages.shared.SharedContact; import org.session.libsignal.service.api.push.SignalServiceAddress; import org.session.libsignal.service.loki.api.fileserver.FileServerAPI; @@ -1145,7 +1146,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { author, quote.get().getText(), true, - PointerAttachment.forPointers(quote.get().getAttachments()))); + PointerAttachment.forPointersOfDataMessage(quote.get().getAttachments()))); } private Optional getStickerAttachment(Optional sticker) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java b/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java index 49d6899d15..ab724a301c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java @@ -5,6 +5,7 @@ import org.session.libsession.messaging.sending_receiving.attachments.PointerAtt import org.session.libsession.messaging.sending_receiving.contacts.Contact; import org.session.libsession.messaging.threads.Address; import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview; +import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel; import org.session.libsession.utilities.GroupUtil; import org.session.libsignal.libsignal.util.guava.Optional; import org.session.libsignal.service.api.messages.SignalServiceAttachment; diff --git a/libsession/build.gradle b/libsession/build.gradle index e7ac959acd..e20997fdc0 100644 --- a/libsession/build.gradle +++ b/libsession/build.gradle @@ -48,8 +48,6 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' implementation 'com.github.bumptech.glide:glide:4.11.0' - annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' - kapt 'com.github.bumptech.glide:compiler:4.11.0' implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation 'com.annimon:stream:1.1.8' implementation 'com.makeramen:roundedimageview:2.1.0' diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/PointerAttachment.java b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/PointerAttachment.java index d8aa41253c..bbfd6da00b 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/PointerAttachment.java +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/PointerAttachment.java @@ -54,6 +54,22 @@ public class PointerAttachment extends Attachment { return results; } + public static List forPointersOfDataMessage(List pointers) { + List results = new LinkedList<>(); + + if (pointers != null) { + for (SignalServiceDataMessage.Quote.QuotedAttachment pointer : pointers) { + Optional result = forPointer(pointer); + + if (result.isPresent()) { + results.add(result.get()); + } + } + } + + return results; + } + public static List forPointers(List pointers) { List results = new LinkedList<>(); @@ -141,4 +157,24 @@ public class PointerAttachment extends Attachment { null, thumbnail != null ? thumbnail.getUrl() : "")); } + + public static Optional forPointer(SignalServiceDataMessage.Quote.QuotedAttachment pointer) { + SignalServiceAttachment thumbnail = pointer.getThumbnail(); + + return Optional.of(new PointerAttachment(pointer.getContentType(), + AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING.getValue(), + thumbnail != null ? thumbnail.asPointer().getSize().or(0) : 0, + pointer.getFileName(), + String.valueOf(thumbnail != null ? thumbnail.asPointer().getId() : 0), + thumbnail != null && thumbnail.asPointer().getKey() != null ? Base64.encodeBytes(thumbnail.asPointer().getKey()) : null, + null, + thumbnail != null ? thumbnail.asPointer().getDigest().orNull() : null, + null, + false, + thumbnail != null ? thumbnail.asPointer().getWidth() : 0, + thumbnail != null ? thumbnail.asPointer().getHeight() : 0, + thumbnail != null ? thumbnail.asPointer().getCaption().orNull() : null, + null, + thumbnail != null ? thumbnail.asPointer().getUrl() : "")); + } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/contacts/Contact.java b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/contacts/Contact.java index 176d08d5c2..4404fc2586 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/contacts/Contact.java +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/contacts/Contact.java @@ -160,12 +160,12 @@ public class Contact implements Parcelable { @JsonProperty private final String middleName; - Name(@JsonProperty("displayName") @Nullable String displayName, - @JsonProperty("givenName") @Nullable String givenName, - @JsonProperty("familyName") @Nullable String familyName, - @JsonProperty("prefix") @Nullable String prefix, - @JsonProperty("suffix") @Nullable String suffix, - @JsonProperty("middleName") @Nullable String middleName) + public Name(@JsonProperty("displayName") @Nullable String displayName, + @JsonProperty("givenName") @Nullable String givenName, + @JsonProperty("familyName") @Nullable String familyName, + @JsonProperty("prefix") @Nullable String prefix, + @JsonProperty("suffix") @Nullable String suffix, + @JsonProperty("middleName") @Nullable String middleName) { this.displayName = displayName; this.givenName = givenName; @@ -254,9 +254,9 @@ public class Contact implements Parcelable { @JsonIgnore private boolean selected; - Phone(@JsonProperty("number") @NonNull String number, - @JsonProperty("type") @NonNull Type type, - @JsonProperty("label") @Nullable String label) + public Phone(@JsonProperty("number") @NonNull String number, + @JsonProperty("type") @NonNull Type type, + @JsonProperty("label") @Nullable String label) { this.number = number; this.type = type; @@ -333,9 +333,9 @@ public class Contact implements Parcelable { @JsonIgnore private boolean selected; - Email(@JsonProperty("email") @NonNull String email, - @JsonProperty("type") @NonNull Type type, - @JsonProperty("label") @Nullable String label) + public Email(@JsonProperty("email") @NonNull String email, + @JsonProperty("type") @NonNull Type type, + @JsonProperty("label") @Nullable String label) { this.email = email; this.type = type; @@ -430,15 +430,15 @@ public class Contact implements Parcelable { @JsonIgnore private boolean selected; - PostalAddress(@JsonProperty("type") @NonNull Type type, - @JsonProperty("label") @Nullable String label, - @JsonProperty("street") @Nullable String street, - @JsonProperty("poBox") @Nullable String poBox, - @JsonProperty("neighborhood") @Nullable String neighborhood, - @JsonProperty("city") @Nullable String city, - @JsonProperty("region") @Nullable String region, - @JsonProperty("postalCode") @Nullable String postalCode, - @JsonProperty("country") @Nullable String country) + public PostalAddress(@JsonProperty("type") @NonNull Type type, + @JsonProperty("label") @Nullable String label, + @JsonProperty("street") @Nullable String street, + @JsonProperty("poBox") @Nullable String poBox, + @JsonProperty("neighborhood") @Nullable String neighborhood, + @JsonProperty("city") @Nullable String city, + @JsonProperty("region") @Nullable String region, + @JsonProperty("postalCode") @Nullable String postalCode, + @JsonProperty("country") @Nullable String country) { this.type = type; this.label = label;