Search in sources :

Example 1 with GlideRequests

use of org.thoughtcrime.securesms.mms.GlideRequests 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;
    }
}
Also used : VideoSlide(org.thoughtcrime.securesms.mms.VideoSlide) Context(android.content.Context) Bundle(android.os.Bundle) BubbleOptOutReminder(org.thoughtcrime.securesms.components.reminder.BubbleOptOutReminder) LinkPreview(org.thoughtcrime.securesms.linkpreview.LinkPreview) NonNull(androidx.annotation.NonNull) ContextUtil(org.thoughtcrime.securesms.util.ContextUtil) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) Media(org.thoughtcrime.securesms.mediasend.Media) EmojiEventListener(org.thoughtcrime.securesms.components.emoji.EmojiEventListener) ContextCompat(androidx.core.content.ContextCompat) OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) ConversationMessageFactory(org.thoughtcrime.securesms.conversation.ConversationMessage.ConversationMessageFactory) DecryptableStreamUriLoader(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader) EmojiStrings(org.thoughtcrime.securesms.components.emoji.EmojiStrings) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) IntentFilter(android.content.IntentFilter) CanNotSendPaymentDialog(org.thoughtcrime.securesms.payments.CanNotSendPaymentDialog) StickerSearchDialogFragment(org.thoughtcrime.securesms.keyboard.sticker.StickerSearchDialogFragment) SearchView(androidx.appcompat.widget.SearchView) AnimatingToggle(org.thoughtcrime.securesms.components.AnimatingToggle) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase) ChatWallpaper(org.thoughtcrime.securesms.wallpaper.ChatWallpaper) GroupChangeFailureReason(org.thoughtcrime.securesms.groups.ui.GroupChangeFailureReason) ServiceOutageReminder(org.thoughtcrime.securesms.components.reminder.ServiceOutageReminder) OutgoingMediaMessage(org.thoughtcrime.securesms.mms.OutgoingMediaMessage) MediaUtil(org.thoughtcrime.securesms.util.MediaUtil) QuoteId(org.thoughtcrime.securesms.mms.QuoteId) Types(org.thoughtcrime.securesms.database.MmsSmsColumns.Types) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Stream(com.annimon.stream.Stream) MediaKeyboardMode(org.thoughtcrime.securesms.util.TextSecurePreferences.MediaKeyboardMode) MainActivity(org.thoughtcrime.securesms.MainActivity) GroupRecord(org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) RetrieveProfileJob(org.thoughtcrime.securesms.jobs.RetrieveProfileJob) ReviewBannerView(org.thoughtcrime.securesms.profiles.spoofing.ReviewBannerView) ReminderView(org.thoughtcrime.securesms.components.reminder.ReminderView) MessageRequestState(org.thoughtcrime.securesms.messagerequests.MessageRequestState) SpannableStringBuilder(android.text.SpannableStringBuilder) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) UnverifiedBannerView(org.thoughtcrime.securesms.components.identity.UnverifiedBannerView) Type(org.thoughtcrime.securesms.TransportOption.Type) Settings(android.provider.Settings) OutgoingEncryptedMessage(org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage) SignalSessionLock(org.whispersystems.signalservice.api.SignalSessionLock) ListenableFuture(org.thoughtcrime.securesms.util.concurrent.ListenableFuture) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) CustomTarget(com.bumptech.glide.request.target.CustomTarget) MessageId(org.thoughtcrime.securesms.database.model.MessageId) StickerSearchRepository(org.thoughtcrime.securesms.stickers.StickerSearchRepository) Collectors(com.annimon.stream.Collectors) DraftRepository(org.thoughtcrime.securesms.conversation.drafts.DraftRepository) UpdatedBodyAndMentions(org.thoughtcrime.securesms.database.MentionUtil.UpdatedBodyAndMentions) SafetyNumberChangeDialog(org.thoughtcrime.securesms.conversation.ui.error.SafetyNumberChangeDialog) IOException(java.io.IOException) GroupCallPeekEvent(org.thoughtcrime.securesms.events.GroupCallPeekEvent) ConversationUtil(org.thoughtcrime.securesms.util.ConversationUtil) VoiceNoteDraft(org.thoughtcrime.securesms.components.voice.VoiceNoteDraft) ManagePendingAndRequestingMembersActivity(org.thoughtcrime.securesms.groups.ui.invitesandrequests.ManagePendingAndRequestingMembersActivity) InviteReminderRepository(org.thoughtcrime.securesms.invites.InviteReminderRepository) Optional(org.whispersystems.libsignal.util.guava.Optional) ExecutionException(java.util.concurrent.ExecutionException) Reminder(org.thoughtcrime.securesms.components.reminder.Reminder) IconCompat(androidx.core.graphics.drawable.IconCompat) StickerLocator(org.thoughtcrime.securesms.stickers.StickerLocator) Drafts(org.thoughtcrime.securesms.database.DraftDatabase.Drafts) Camera(android.hardware.Camera) ImageButton(android.widget.ImageButton) ReentrantSessionLock(org.thoughtcrime.securesms.crypto.ReentrantSessionLock) StickerKeyboardPageFragment(org.thoughtcrime.securesms.keyboard.sticker.StickerKeyboardPageFragment) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) WindowManager(android.view.WindowManager) RequestGroupV2InfoJob(org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob) DrawableUtil(org.thoughtcrime.securesms.util.DrawableUtil) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) MediaKeyboard(org.thoughtcrime.securesms.components.emoji.MediaKeyboard) TypingStatusSender(org.thoughtcrime.securesms.components.TypingStatusSender) GroupV1MigrationJob(org.thoughtcrime.securesms.jobs.GroupV1MigrationJob) AttachmentManager(org.thoughtcrime.securesms.mms.AttachmentManager) PlayStoreUtil(org.thoughtcrime.securesms.util.PlayStoreUtil) LocationSlide(org.thoughtcrime.securesms.mms.LocationSlide) ContactsContract(android.provider.ContactsContract) OnFocusChangeListener(android.view.View.OnFocusChangeListener) SecurityEvent(org.thoughtcrime.securesms.crypto.SecurityEvent) RegisteredState(org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Locale(java.util.Locale) AsynchronousCallback(org.thoughtcrime.securesms.util.AsynchronousCallback) ActivityInfo(android.content.pm.ActivityInfo) Button(android.widget.Button) VoiceNotePlaybackState(org.thoughtcrime.securesms.components.voice.VoiceNotePlaybackState) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) AsyncTask(android.os.AsyncTask) RecipientDisappearingMessagesActivity(org.thoughtcrime.securesms.recipients.ui.disappearingmessages.RecipientDisappearingMessagesActivity) VoiceNotePlayerView(org.thoughtcrime.securesms.components.voice.VoiceNotePlayerView) OutgoingSecureMediaMessage(org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage) CharacterState(org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState) PorterDuff(android.graphics.PorterDuff) ThreadUtil(org.signal.core.util.ThreadUtil) LinkPreviewViewModel(org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel) Objects(java.util.Objects) ChatWallpaperDimLevelUtil(org.thoughtcrime.securesms.wallpaper.ChatWallpaperDimLevelUtil) GroupsV1MigrationSuggestionsDialog(org.thoughtcrime.securesms.groups.ui.migration.GroupsV1MigrationSuggestionsDialog) Slide(org.thoughtcrime.securesms.mms.Slide) ActivityNotFoundException(android.content.ActivityNotFoundException) SignalPlace(org.thoughtcrime.securesms.components.location.SignalPlace) Draft(org.thoughtcrime.securesms.database.DraftDatabase.Draft) Toolbar(androidx.appcompat.widget.Toolbar) GiphyActivity(org.thoughtcrime.securesms.giph.ui.GiphyActivity) SmsUtil(org.thoughtcrime.securesms.util.SmsUtil) EditorInfo(android.view.inputmethod.EditorInfo) AlertDialog(androidx.appcompat.app.AlertDialog) KeyboardPage(org.thoughtcrime.securesms.keyboard.KeyboardPage) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RecipientDatabase(org.thoughtcrime.securesms.database.RecipientDatabase) MenuItem(android.view.MenuItem) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) Lifecycle(androidx.lifecycle.Lifecycle) MaterialButton(com.google.android.material.button.MaterialButton) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) PlacePickerActivity(org.thoughtcrime.securesms.maps.PlacePickerActivity) InviteReminderModel(org.thoughtcrime.securesms.invites.InviteReminderModel) QuoteModel(org.thoughtcrime.securesms.mms.QuoteModel) Build(android.os.Build) ShortcutLauncherActivity(org.thoughtcrime.securesms.ShortcutLauncherActivity) ConversationSearchBottomBar(org.thoughtcrime.securesms.components.ConversationSearchBottomBar) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) StickerPackInstallEvent(org.thoughtcrime.securesms.stickers.StickerPackInstallEvent) Stub(org.thoughtcrime.securesms.util.views.Stub) LayoutInflater(android.view.LayoutInflater) MediaSelectionActivity(org.thoughtcrime.securesms.mediasend.v2.MediaSelectionActivity) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper) GroupMembersDialog(org.thoughtcrime.securesms.GroupMembersDialog) GifSlide(org.thoughtcrime.securesms.mms.GifSlide) BlobProvider(org.thoughtcrime.securesms.providers.BlobProvider) CommunicationActions(org.thoughtcrime.securesms.util.CommunicationActions) WindowUtil(org.thoughtcrime.securesms.util.WindowUtil) Color(android.graphics.Color) GifKeyboardPageFragment(org.thoughtcrime.securesms.keyboard.gif.GifKeyboardPageFragment) OnKeyListener(android.view.View.OnKeyListener) ComposeText(org.thoughtcrime.securesms.components.ComposeText) MediaConstraints(org.thoughtcrime.securesms.mms.MediaConstraints) Bitmap(android.graphics.Bitmap) Transition(com.bumptech.glide.request.transition.Transition) Vibrator(android.os.Vibrator) ContactData(org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData) DraftViewModel(org.thoughtcrime.securesms.conversation.drafts.DraftViewModel) Activity(android.app.Activity) ContactShareEditActivity(org.thoughtcrime.securesms.contactshare.ContactShareEditActivity) UnauthorizedReminder(org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder) PendingGroupJoinRequestsReminder(org.thoughtcrime.securesms.components.reminder.PendingGroupJoinRequestsReminder) RecaptchaProofBottomSheetFragment(org.thoughtcrime.securesms.ratelimit.RecaptchaProofBottomSheetFragment) RecipientUtil(org.thoughtcrime.securesms.recipients.RecipientUtil) SendButton(org.thoughtcrime.securesms.components.SendButton) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) EmojiSearchFragment(org.thoughtcrime.securesms.keyboard.emoji.search.EmojiSearchFragment) MediaOverviewActivity(org.thoughtcrime.securesms.mediaoverview.MediaOverviewActivity) Drawable(android.graphics.drawable.Drawable) ImageSlide(org.thoughtcrime.securesms.mms.ImageSlide) ShortcutManagerCompat(androidx.core.content.pm.ShortcutManagerCompat) SecureRandom(java.security.SecureRandom) MentionUtil(org.thoughtcrime.securesms.database.MentionUtil) Manifest(android.Manifest) ReviewCardDialogFragment(org.thoughtcrime.securesms.profiles.spoofing.ReviewCardDialogFragment) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) Fragment(androidx.fragment.app.Fragment) TargetApi(android.annotation.TargetApi) ServiceUtil(org.thoughtcrime.securesms.util.ServiceUtil) Set(java.util.Set) ReactionRecord(org.thoughtcrime.securesms.database.model.ReactionRecord) StickerManagementActivity(org.thoughtcrime.securesms.stickers.StickerManagementActivity) IdRes(androidx.annotation.IdRes) Nullable(androidx.annotation.Nullable) InsightsLauncher(org.thoughtcrime.securesms.insights.InsightsLauncher) IdentityRecord(org.thoughtcrime.securesms.database.model.IdentityRecord) Attachment(org.thoughtcrime.securesms.attachments.Attachment) TextWatcher(android.text.TextWatcher) Util(org.thoughtcrime.securesms.util.Util) WorkerThread(androidx.annotation.WorkerThread) Editable(android.text.Editable) MessageRequestsBottomView(org.thoughtcrime.securesms.messagerequests.MessageRequestsBottomView) ArrayList(java.util.ArrayList) GroupsV1MigrationInitiationBottomSheetDialogFragment(org.thoughtcrime.securesms.groups.ui.migration.GroupsV1MigrationInitiationBottomSheetDialogFragment) RecipientFormattingException(org.thoughtcrime.securesms.recipients.RecipientFormattingException) AudioRecorder(org.thoughtcrime.securesms.audio.AudioRecorder) KeyCachingService(org.thoughtcrime.securesms.service.KeyCachingService) InputAwareLayout(org.thoughtcrime.securesms.components.InputAwareLayout) IdentityUtil(org.thoughtcrime.securesms.util.IdentityUtil) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Contact(org.thoughtcrime.securesms.contactshare.Contact) SpannableString(android.text.SpannableString) PaymentsValues(org.thoughtcrime.securesms.keyvalue.PaymentsValues) Permissions(org.thoughtcrime.securesms.permissions.Permissions) SpanUtil(org.thoughtcrime.securesms.util.SpanUtil) IdentityRecordList(org.thoughtcrime.securesms.database.identity.IdentityRecordList) AudioSlide(org.thoughtcrime.securesms.mms.AudioSlide) LinkPreviewRepository(org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository) ContactAccessor(org.thoughtcrime.securesms.contacts.ContactAccessor) Configuration(android.content.res.Configuration) RecipientExporter(org.thoughtcrime.securesms.recipients.RecipientExporter) GroupErrors(org.thoughtcrime.securesms.groups.ui.GroupErrors) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) BubbleUtil(org.thoughtcrime.securesms.util.BubbleUtil) MessageSender(org.thoughtcrime.securesms.sms.MessageSender) BlockUnblockDialog(org.thoughtcrime.securesms.BlockUnblockDialog) GroupCallViewModel(org.thoughtcrime.securesms.conversation.ui.groupcall.GroupCallViewModel) Spannable(android.text.Spannable) TimeoutException(java.util.concurrent.TimeoutException) PendingIntent(android.app.PendingIntent) LinkMovementMethod(android.text.method.LinkMovementMethod) R(org.thoughtcrime.securesms.R) Mention(org.thoughtcrime.securesms.database.model.Mention) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) Browser(android.provider.Browser) KeyboardPagerViewModel(org.thoughtcrime.securesms.keyboard.KeyboardPagerViewModel) View(android.view.View) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) MediaType(org.thoughtcrime.securesms.mms.SlideFactory.MediaType) ExpiredBuildReminder(org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder) Base64(org.thoughtcrime.securesms.util.Base64) StickerEventListener(org.thoughtcrime.securesms.stickers.StickerEventListener) ContactUtil(org.thoughtcrime.securesms.contactshare.ContactUtil) SimpleTextWatcher(org.thoughtcrime.securesms.contactshare.SimpleTextWatcher) InputPanel(org.thoughtcrime.securesms.components.InputPanel) MessageRequestViewModel(org.thoughtcrime.securesms.messagerequests.MessageRequestViewModel) InvalidMessageException(org.whispersystems.libsignal.InvalidMessageException) DraftDatabase(org.thoughtcrime.securesms.database.DraftDatabase) ThreadMode(org.greenrobot.eventbus.ThreadMode) BroadcastReceiver(android.content.BroadcastReceiver) ViewGroup(android.view.ViewGroup) Log(org.signal.core.util.logging.Log) List(java.util.List) TextView(android.widget.TextView) MentionAnnotation(org.thoughtcrime.securesms.components.mention.MentionAnnotation) GroupId(org.thoughtcrime.securesms.groups.GroupId) MessageResult(org.thoughtcrime.securesms.search.MessageResult) GlideRequests(org.thoughtcrime.securesms.mms.GlideRequests) GroupV2UpdateSelfProfileKeyJob(org.thoughtcrime.securesms.jobs.GroupV2UpdateSelfProfileKeyJob) BitmapUtil(org.thoughtcrime.securesms.util.BitmapUtil) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) VideoSlide(org.thoughtcrime.securesms.mms.VideoSlide) Context(android.content.Context) RegistrationNavigationActivity(org.thoughtcrime.securesms.registration.RegistrationNavigationActivity) KeyEvent(android.view.KeyEvent) DirectoryHelper(org.thoughtcrime.securesms.contacts.sync.DirectoryHelper) ReactionsBottomSheetDialogFragment(org.thoughtcrime.securesms.reactions.ReactionsBottomSheetDialogFragment) SignalLocalMetrics(org.thoughtcrime.securesms.util.SignalLocalMetrics) Intent(android.content.Intent) AssertedSuccessListener(org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener) OnKeyboardShownListener(org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout.OnKeyboardShownListener) TooltipPopup(org.thoughtcrime.securesms.components.TooltipPopup) SuppressLint(android.annotation.SuppressLint) Pair(org.whispersystems.libsignal.util.Pair) NotificationChannels(org.thoughtcrime.securesms.notifications.NotificationChannels) TransportOption(org.thoughtcrime.securesms.TransportOption) EmojiKeyboardPageFragment(org.thoughtcrime.securesms.keyboard.emoji.EmojiKeyboardPageFragment) MotionEvent(android.view.MotionEvent) EventBus(org.greenrobot.eventbus.EventBus) MessageUtil(org.thoughtcrime.securesms.util.MessageUtil) VoiceNoteMediaController(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController) ShortcutInfoCompat(androidx.core.content.pm.ShortcutInfoCompat) SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) VerifyIdentityActivity(org.thoughtcrime.securesms.verify.VerifyIdentityActivity) PromptMmsActivity(org.thoughtcrime.securesms.PromptMmsActivity) HidingLinearLayout(org.thoughtcrime.securesms.components.HidingLinearLayout) GroupsV1MigrationSuggestionsReminder(org.thoughtcrime.securesms.components.reminder.GroupsV1MigrationSuggestionsReminder) VerifiedStatus(org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus) MediaSendActivityResult(org.thoughtcrime.securesms.mediasend.MediaSendActivityResult) ActivityCompat(androidx.core.app.ActivityCompat) StickerRecord(org.thoughtcrime.securesms.database.model.StickerRecord) MessageDetailsFragment(org.thoughtcrime.securesms.messagedetails.MessageDetailsFragment) TombstoneAttachment(org.thoughtcrime.securesms.attachments.TombstoneAttachment) GroupActiveState(org.thoughtcrime.securesms.conversation.ConversationGroupViewModel.GroupActiveState) ConversationSettingsActivity(org.thoughtcrime.securesms.components.settings.conversation.ConversationSettingsActivity) TimeUnit(java.util.concurrent.TimeUnit) ServiceOutageDetectionJob(org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob) Observer(androidx.lifecycle.Observer) MentionsPickerViewModel(org.thoughtcrime.securesms.conversation.ui.mentions.MentionsPickerViewModel) Subscribe(org.greenrobot.eventbus.Subscribe) ReminderUpdateEvent(org.thoughtcrime.securesms.events.ReminderUpdateEvent) MuteDialog(org.thoughtcrime.securesms.MuteDialog) ReactWithAnyEmojiBottomSheetDialogFragment(org.thoughtcrime.securesms.reactions.any.ReactWithAnyEmojiBottomSheetDialogFragment) LeaveGroupDialog(org.thoughtcrime.securesms.groups.ui.LeaveGroupDialog) Collections(java.util.Collections) OnClickListener(android.view.View.OnClickListener) ArrayList(java.util.ArrayList) Media(org.thoughtcrime.securesms.mediasend.Media) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) Recipient(org.thoughtcrime.securesms.recipients.Recipient) MediaSendActivityResult(org.thoughtcrime.securesms.mediasend.MediaSendActivityResult) IOException(java.io.IOException) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) SignalPlace(org.thoughtcrime.securesms.components.location.SignalPlace) SuppressLint(android.annotation.SuppressLint) QuoteModel(org.thoughtcrime.securesms.mms.QuoteModel) ImageSlide(org.thoughtcrime.securesms.mms.ImageSlide) LocationSlide(org.thoughtcrime.securesms.mms.LocationSlide) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) Slide(org.thoughtcrime.securesms.mms.Slide) GifSlide(org.thoughtcrime.securesms.mms.GifSlide) ImageSlide(org.thoughtcrime.securesms.mms.ImageSlide) AudioSlide(org.thoughtcrime.securesms.mms.AudioSlide) VideoSlide(org.thoughtcrime.securesms.mms.VideoSlide) Mention(org.thoughtcrime.securesms.database.model.Mention) GifSlide(org.thoughtcrime.securesms.mms.GifSlide) BlobProvider(org.thoughtcrime.securesms.providers.BlobProvider)

