use of org.thoughtcrime.securesms.mms.ImageSlide in project Signal-Android by signalapp.
the class ConversationParentFragment method sendKeyboardImage.
private void sendKeyboardImage(@NonNull Uri uri, @NonNull String contentType, @Nullable KeyboardImageDetails details) {
if (details == null || !details.hasTransparency) {
setMedia(uri, Objects.requireNonNull(MediaType.from(contentType)));
return;
}
long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
boolean initiating = threadId == -1;
SlideDeck slideDeck = new SlideDeck();
if (MediaUtil.isGif(contentType)) {
slideDeck.addSlide(new GifSlide(requireContext(), uri, 0, details.width, details.height, details.hasTransparency, null));
} else if (MediaUtil.isImageType(contentType)) {
slideDeck.addSlide(new ImageSlide(requireContext(), uri, contentType, 0, details.width, details.height, details.hasTransparency, null, null));
} else {
throw new AssertionError("Only images are supported!");
}
sendMediaMessage(recipient.getId(), isSmsForced(), "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), composeText.getMentions(), expiresIn, false, subscriptionId, initiating, false, null);
}
use of org.thoughtcrime.securesms.mms.ImageSlide in project Signal-Android by WhisperSystems.
the class ConversationParentFragment method onActivityResult.
@Override
public void onActivityResult(final int reqCode, int resultCode, Intent data) {
Log.i(TAG, "onActivityResult called: " + reqCode + ", " + resultCode + " , " + data);
super.onActivityResult(reqCode, resultCode, data);
if ((data == null && reqCode != TAKE_PHOTO && reqCode != SMS_DEFAULT) || (resultCode != Activity.RESULT_OK && reqCode != SMS_DEFAULT)) {
updateLinkPreviewState();
SignalStore.settings().setDefaultSms(Util.isDefaultSmsProvider(requireContext()));
return;
}
switch(reqCode) {
case PICK_DOCUMENT:
setMedia(data.getData(), MediaType.DOCUMENT);
break;
case PICK_AUDIO:
setMedia(data.getData(), MediaType.AUDIO);
break;
case PICK_CONTACT:
if (isSecureText && !isSmsForced()) {
openContactShareEditor(data.getData());
} else {
addAttachmentContactInfo(data.getData());
}
break;
case GET_CONTACT_DETAILS:
sendSharedContact(data.getParcelableArrayListExtra(ContactShareEditActivity.KEY_CONTACTS));
break;
case GROUP_EDIT:
Recipient recipientSnapshot = recipient.get();
onRecipientChanged(recipientSnapshot);
titleView.setTitle(glideRequests, recipientSnapshot);
NotificationChannels.updateContactChannelName(requireContext(), recipientSnapshot);
setBlockedUserState(recipientSnapshot, isSecureText, isDefaultSms);
invalidateOptionsMenu();
break;
case TAKE_PHOTO:
handleImageFromDeviceCameraApp();
break;
case ADD_CONTACT:
SimpleTask.run(() -> {
try {
DirectoryHelper.refreshDirectoryFor(requireContext(), recipient.get(), false);
} catch (IOException e) {
Log.w(TAG, "Failed to refresh user after adding to contacts.");
}
return null;
}, nothing -> onRecipientChanged(recipient.get()));
break;
case PICK_LOCATION:
SignalPlace place = new SignalPlace(PlacePickerActivity.addressFromData(data));
attachmentManager.setLocation(place, getCurrentMediaConstraints());
break;
case PICK_GIF:
onGifSelectSuccess(data.getData(), data.getIntExtra(GiphyActivity.EXTRA_WIDTH, 0), data.getIntExtra(GiphyActivity.EXTRA_HEIGHT, 0));
break;
case SMS_DEFAULT:
initializeSecurity(isSecureText, isDefaultSms);
break;
case MEDIA_SENDER:
MediaSendActivityResult result = MediaSendActivityResult.fromData(data);
if (!Objects.equals(result.getRecipientId(), recipient.getId())) {
Log.w(TAG, "Result's recipientId did not match ours! Result: " + result.getRecipientId() + ", Activity: " + recipient.getId());
Toast.makeText(requireContext(), R.string.ConversationActivity_error_sending_media, Toast.LENGTH_SHORT).show();
return;
}
sendButton.setTransport(result.getTransport());
if (result.isPushPreUpload()) {
sendMediaMessage(result);
return;
}
long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
boolean initiating = threadId == -1;
QuoteModel quote = result.isViewOnce() ? null : inputPanel.getQuote().orNull();
SlideDeck slideDeck = new SlideDeck();
List<Mention> mentions = new ArrayList<>(result.getMentions());
for (Media mediaItem : result.getNonUploadedMedia()) {
if (MediaUtil.isVideoType(mediaItem.getMimeType())) {
slideDeck.addSlide(new VideoSlide(requireContext(), mediaItem.getUri(), mediaItem.getSize(), mediaItem.isVideoGif(), mediaItem.getWidth(), mediaItem.getHeight(), mediaItem.getCaption().orNull(), mediaItem.getTransformProperties().orNull()));
} else if (MediaUtil.isGif(mediaItem.getMimeType())) {
slideDeck.addSlide(new GifSlide(requireContext(), mediaItem.getUri(), mediaItem.getSize(), mediaItem.getWidth(), mediaItem.getHeight(), mediaItem.isBorderless(), mediaItem.getCaption().orNull()));
} else if (MediaUtil.isImageType(mediaItem.getMimeType())) {
slideDeck.addSlide(new ImageSlide(requireContext(), mediaItem.getUri(), mediaItem.getMimeType(), mediaItem.getSize(), mediaItem.getWidth(), mediaItem.getHeight(), mediaItem.isBorderless(), mediaItem.getCaption().orNull(), null, mediaItem.getTransformProperties().orNull()));
} else {
Log.w(TAG, "Asked to send an unexpected mimeType: '" + mediaItem.getMimeType() + "'. Skipping.");
}
}
final Context context = requireContext().getApplicationContext();
sendMediaMessage(result.getRecipientId(), result.getTransport().isSms(), result.getBody(), slideDeck, quote, Collections.emptyList(), Collections.emptyList(), mentions, expiresIn, result.isViewOnce(), subscriptionId, initiating, true, null).addListener(new AssertedSuccessListener<Void>() {
@Override
public void onSuccess(Void result) {
AsyncTask.THREAD_POOL_EXECUTOR.execute(() -> {
Stream.of(slideDeck.getSlides()).map(Slide::getUri).withoutNulls().filter(BlobProvider::isAuthority).forEach(uri -> BlobProvider.getInstance().delete(context, uri));
});
}
});
break;
}
}
use of org.thoughtcrime.securesms.mms.ImageSlide in project Signal-Android by WhisperSystems.
the class ConversationItem method setMediaAttributes.
private void setMediaAttributes(@NonNull MessageRecord messageRecord, @NonNull Optional<MessageRecord> previousRecord, @NonNull Optional<MessageRecord> nextRecord, boolean isGroupThread, boolean hasWallpaper, boolean messageRequestAccepted, boolean allowedToPlayInline) {
boolean showControls = !messageRecord.isFailed();
ViewUtil.setTopMargin(bodyText, readDimen(R.dimen.message_bubble_top_padding));
bodyBubble.setQuoteViewProjection(null);
bodyBubble.setVideoPlayerProjection(null);
if (eventListener != null && audioViewStub.resolved()) {
Log.d(TAG, "setMediaAttributes: unregistering voice note callbacks for audio slide " + audioViewStub.get().getAudioSlideUri());
eventListener.onUnregisterVoiceNoteCallbacks(audioViewStub.get().getPlaybackStateObserver());
}
footer.setPlaybackSpeedListener(null);
if (isViewOnceMessage(messageRecord) && !messageRecord.isRemoteDelete()) {
revealableStub.get().setVisibility(VISIBLE);
if (mediaThumbnailStub.resolved())
mediaThumbnailStub.require().setVisibility(View.GONE);
if (audioViewStub.resolved())
audioViewStub.get().setVisibility(View.GONE);
if (documentViewStub.resolved())
documentViewStub.get().setVisibility(View.GONE);
if (sharedContactStub.resolved())
sharedContactStub.get().setVisibility(GONE);
if (linkPreviewStub.resolved())
linkPreviewStub.get().setVisibility(GONE);
if (stickerStub.resolved())
stickerStub.get().setVisibility(View.GONE);
revealableStub.get().setMessage((MmsMessageRecord) messageRecord, hasWallpaper);
revealableStub.get().setOnClickListener(revealableClickListener);
revealableStub.get().setOnLongClickListener(passthroughClickListener);
updateRevealableMargins(messageRecord, previousRecord, nextRecord, isGroupThread);
footer.setVisibility(VISIBLE);
} else if (hasSharedContact(messageRecord)) {
sharedContactStub.get().setVisibility(VISIBLE);
if (audioViewStub.resolved())
audioViewStub.get().setVisibility(View.GONE);
if (mediaThumbnailStub.resolved())
mediaThumbnailStub.require().setVisibility(View.GONE);
if (documentViewStub.resolved())
documentViewStub.get().setVisibility(View.GONE);
if (linkPreviewStub.resolved())
linkPreviewStub.get().setVisibility(GONE);
if (stickerStub.resolved())
stickerStub.get().setVisibility(View.GONE);
if (revealableStub.resolved())
revealableStub.get().setVisibility(View.GONE);
sharedContactStub.get().setContact(((MediaMmsMessageRecord) messageRecord).getSharedContacts().get(0), glideRequests, locale);
sharedContactStub.get().setEventListener(sharedContactEventListener);
sharedContactStub.get().setOnClickListener(sharedContactClickListener);
sharedContactStub.get().setOnLongClickListener(passthroughClickListener);
setSharedContactCorners(messageRecord, previousRecord, nextRecord, isGroupThread);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
footer.setVisibility(GONE);
} else if (hasLinkPreview(messageRecord) && messageRequestAccepted) {
linkPreviewStub.get().setVisibility(View.VISIBLE);
if (audioViewStub.resolved())
audioViewStub.get().setVisibility(View.GONE);
if (mediaThumbnailStub.resolved())
mediaThumbnailStub.require().setVisibility(View.GONE);
if (documentViewStub.resolved())
documentViewStub.get().setVisibility(View.GONE);
if (sharedContactStub.resolved())
sharedContactStub.get().setVisibility(GONE);
if (stickerStub.resolved())
stickerStub.get().setVisibility(View.GONE);
if (revealableStub.resolved())
revealableStub.get().setVisibility(View.GONE);
// noinspection ConstantConditions
LinkPreview linkPreview = ((MmsMessageRecord) messageRecord).getLinkPreviews().get(0);
if (hasBigImageLinkPreview(messageRecord)) {
mediaThumbnailStub.require().setVisibility(VISIBLE);
mediaThumbnailStub.require().setMinimumThumbnailWidth(readDimen(R.dimen.media_bubble_min_width_with_content));
mediaThumbnailStub.require().setImageResource(glideRequests, Collections.singletonList(new ImageSlide(context, linkPreview.getThumbnail().get())), showControls, false);
mediaThumbnailStub.require().setThumbnailClickListener(new LinkPreviewThumbnailClickListener());
mediaThumbnailStub.require().setDownloadClickListener(downloadClickListener);
mediaThumbnailStub.require().setOnLongClickListener(passthroughClickListener);
linkPreviewStub.get().setLinkPreview(glideRequests, linkPreview, false);
setThumbnailCorners(messageRecord, previousRecord, nextRecord, isGroupThread);
setLinkPreviewCorners(messageRecord, previousRecord, nextRecord, isGroupThread, true);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.setTopMargin(linkPreviewStub.get(), 0);
} else {
linkPreviewStub.get().setLinkPreview(glideRequests, linkPreview, true);
linkPreviewStub.get().setDownloadClickedListener(downloadClickListener);
setLinkPreviewCorners(messageRecord, previousRecord, nextRecord, isGroupThread, false);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// noinspection ConstantConditions
int topMargin = isGroupThread && isStartOfMessageCluster(messageRecord, previousRecord, isGroupThread) && !messageRecord.isOutgoing() ? readDimen(R.dimen.message_bubble_top_padding) : 0;
ViewUtil.setTopMargin(linkPreviewStub.get(), topMargin);
}
linkPreviewStub.get().setOnClickListener(linkPreviewClickListener);
linkPreviewStub.get().setOnLongClickListener(passthroughClickListener);
footer.setVisibility(VISIBLE);
} else if (hasAudio(messageRecord)) {
audioViewStub.get().setVisibility(View.VISIBLE);
if (mediaThumbnailStub.resolved())
mediaThumbnailStub.require().setVisibility(View.GONE);
if (documentViewStub.resolved())
documentViewStub.get().setVisibility(View.GONE);
if (sharedContactStub.resolved())
sharedContactStub.get().setVisibility(GONE);
if (linkPreviewStub.resolved())
linkPreviewStub.get().setVisibility(GONE);
if (stickerStub.resolved())
stickerStub.get().setVisibility(View.GONE);
if (revealableStub.resolved())
revealableStub.get().setVisibility(View.GONE);
audioViewStub.get().setAudio(Objects.requireNonNull(((MediaMmsMessageRecord) messageRecord).getSlideDeck().getAudioSlide()), new AudioViewCallbacks(), showControls, true);
audioViewStub.get().setDownloadClickListener(singleDownloadClickListener);
audioViewStub.get().setOnLongClickListener(passthroughClickListener);
if (eventListener != null) {
Log.d(TAG, "setMediaAttributes: registered listener for audio slide " + audioViewStub.get().getAudioSlideUri());
eventListener.onRegisterVoiceNoteCallbacks(audioViewStub.get().getPlaybackStateObserver());
} else {
Log.w(TAG, "setMediaAttributes: could not register listener for audio slide " + audioViewStub.get().getAudioSlideUri());
}
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
footer.setPlaybackSpeedListener(new AudioPlaybackSpeedToggleListener());
footer.setVisibility(VISIBLE);
} else if (hasDocument(messageRecord)) {
documentViewStub.get().setVisibility(View.VISIBLE);
if (mediaThumbnailStub.resolved())
mediaThumbnailStub.require().setVisibility(View.GONE);
if (audioViewStub.resolved())
audioViewStub.get().setVisibility(View.GONE);
if (sharedContactStub.resolved())
sharedContactStub.get().setVisibility(GONE);
if (linkPreviewStub.resolved())
linkPreviewStub.get().setVisibility(GONE);
if (stickerStub.resolved())
stickerStub.get().setVisibility(View.GONE);
if (revealableStub.resolved())
revealableStub.get().setVisibility(View.GONE);
// noinspection ConstantConditions
documentViewStub.get().setDocument(((MediaMmsMessageRecord) messageRecord).getSlideDeck().getDocumentSlide(), showControls);
documentViewStub.get().setDocumentClickListener(new ThumbnailClickListener());
documentViewStub.get().setDownloadClickListener(singleDownloadClickListener);
documentViewStub.get().setOnLongClickListener(passthroughClickListener);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.setTopMargin(bodyText, 0);
footer.setVisibility(VISIBLE);
} else if ((hasSticker(messageRecord) && isCaptionlessMms(messageRecord)) || isBorderless(messageRecord)) {
bodyBubble.setBackgroundColor(Color.TRANSPARENT);
stickerStub.get().setVisibility(View.VISIBLE);
if (mediaThumbnailStub.resolved())
mediaThumbnailStub.require().setVisibility(View.GONE);
if (audioViewStub.resolved())
audioViewStub.get().setVisibility(View.GONE);
if (documentViewStub.resolved())
documentViewStub.get().setVisibility(View.GONE);
if (sharedContactStub.resolved())
sharedContactStub.get().setVisibility(GONE);
if (linkPreviewStub.resolved())
linkPreviewStub.get().setVisibility(GONE);
if (revealableStub.resolved())
revealableStub.get().setVisibility(View.GONE);
if (hasSticker(messageRecord)) {
// noinspection ConstantConditions
stickerStub.get().setSlide(glideRequests, ((MmsMessageRecord) messageRecord).getSlideDeck().getStickerSlide());
stickerStub.get().setThumbnailClickListener(new StickerClickListener());
} else {
// noinspection ConstantConditions
stickerStub.get().setSlide(glideRequests, ((MmsMessageRecord) messageRecord).getSlideDeck().getThumbnailSlide());
stickerStub.get().setThumbnailClickListener((v, slide) -> performClick());
}
stickerStub.get().setDownloadClickListener(downloadClickListener);
stickerStub.get().setOnLongClickListener(passthroughClickListener);
stickerStub.get().setOnClickListener(passthroughClickListener);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
footer.setVisibility(VISIBLE);
} else if (hasNoBubble(messageRecord)) {
bodyBubble.setBackgroundColor(Color.TRANSPARENT);
} else if (hasThumbnail(messageRecord)) {
mediaThumbnailStub.require().setVisibility(View.VISIBLE);
if (audioViewStub.resolved())
audioViewStub.get().setVisibility(View.GONE);
if (documentViewStub.resolved())
documentViewStub.get().setVisibility(View.GONE);
if (sharedContactStub.resolved())
sharedContactStub.get().setVisibility(GONE);
if (linkPreviewStub.resolved())
linkPreviewStub.get().setVisibility(GONE);
if (stickerStub.resolved())
stickerStub.get().setVisibility(View.GONE);
if (revealableStub.resolved())
revealableStub.get().setVisibility(View.GONE);
List<Slide> thumbnailSlides = ((MmsMessageRecord) messageRecord).getSlideDeck().getThumbnailSlides();
mediaThumbnailStub.require().setMinimumThumbnailWidth(readDimen(isCaptionlessMms(messageRecord) ? R.dimen.media_bubble_min_width_solo : R.dimen.media_bubble_min_width_with_content));
mediaThumbnailStub.require().setImageResource(glideRequests, thumbnailSlides, showControls, false);
mediaThumbnailStub.require().setThumbnailClickListener(new ThumbnailClickListener());
mediaThumbnailStub.require().setDownloadClickListener(downloadClickListener);
mediaThumbnailStub.require().setOnLongClickListener(passthroughClickListener);
mediaThumbnailStub.require().setOnClickListener(passthroughClickListener);
mediaThumbnailStub.require().showShade(messageRecord.isDisplayBodyEmpty(getContext()) && !hasExtraText(messageRecord));
if (!messageRecord.isOutgoing()) {
mediaThumbnailStub.require().setConversationColor(getDefaultBubbleColor(hasWallpaper));
} else {
mediaThumbnailStub.require().setConversationColor(Color.TRANSPARENT);
}
mediaThumbnailStub.require().setBorderless(false);
setThumbnailCorners(messageRecord, previousRecord, nextRecord, isGroupThread);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
footer.setVisibility(VISIBLE);
if (thumbnailSlides.size() == 1 && thumbnailSlides.get(0).isVideoGif() && thumbnailSlides.get(0) instanceof VideoSlide) {
Uri uri = thumbnailSlides.get(0).getUri();
if (uri != null) {
mediaItem = MediaItem.fromUri(uri);
} else {
mediaItem = null;
}
canPlayContent = (GiphyMp4PlaybackPolicy.autoplay() || allowedToPlayInline) && mediaItem != null;
}
} else {
if (mediaThumbnailStub.resolved())
mediaThumbnailStub.require().setVisibility(View.GONE);
if (audioViewStub.resolved())
audioViewStub.get().setVisibility(View.GONE);
if (documentViewStub.resolved())
documentViewStub.get().setVisibility(View.GONE);
if (sharedContactStub.resolved())
sharedContactStub.get().setVisibility(GONE);
if (linkPreviewStub.resolved())
linkPreviewStub.get().setVisibility(GONE);
if (stickerStub.resolved())
stickerStub.get().setVisibility(View.GONE);
if (revealableStub.resolved())
revealableStub.get().setVisibility(View.GONE);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
footer.setVisibility(VISIBLE);
// noinspection ConstantConditions
int topMargin = !messageRecord.isOutgoing() && isGroupThread && isStartOfMessageCluster(messageRecord, previousRecord, isGroupThread) ? readDimen(R.dimen.message_bubble_text_only_top_margin) : readDimen(R.dimen.message_bubble_top_padding);
ViewUtil.setTopMargin(bodyText, topMargin);
}
}
use of org.thoughtcrime.securesms.mms.ImageSlide in project Signal-Android by WhisperSystems.
the class LinkPreviewView method setLinkPreview.
public void setLinkPreview(@NonNull GlideRequests glideRequests, @NonNull LinkPreview linkPreview, boolean showThumbnail) {
spinner.setVisibility(GONE);
noPreview.setVisibility(GONE);
if (!Util.isEmpty(linkPreview.getTitle())) {
title.setText(linkPreview.getTitle());
title.setVisibility(VISIBLE);
} else {
title.setVisibility(GONE);
}
if (!Util.isEmpty(linkPreview.getDescription())) {
description.setText(linkPreview.getDescription());
description.setVisibility(VISIBLE);
} else {
description.setVisibility(GONE);
}
String domain = null;
if (!Util.isEmpty(linkPreview.getUrl())) {
HttpUrl url = HttpUrl.parse(linkPreview.getUrl());
if (url != null) {
domain = url.topPrivateDomain();
}
}
if (domain != null && linkPreview.getDate() > 0) {
site.setText(getContext().getString(R.string.LinkPreviewView_domain_date, domain, formatDate(linkPreview.getDate())));
site.setVisibility(VISIBLE);
} else if (domain != null) {
site.setText(domain);
site.setVisibility(VISIBLE);
} else if (linkPreview.getDate() > 0) {
site.setText(formatDate(linkPreview.getDate()));
site.setVisibility(VISIBLE);
} else {
site.setVisibility(GONE);
}
if (showThumbnail && linkPreview.getThumbnail().isPresent()) {
thumbnail.setVisibility(VISIBLE);
thumbnail.setImageResource(glideRequests, new ImageSlide(getContext(), linkPreview.getThumbnail().get()), type == TYPE_CONVERSATION, false);
thumbnail.showDownloadText(false);
} else {
thumbnail.setVisibility(GONE);
}
}
use of org.thoughtcrime.securesms.mms.ImageSlide in project Signal-Android by WhisperSystems.
the class ConversationParentFragment method sendKeyboardImage.
private void sendKeyboardImage(@NonNull Uri uri, @NonNull String contentType, @Nullable KeyboardImageDetails details) {
if (details == null || !details.hasTransparency) {
setMedia(uri, Objects.requireNonNull(MediaType.from(contentType)));
return;
}
long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
boolean initiating = threadId == -1;
SlideDeck slideDeck = new SlideDeck();
if (MediaUtil.isGif(contentType)) {
slideDeck.addSlide(new GifSlide(requireContext(), uri, 0, details.width, details.height, details.hasTransparency, null));
} else if (MediaUtil.isImageType(contentType)) {
slideDeck.addSlide(new ImageSlide(requireContext(), uri, contentType, 0, details.width, details.height, details.hasTransparency, null, null));
} else {
throw new AssertionError("Only images are supported!");
}
sendMediaMessage(recipient.getId(), isSmsForced(), "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), composeText.getMentions(), expiresIn, false, subscriptionId, initiating, false, null);
}
Aggregations