Search in sources :

Example 6 with SlideDeck

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

the class ThreadDatabase method getAttachmentUriFor.

@Nullable
private Uri getAttachmentUriFor(MessageRecord record) {
    if (!record.isMms() || record.isMmsNotification() || record.isGroupAction())
        return null;
    SlideDeck slideDeck = ((MediaMmsMessageRecord) record).getSlideDeck();
    Slide thumbnail = Optional.fromNullable(slideDeck.getThumbnailSlide()).or(Optional.fromNullable(slideDeck.getStickerSlide())).orNull();
    if (thumbnail != null && !((MmsMessageRecord) record).isViewOnce()) {
        return thumbnail.getUri();
    }
    return null;
}
Also used : MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) Slide(org.thoughtcrime.securesms.mms.Slide) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Nullable(androidx.annotation.Nullable)

Example 7 with SlideDeck

use of org.thoughtcrime.securesms.mms.SlideDeck 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 8 with SlideDeck

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

the class ConversationParentFragment method handleReplyMessage.

@Override
public void handleReplyMessage(ConversationMessage conversationMessage) {
    MessageRecord messageRecord = conversationMessage.getMessageRecord();
    Recipient author;
    if (messageRecord.isOutgoing()) {
        author = Recipient.self();
    } else {
        author = messageRecord.getIndividualRecipient();
    }
    if (messageRecord.isMms() && !((MmsMessageRecord) messageRecord).getSharedContacts().isEmpty()) {
        Contact contact = ((MmsMessageRecord) messageRecord).getSharedContacts().get(0);
        String displayName = ContactUtil.getDisplayName(contact);
        String body = getString(R.string.ConversationActivity_quoted_contact_message, EmojiStrings.BUST_IN_SILHOUETTE, displayName);
        SlideDeck slideDeck = new SlideDeck();
        if (contact.getAvatarAttachment() != null) {
            slideDeck.addSlide(MediaUtil.getSlideForAttachment(requireContext(), contact.getAvatarAttachment()));
        }
        inputPanel.setQuote(GlideApp.with(this), messageRecord.getDateSent(), author, body, slideDeck);
    } else if (messageRecord.isMms() && !((MmsMessageRecord) messageRecord).getLinkPreviews().isEmpty()) {
        LinkPreview linkPreview = ((MmsMessageRecord) messageRecord).getLinkPreviews().get(0);
        SlideDeck slideDeck = new SlideDeck();
        if (linkPreview.getThumbnail().isPresent()) {
            slideDeck.addSlide(MediaUtil.getSlideForAttachment(requireContext(), linkPreview.getThumbnail().get()));
        }
        inputPanel.setQuote(GlideApp.with(this), messageRecord.getDateSent(), author, conversationMessage.getDisplayBody(requireContext()), slideDeck);
    } else {
        SlideDeck slideDeck = messageRecord.isMms() ? ((MmsMessageRecord) messageRecord).getSlideDeck() : new SlideDeck();
        if (messageRecord.isMms() && ((MmsMessageRecord) messageRecord).isViewOnce()) {
            Attachment attachment = new TombstoneAttachment(MediaUtil.VIEW_ONCE, true);
            slideDeck = new SlideDeck();
            slideDeck.addSlide(MediaUtil.getSlideForAttachment(requireContext(), attachment));
        }
        inputPanel.setQuote(GlideApp.with(this), messageRecord.getDateSent(), author, conversationMessage.getDisplayBody(requireContext()), slideDeck);
    }
    inputPanel.clickOnComposeInput();
}
Also used : TombstoneAttachment(org.thoughtcrime.securesms.attachments.TombstoneAttachment) LinkPreview(org.thoughtcrime.securesms.linkpreview.LinkPreview) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Attachment(org.thoughtcrime.securesms.attachments.Attachment) TombstoneAttachment(org.thoughtcrime.securesms.attachments.TombstoneAttachment) SpannableString(android.text.SpannableString) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) Contact(org.thoughtcrime.securesms.contactshare.Contact)

Example 9 with SlideDeck

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

the class ConversationParentFragment method sendMediaMessage.