Example 2 with GlideRequests

use of org.thoughtcrime.securesms.mms.GlideRequests 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);
    }
}
Also used : LinkPreview(org.thoughtcrime.securesms.linkpreview.LinkPreview) SlideClickListener(org.thoughtcrime.securesms.mms.SlideClickListener) NonNull(androidx.annotation.NonNull) LongClickMovementMethod(org.thoughtcrime.securesms.util.LongClickMovementMethod) Uri(android.net.Uri) StringUtil(org.thoughtcrime.securesms.util.StringUtil) TouchDelegate(android.view.TouchDelegate) ColorInt(androidx.annotation.ColorInt) LinkPreviewUtil(org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil) ImageSlide(org.thoughtcrime.securesms.mms.ImageSlide) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) TextSlide(org.thoughtcrime.securesms.mms.TextSlide) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) BindableConversationItem(org.thoughtcrime.securesms.BindableConversationItem) PartAuthority(org.thoughtcrime.securesms.mms.PartAuthority) LinkPreviewView(org.thoughtcrime.securesms.components.LinkPreviewView) ForegroundColorSpan(android.text.style.ForegroundColorSpan) ContextCompat(androidx.core.content.ContextCompat) PlaceholderURLSpan(org.thoughtcrime.securesms.util.PlaceholderURLSpan) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Set(java.util.Set) MediaPreviewActivity(org.thoughtcrime.securesms.MediaPreviewActivity) MmsDownloadJob(org.thoughtcrime.securesms.jobs.MmsDownloadJob) MessageRecordUtil(org.thoughtcrime.securesms.util.MessageRecordUtil) Nullable(androidx.annotation.Nullable) TextPaint(android.text.TextPaint) AlertView(org.thoughtcrime.securesms.components.AlertView) LinkifyCompat(androidx.core.text.util.LinkifyCompat) ViewOnceMessageView(org.thoughtcrime.securesms.revealable.ViewOnceMessageView) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Stream(com.annimon.stream.Stream) Util(org.thoughtcrime.securesms.util.Util) PlaybackSpeedToggleTextView(org.thoughtcrime.securesms.components.PlaybackSpeedToggleTextView) AttachmentDatabase(org.thoughtcrime.securesms.database.AttachmentDatabase) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) Toast(android.widget.Toast) Annotation(android.text.Annotation) AvatarImageView(org.thoughtcrime.securesms.components.AvatarImageView) MultiselectCollection(org.thoughtcrime.securesms.conversation.mutiselect.MultiselectCollection) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) URLSpan(android.text.style.URLSpan) Contact(org.thoughtcrime.securesms.contactshare.Contact) SpannableString(android.text.SpannableString) StyleSpan(android.text.style.StyleSpan) NullableStub(org.thoughtcrime.securesms.util.views.NullableStub) Optional(org.whispersystems.libsignal.util.guava.Optional) ThemeUtil(org.thoughtcrime.securesms.util.ThemeUtil) TypedValue(android.util.TypedValue) SmsSendJob(org.thoughtcrime.securesms.jobs.SmsSendJob) DocumentView(org.thoughtcrime.securesms.components.DocumentView) ProjectionList(org.thoughtcrime.securesms.util.ProjectionList) ValueAnimator(android.animation.ValueAnimator) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Rect(android.graphics.Rect) UrlClickHandler(org.thoughtcrime.securesms.util.UrlClickHandler) DimenRes(androidx.annotation.DimenRes) ConversationItemThumbnail(org.thoughtcrime.securesms.components.ConversationItemThumbnail) AttachmentDownloadJob(org.thoughtcrime.securesms.jobs.AttachmentDownloadJob) Spannable(android.text.Spannable) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) ClickableSpan(android.text.style.ClickableSpan) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) ChatColors(org.thoughtcrime.securesms.conversation.colors.ChatColors) R(org.thoughtcrime.securesms.R) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) AttributeSet(android.util.AttributeSet) Locale(java.util.Locale) View(android.view.View) Button(android.widget.Button) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SlidesClickedListener(org.thoughtcrime.securesms.mms.SlidesClickedListener) QuoteView(org.thoughtcrime.securesms.components.QuoteView) MediaItem(com.google.android.exoplayer2.MediaItem) Outliner(org.thoughtcrime.securesms.components.Outliner) RecipientForeverObserver(org.thoughtcrime.securesms.recipients.RecipientForeverObserver) PorterDuff(android.graphics.PorterDuff) SharedContactView(org.thoughtcrime.securesms.components.SharedContactView) ViewGroup(android.view.ViewGroup) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) Log(org.signal.core.util.logging.Log) List(java.util.List) TextView(android.widget.TextView) Slide(org.thoughtcrime.securesms.mms.Slide) MentionAnnotation(org.thoughtcrime.securesms.components.mention.MentionAnnotation) SearchUtil(org.thoughtcrime.securesms.util.SearchUtil) ActivityNotFoundException(android.content.ActivityNotFoundException) DateUtils(org.thoughtcrime.securesms.util.DateUtils) RelativeLayout(android.widget.RelativeLayout) GlideRequests(org.thoughtcrime.securesms.mms.GlideRequests) MessageDatabase(org.thoughtcrime.securesms.database.MessageDatabase) ReactionsConversationView(org.thoughtcrime.securesms.reactions.ReactionsConversationView) GiphyMp4PlaybackPolicy(org.thoughtcrime.securesms.giph.mp4.GiphyMp4PlaybackPolicy) Projection(org.thoughtcrime.securesms.util.Projection) VideoSlide(org.thoughtcrime.securesms.mms.VideoSlide) Typeface(android.graphics.Typeface) Context(android.content.Context) Spanned(android.text.Spanned) AlertDialog(androidx.appcompat.app.AlertDialog) InterceptableLongClickCopyLinkSpan(org.thoughtcrime.securesms.util.InterceptableLongClickCopyLinkSpan) BorderlessImageView(org.thoughtcrime.securesms.components.BorderlessImageView) MultiselectPart(org.thoughtcrime.securesms.conversation.mutiselect.MultiselectPart) GiphyMp4PlaybackPolicyEnforcer(org.thoughtcrime.securesms.giph.mp4.GiphyMp4PlaybackPolicyEnforcer) Intent(android.content.Intent) VibrateUtil(org.thoughtcrime.securesms.util.VibrateUtil) Linkify(android.text.util.Linkify) DatabaseAttachment(org.thoughtcrime.securesms.attachments.DatabaseAttachment) HashSet(java.util.HashSet) MmsSendJob(org.thoughtcrime.securesms.jobs.MmsSendJob) SuppressLint(android.annotation.SuppressLint) LifecycleOwner(androidx.lifecycle.LifecycleOwner) MotionEvent(android.view.MotionEvent) Colorizer(org.thoughtcrime.securesms.conversation.colors.Colorizer) AudioView(org.thoughtcrime.securesms.components.AudioView) Stub(org.thoughtcrime.securesms.util.views.Stub) BackgroundColorSpan(android.text.style.BackgroundColorSpan) Quote(org.thoughtcrime.securesms.database.model.Quote) Color(android.graphics.Color) TimeUnit(java.util.concurrent.TimeUnit) BadgeImageView(org.thoughtcrime.securesms.badges.BadgeImageView) CharacterStyle(android.text.style.CharacterStyle) ConversationItemFooter(org.thoughtcrime.securesms.components.ConversationItemFooter) Collections(java.util.Collections) VideoSlide(org.thoughtcrime.securesms.mms.VideoSlide) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) LinkPreview(org.thoughtcrime.securesms.linkpreview.LinkPreview) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Uri(android.net.Uri) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) ImageSlide(org.thoughtcrime.securesms.mms.ImageSlide) ArrayList(java.util.ArrayList) ProjectionList(org.thoughtcrime.securesms.util.ProjectionList) List(java.util.List)

