Java Code Examples for org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer#getWidth()

The following examples show how to use org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer#getWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonAttachment.java    From signald with GNU General Public License v3.0 5 votes vote down vote up
JsonAttachment(SignalServiceAttachment attachment, String username) throws IOException, NoSuchAccountException {
    this.contentType = attachment.getContentType();
    final SignalServiceAttachmentPointer pointer = attachment.asPointer();
    if (attachment.isPointer()) {
        this.id = pointer.getId();
        this.key = Base64.encodeBytes(pointer.getKey());

        if (pointer.getSize().isPresent()) {
            this.size = pointer.getSize().get();
        }

        if(pointer.getPreview().isPresent()) {
            this.preview = Base64.encodeBytes(pointer.getPreview().get());
        }

        if(pointer.getDigest().isPresent()) {
            this.digest = Base64.encodeBytes(pointer.getDigest().get());
        }

        this.voiceNote = pointer.getVoiceNote();

        this.width = pointer.getWidth();
        this.height = pointer.getHeight();

        if(pointer.getCaption().isPresent()) {
            this.caption = pointer.getCaption().get();
        }

        if(pointer.getBlurHash().isPresent()) {
            this.blurhash = pointer.getBlurHash().get();
        }

        File file = Manager.get(username).getAttachmentFile(pointer.getId());
        if(file.exists()) {
            this.storedFilename = file.toString();
        }
    }
}
 
Example 2
Source File: SignalServiceMessageSender.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
private AttachmentPointer createAttachmentPointer(SignalServiceAttachmentPointer attachment) {
  AttachmentPointer.Builder builder = AttachmentPointer.newBuilder()
                                                       .setContentType(attachment.getContentType())
                                                       .setId(attachment.getId())
                                                       .setKey(ByteString.copyFrom(attachment.getKey()))
                                                       .setDigest(ByteString.copyFrom(attachment.getDigest().get()))
                                                       .setSize(attachment.getSize().get());

  if (attachment.getFileName().isPresent()) {
    builder.setFileName(attachment.getFileName().get());
  }

  if (attachment.getPreview().isPresent()) {
    builder.setThumbnail(ByteString.copyFrom(attachment.getPreview().get()));
  }

  if (attachment.getWidth() > 0) {
    builder.setWidth(attachment.getWidth());
  }

  if (attachment.getHeight() > 0) {
    builder.setHeight(attachment.getHeight());
  }

  if (attachment.getVoiceNote()) {
    builder.setFlags(AttachmentPointer.Flags.VOICE_MESSAGE_VALUE);
  }

  if (attachment.getCaption().isPresent()) {
    builder.setCaption(attachment.getCaption().get());
  }

  if (attachment.getBlurHash().isPresent()) {
    builder.setBlurHash(attachment.getBlurHash().get());
  }

  return builder.build();
}
 
Example 3
Source File: SignalServiceMessageSender.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private AttachmentPointer createAttachmentPointer(SignalServiceAttachmentPointer attachment) {
  AttachmentPointer.Builder builder = AttachmentPointer.newBuilder()
                                                       .setCdnNumber(attachment.getCdnNumber())
                                                       .setContentType(attachment.getContentType())
                                                       .setKey(ByteString.copyFrom(attachment.getKey()))
                                                       .setDigest(ByteString.copyFrom(attachment.getDigest().get()))
                                                       .setSize(attachment.getSize().get())
                                                       .setUploadTimestamp(attachment.getUploadTimestamp());

  if (attachment.getRemoteId().getV2().isPresent()) {
    builder.setCdnId(attachment.getRemoteId().getV2().get());
  }

  if (attachment.getRemoteId().getV3().isPresent()) {
    builder.setCdnKey(attachment.getRemoteId().getV3().get());
  }

  if (attachment.getFileName().isPresent()) {
    builder.setFileName(attachment.getFileName().get());
  }

  if (attachment.getPreview().isPresent()) {
    builder.setThumbnail(ByteString.copyFrom(attachment.getPreview().get()));
  }

  if (attachment.getWidth() > 0) {
    builder.setWidth(attachment.getWidth());
  }

  if (attachment.getHeight() > 0) {
    builder.setHeight(attachment.getHeight());
  }

  if (attachment.getVoiceNote()) {
    builder.setFlags(AttachmentPointer.Flags.VOICE_MESSAGE_VALUE);
  }

  if (attachment.getCaption().isPresent()) {
    builder.setCaption(attachment.getCaption().get());
  }

  if (attachment.getBlurHash().isPresent()) {
    builder.setBlurHash(attachment.getBlurHash().get());
  }

  return builder.build();
}