private void sendMediaMessage(@NonNull MediaSendActivityResult result) {
    long thread = this.threadId;
    long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
    QuoteModel quote = result.isViewOnce() ? null : inputPanel.getQuote().orNull();
    List<Mention> mentions = new ArrayList<>(result.getMentions());
    OutgoingMediaMessage message = new OutgoingMediaMessage(recipient.get(), new SlideDeck(), result.getBody(), System.currentTimeMillis(), -1, expiresIn, result.isViewOnce(), distributionType, quote, Collections.emptyList(), Collections.emptyList(), mentions);
    OutgoingMediaMessage secureMessage = new OutgoingSecureMediaMessage(message);
    final Context context = requireContext().getApplicationContext();
    ApplicationDependencies.getTypingStatusSender().onTypingStopped(thread);
    inputPanel.clearQuote();
    attachmentManager.clear(glideRequests, false);
    silentlySetComposeText("");
    long id = fragment.stageOutgoingMessage(secureMessage);
    SimpleTask.run(() -> {
        long resultId = MessageSender.sendPushWithPreUploadedMedia(context, secureMessage, result.getPreUploadResults(), thread, null);
        int deleted = SignalDatabase.attachments().deleteAbandonedPreuploadedAttachments();
        Log.i(TAG, "Deleted " + deleted + " abandoned attachments.");
        return resultId;
    }, this::sendComplete);
}
Also used : Context(android.content.Context) OutgoingSecureMediaMessage(org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage) Mention(org.thoughtcrime.securesms.database.model.Mention) ArrayList(java.util.ArrayList) OutgoingMediaMessage(org.thoughtcrime.securesms.mms.OutgoingMediaMessage) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) QuoteModel(org.thoughtcrime.securesms.mms.QuoteModel) SuppressLint(android.annotation.SuppressLint)

Example 10 with SlideDeck

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

the class ConversationParentFragment method sendSticker.

private void sendSticker(@NonNull StickerLocator stickerLocator, @NonNull String contentType, @NonNull Uri uri, long size, boolean clearCompose) {
    if (sendButton.getSelectedTransport().isSms()) {
        Media media = new Media(uri, contentType, System.currentTimeMillis(), StickerSlide.WIDTH, StickerSlide.HEIGHT, size, 0, false, false, Optional.absent(), Optional.absent(), Optional.absent());
        Intent intent = MediaSelectionActivity.editor(requireContext(), sendButton.getSelectedTransport(), Collections.singletonList(media), recipient.getId(), composeText.getTextTrimmed());
        startActivityForResult(intent, MEDIA_SENDER);
        return;
    }
    long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
    int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
    boolean initiating = threadId == -1;
    TransportOption transport = sendButton.getSelectedTransport();
    SlideDeck slideDeck = new SlideDeck();
    Slide stickerSlide = new StickerSlide(requireContext(), uri, size, stickerLocator, contentType);
    slideDeck.addSlide(stickerSlide);
    sendMediaMessage(recipient.getId(), transport.isSms(), "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), expiresIn, false, subscriptionId, initiating, clearCompose, null);
}
Also used : TransportOption(org.thoughtcrime.securesms.TransportOption) 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) Media(org.thoughtcrime.securesms.mediasend.Media) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) SuppressLint(android.annotation.SuppressLint)

Aggregations

SlideDeck (org.thoughtcrime.securesms.mms.SlideDeck)26 Recipient (org.thoughtcrime.securesms.recipients.Recipient)13 SuppressLint (android.annotation.SuppressLint)11 Context (android.content.Context)8 AudioSlide (org.thoughtcrime.securesms.mms.AudioSlide)8 OutgoingMediaMessage (org.thoughtcrime.securesms.mms.OutgoingMediaMessage)8 OutgoingSecureMediaMessage (org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage)7 Nullable (androidx.annotation.Nullable)6 WorkerThread (androidx.annotation.WorkerThread)6 ArrayList (java.util.ArrayList)6 Mention (org.thoughtcrime.securesms.database.model.Mention)6 MmsMessageRecord (org.thoughtcrime.securesms.database.model.MmsMessageRecord)6 GifSlide (org.thoughtcrime.securesms.mms.GifSlide)6 ImageSlide (org.thoughtcrime.securesms.mms.ImageSlide)6 Slide (org.thoughtcrime.securesms.mms.Slide)6 StickerSlide (org.thoughtcrime.securesms.mms.StickerSlide)6 OutgoingTextMessage (org.thoughtcrime.securesms.sms.OutgoingTextMessage)6 SpannableString (android.text.SpannableString)5 Attachment (org.thoughtcrime.securesms.attachments.Attachment)5 Contact (org.thoughtcrime.securesms.contactshare.Contact)5