Example 3 with GlideRequests

use of org.thoughtcrime.securesms.mms.GlideRequests in project Signal-Android by WhisperSystems.

the class ImageMediaPreviewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ZoomingImageView zoomingImageView = (ZoomingImageView) inflater.inflate(R.layout.media_preview_image_fragment, container, false);
    GlideRequests glideRequests = GlideApp.with(requireActivity());
    Bundle arguments = requireArguments();
    Uri uri = arguments.getParcelable(DATA_URI);
    String contentType = arguments.getString(DATA_CONTENT_TYPE);
    if (!MediaUtil.isImageType(contentType)) {
        throw new AssertionError("This fragment can only display images");
    }
    // noinspection ConstantConditions
    zoomingImageView.setImageUri(glideRequests, uri, contentType);
    zoomingImageView.setOnClickListener(v -> events.singleTapOnMedia());
    return zoomingImageView;
}
Also used : GlideRequests(org.thoughtcrime.securesms.mms.GlideRequests) Bundle(android.os.Bundle) ZoomingImageView(org.thoughtcrime.securesms.components.ZoomingImageView) Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)3 SuppressLint (android.annotation.SuppressLint)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Color (android.graphics.Color)2 PorterDuff (android.graphics.PorterDuff)2 Bundle (android.os.Bundle)2 Spannable (android.text.Spannable)2 SpannableString (android.text.SpannableString)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 MotionEvent (android.view.MotionEvent)2 View (android.view.View)2 GlideRequests (org.thoughtcrime.securesms.mms.GlideRequests)2 Manifest (android.Manifest)1 ValueAnimator (android.animation.ValueAnimator)1 TargetApi (android.annotation.TargetApi)1 Activity (android.app.Activity)1 PendingIntent (android.app.PendingIntent)1 BroadcastReceiver (android.content.BroadcastReceiver)1