mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 20:33:39 +00:00
Re-implement GIF & document sending
This commit is contained in:
parent
bf80f5c449
commit
ca3034cb05
@ -422,9 +422,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!org.thoughtcrime.securesms.util.Util.isEmpty(composeText) || attachmentManager.isAttachmentPresent()) {
|
if (!org.thoughtcrime.securesms.util.Util.isEmpty(composeText)) {
|
||||||
saveDraft();
|
saveDraft();
|
||||||
attachmentManager.clear(glideRequests, false);
|
attachmentManager.clear();
|
||||||
silentlySetComposeText("");
|
silentlySetComposeText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1426,7 +1426,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
case AttachmentTypeSelector.ADD_CONTACT_INFO:
|
case AttachmentTypeSelector.ADD_CONTACT_INFO:
|
||||||
AttachmentManager.selectContactInfo(this, PICK_CONTACT); break;
|
AttachmentManager.selectContactInfo(this, PICK_CONTACT); break;
|
||||||
case AttachmentTypeSelector.ADD_LOCATION:
|
case AttachmentTypeSelector.ADD_LOCATION:
|
||||||
AttachmentManager.selectLocation(this, PICK_LOCATION); break;
|
break;
|
||||||
case AttachmentTypeSelector.TAKE_PHOTO:
|
case AttachmentTypeSelector.TAKE_PHOTO:
|
||||||
attachmentManager.capturePhoto(this, TAKE_PHOTO); break;
|
attachmentManager.capturePhoto(this, TAKE_PHOTO); break;
|
||||||
case AttachmentTypeSelector.ADD_GIF:
|
case AttachmentTypeSelector.ADD_GIF:
|
||||||
@ -1620,7 +1620,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
private String getMessage() throws InvalidMessageException {
|
private String getMessage() throws InvalidMessageException {
|
||||||
String result = composeText.getTextTrimmed();
|
String result = composeText.getTextTrimmed();
|
||||||
if (result.length() < 1 && !attachmentManager.isAttachmentPresent()) throw new InvalidMessageException();
|
if (result.length() < 1) throw new InvalidMessageException();
|
||||||
for (Mention mention : mentions) {
|
for (Mention mention : mentions) {
|
||||||
try {
|
try {
|
||||||
int startIndex = result.indexOf("@" + mention.getDisplayName());
|
int startIndex = result.indexOf("@" + mention.getDisplayName());
|
||||||
@ -1723,7 +1723,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
String message = getMessage();
|
String message = getMessage();
|
||||||
boolean initiating = threadId == -1;
|
boolean initiating = threadId == -1;
|
||||||
boolean needsSplit = message.length() > characterCalculator.calculateCharacters(message).maxPrimaryMessageSize;
|
boolean needsSplit = message.length() > characterCalculator.calculateCharacters(message).maxPrimaryMessageSize;
|
||||||
boolean isMediaMessage = attachmentManager.isAttachmentPresent() ||
|
boolean isMediaMessage = false ||
|
||||||
// recipient.isGroupRecipient() ||
|
// recipient.isGroupRecipient() ||
|
||||||
inputPanel.getQuote().isPresent() ||
|
inputPanel.getQuote().isPresent() ||
|
||||||
linkPreviewViewModel.hasLinkPreview() ||
|
linkPreviewViewModel.hasLinkPreview() ||
|
||||||
@ -1785,7 +1785,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
ApplicationContext.getInstance(context).getTypingStatusSender().onTypingStopped(threadId);
|
ApplicationContext.getInstance(context).getTypingStatusSender().onTypingStopped(threadId);
|
||||||
|
|
||||||
inputPanel.clearQuote();
|
inputPanel.clearQuote();
|
||||||
attachmentManager.clear(glideRequests, false);
|
attachmentManager.clear();
|
||||||
silentlySetComposeText("");
|
silentlySetComposeText("");
|
||||||
|
|
||||||
final long id = fragment.stageOutgoingMessage(outgoingMessage);
|
final long id = fragment.stageOutgoingMessage(outgoingMessage);
|
||||||
@ -1859,7 +1859,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (composeText.getText().length() == 0 && !attachmentManager.isAttachmentPresent()) {
|
if (composeText.getText().length() == 0) {
|
||||||
buttonToggle.display(attachButton);
|
buttonToggle.display(attachButton);
|
||||||
quickAttachmentToggle.show();
|
quickAttachmentToggle.show();
|
||||||
inlineAttachmentToggle.hide();
|
inlineAttachmentToggle.hide();
|
||||||
@ -1867,7 +1867,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
buttonToggle.display(sendButton);
|
buttonToggle.display(sendButton);
|
||||||
quickAttachmentToggle.hide();
|
quickAttachmentToggle.hide();
|
||||||
|
|
||||||
if (!attachmentManager.isAttachmentPresent() && !linkPreviewViewModel.hasLinkPreview()) {
|
if (!linkPreviewViewModel.hasLinkPreview()) {
|
||||||
inlineAttachmentToggle.show();
|
inlineAttachmentToggle.show();
|
||||||
} else {
|
} else {
|
||||||
inlineAttachmentToggle.hide();
|
inlineAttachmentToggle.hide();
|
||||||
@ -1876,7 +1876,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLinkPreviewState() {
|
private void updateLinkPreviewState() {
|
||||||
if (TextSecurePreferences.isLinkPreviewsEnabled(this) && !attachmentManager.isAttachmentPresent()) {
|
if (TextSecurePreferences.isLinkPreviewsEnabled(this)) {
|
||||||
linkPreviewViewModel.onEnabled();
|
linkPreviewViewModel.onEnabled();
|
||||||
linkPreviewViewModel.onTextChanged(this, composeText.getTextTrimmed(), composeText.getSelectionStart(), composeText.getSelectionEnd());
|
linkPreviewViewModel.onTextChanged(this, composeText.getTextTrimmed(), composeText.getSelectionStart(), composeText.getSelectionEnd());
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,6 +13,7 @@ import android.util.Log
|
|||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.loader.app.LoaderManager
|
import androidx.loader.app.LoaderManager
|
||||||
@ -39,6 +40,7 @@ import org.session.libsession.messaging.open_groups.OpenGroupAPIV2
|
|||||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
import org.session.libsignal.utilities.ListenableFuture
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.contactshare.SimpleTextWatcher
|
import org.thoughtcrime.securesms.contactshare.SimpleTextWatcher
|
||||||
@ -66,6 +68,7 @@ import org.thoughtcrime.securesms.notifications.MarkReadReceiver
|
|||||||
import org.thoughtcrime.securesms.util.DateUtils
|
import org.thoughtcrime.securesms.util.DateUtils
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil
|
import org.thoughtcrime.securesms.util.MediaUtil
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.concurrent.ExecutionException
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
// Some things that seemingly belong to the input bar (e.g. the voice message recording UI) are actually
|
// Some things that seemingly belong to the input bar (e.g. the voice message recording UI) are actually
|
||||||
@ -681,9 +684,9 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
currentMentionStartIndex = -1
|
currentMentionStartIndex = -1
|
||||||
mentions.clear()
|
mentions.clear()
|
||||||
// Reset the attachment manager
|
// Reset the attachment manager
|
||||||
attachmentManager.clear(glide, false)
|
attachmentManager.clear()
|
||||||
//
|
// Reset attachments button if needed
|
||||||
|
if (isShowingAttachmentOptions) { toggleAttachmentOptions() }
|
||||||
// Put the message in the database
|
// Put the message in the database
|
||||||
message.id = DatabaseFactory.getMmsDatabase(this).insertMessageOutbox(outgoingTextMessage, threadID, false) { }
|
message.id = DatabaseFactory.getMmsDatabase(this).insertMessageOutbox(outgoingTextMessage, threadID, false) { }
|
||||||
// Send it
|
// Send it
|
||||||
@ -709,27 +712,37 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttachmentChanged() {
|
override fun onAttachmentChanged() {
|
||||||
|
// TODO: Do we need to do something here?
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, intent)
|
super.onActivityResult(requestCode, resultCode, intent)
|
||||||
intent ?: return
|
intent ?: return
|
||||||
|
val mediaPreppedListener = object : ListenableFuture.Listener<Boolean> {
|
||||||
|
|
||||||
|
override fun onSuccess(result: Boolean?) {
|
||||||
|
sendAttachments(attachmentManager.buildSlideDeck().asAttachments(), null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(e: ExecutionException?) {
|
||||||
|
Toast.makeText(this@ConversationActivityV2, R.string.activity_conversation_attachment_prep_failed, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
PICK_DOCUMENT -> {
|
PICK_DOCUMENT -> {
|
||||||
val uri = intent.data ?: return
|
val uri = intent.data ?: return
|
||||||
prepMediaForSending(uri, AttachmentManager.MediaType.DOCUMENT)
|
prepMediaForSending(uri, AttachmentManager.MediaType.DOCUMENT).addListener(mediaPreppedListener)
|
||||||
}
|
}
|
||||||
TAKE_PHOTO -> {
|
TAKE_PHOTO -> {
|
||||||
val uri = attachmentManager.captureUri ?: return
|
val uri = attachmentManager.captureUri ?: return
|
||||||
prepMediaForSending(uri, AttachmentManager.MediaType.IMAGE)
|
prepMediaForSending(uri, AttachmentManager.MediaType.IMAGE).addListener(mediaPreppedListener)
|
||||||
}
|
}
|
||||||
PICK_GIF -> {
|
PICK_GIF -> {
|
||||||
val uri = intent.data ?: return
|
val uri = intent.data ?: return
|
||||||
val type = AttachmentManager.MediaType.GIF
|
val type = AttachmentManager.MediaType.GIF
|
||||||
val width = intent.getIntExtra(GiphyActivity.EXTRA_WIDTH, 0)
|
val width = intent.getIntExtra(GiphyActivity.EXTRA_WIDTH, 0)
|
||||||
val height = intent.getIntExtra(GiphyActivity.EXTRA_HEIGHT, 0)
|
val height = intent.getIntExtra(GiphyActivity.EXTRA_HEIGHT, 0)
|
||||||
prepMediaForSending(uri, type, width, height)
|
prepMediaForSending(uri, type, width, height).addListener(mediaPreppedListener)
|
||||||
}
|
}
|
||||||
PICK_FROM_LIBRARY -> {
|
PICK_FROM_LIBRARY -> {
|
||||||
val body = intent.getStringExtra(MediaSendActivity.EXTRA_MESSAGE)
|
val body = intent.getStringExtra(MediaSendActivity.EXTRA_MESSAGE)
|
||||||
@ -756,12 +769,12 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepMediaForSending(uri: Uri, type: AttachmentManager.MediaType) {
|
private fun prepMediaForSending(uri: Uri, type: AttachmentManager.MediaType): ListenableFuture<Boolean> {
|
||||||
prepMediaForSending(uri, type, null, null)
|
return prepMediaForSending(uri, type, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepMediaForSending(uri: Uri, type: AttachmentManager.MediaType, width: Int?, height: Int?) {
|
private fun prepMediaForSending(uri: Uri, type: AttachmentManager.MediaType, width: Int?, height: Int?): ListenableFuture<Boolean> {
|
||||||
attachmentManager.setMedia(glide, uri, type, MediaConstraints.getPushMediaConstraints(), width ?: 0, height ?: 0)
|
return attachmentManager.setMedia(glide, uri, type, MediaConstraints.getPushMediaConstraints(), width ?: 0, height ?: 0)
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
@ -73,20 +73,13 @@ import network.loki.messenger.R;
|
|||||||
|
|
||||||
import static android.provider.MediaStore.EXTRA_OUTPUT;
|
import static android.provider.MediaStore.EXTRA_OUTPUT;
|
||||||
|
|
||||||
|
|
||||||
public class AttachmentManager {
|
public class AttachmentManager {
|
||||||
|
|
||||||
private final static String TAG = AttachmentManager.class.getSimpleName();
|
private final static String TAG = AttachmentManager.class.getSimpleName();
|
||||||
|
|
||||||
private final @NonNull Context context;
|
private final @NonNull Context context;
|
||||||
private final @NonNull Stub<View> attachmentViewStub;
|
|
||||||
private final @NonNull AttachmentListener attachmentListener;
|
private final @NonNull AttachmentListener attachmentListener;
|
||||||
|
|
||||||
private RemovableEditableMediaView removableMediaView;
|
|
||||||
private ThumbnailView thumbnail;
|
|
||||||
private MessageAudioView audioView;
|
|
||||||
private DocumentView documentView;
|
|
||||||
|
|
||||||
private @NonNull List<Uri> garbage = new LinkedList<>();
|
private @NonNull List<Uri> garbage = new LinkedList<>();
|
||||||
private @NonNull Optional<Slide> slide = Optional.absent();
|
private @NonNull Optional<Slide> slide = Optional.absent();
|
||||||
private @Nullable Uri captureUri;
|
private @Nullable Uri captureUri;
|
||||||
@ -94,51 +87,12 @@ public class AttachmentManager {
|
|||||||
public AttachmentManager(@NonNull Activity activity, @NonNull AttachmentListener listener) {
|
public AttachmentManager(@NonNull Activity activity, @NonNull AttachmentListener listener) {
|
||||||
this.context = activity;
|
this.context = activity;
|
||||||
this.attachmentListener = listener;
|
this.attachmentListener = listener;
|
||||||
this.attachmentViewStub = ViewUtil.findStubById(activity, R.id.attachment_editor_stub);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inflateStub() {
|
public void clear() {
|
||||||
if (!attachmentViewStub.resolved()) {
|
markGarbage(getSlideUri());
|
||||||
View root = attachmentViewStub.get();
|
slide = Optional.absent();
|
||||||
|
attachmentListener.onAttachmentChanged();
|
||||||
this.thumbnail = ViewUtil.findById(root, R.id.attachment_thumbnail);
|
|
||||||
this.audioView = ViewUtil.findById(root, R.id.attachment_audio);
|
|
||||||
this.documentView = ViewUtil.findById(root, R.id.attachment_document);
|
|
||||||
this.removableMediaView = ViewUtil.findById(root, R.id.removable_media_view);
|
|
||||||
|
|
||||||
removableMediaView.setRemoveClickListener(new RemoveButtonListener());
|
|
||||||
thumbnail.setOnClickListener(new ThumbnailClickListener());
|
|
||||||
documentView.getBackground().setColorFilter(ThemeUtil.getThemedColor(context, R.attr.conversation_item_bubble_background), PorterDuff.Mode.MULTIPLY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(@NonNull GlideRequests glideRequests, boolean animate) {
|
|
||||||
if (attachmentViewStub.resolved()) {
|
|
||||||
|
|
||||||
if (animate) {
|
|
||||||
ViewUtil.fadeOut(attachmentViewStub.get(), 200).addListener(new Listener<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Boolean result) {
|
|
||||||
thumbnail.clear(glideRequests);
|
|
||||||
attachmentViewStub.get().setVisibility(View.GONE);
|
|
||||||
attachmentListener.onAttachmentChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(ExecutionException e) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
thumbnail.clear(glideRequests);
|
|
||||||
attachmentViewStub.get().setVisibility(View.GONE);
|
|
||||||
attachmentListener.onAttachmentChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
markGarbage(getSlideUri());
|
|
||||||
slide = Optional.absent();
|
|
||||||
|
|
||||||
audioView.cleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
@ -190,16 +144,12 @@ public class AttachmentManager {
|
|||||||
final int width,
|
final int width,
|
||||||
final int height)
|
final int height)
|
||||||
{
|
{
|
||||||
inflateStub();
|
|
||||||
|
|
||||||
final SettableFuture<Boolean> result = new SettableFuture<>();
|
final SettableFuture<Boolean> result = new SettableFuture<>();
|
||||||
|
|
||||||
new AsyncTask<Void, Void, Slide>() {
|
new AsyncTask<Void, Void, Slide>() {
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
thumbnail.clear(glideRequests);
|
|
||||||
thumbnail.showProgressSpinner();
|
|
||||||
attachmentViewStub.get().setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -222,35 +172,12 @@ public class AttachmentManager {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(@Nullable final Slide slide) {
|
protected void onPostExecute(@Nullable final Slide slide) {
|
||||||
if (slide == null) {
|
if (slide == null) {
|
||||||
attachmentViewStub.get().setVisibility(View.GONE);
|
|
||||||
Toast.makeText(context,
|
|
||||||
R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
result.set(false);
|
result.set(false);
|
||||||
} else if (!areConstraintsSatisfied(context, slide, constraints)) {
|
} else if (!areConstraintsSatisfied(context, slide, constraints)) {
|
||||||
attachmentViewStub.get().setVisibility(View.GONE);
|
|
||||||
Toast.makeText(context,
|
|
||||||
R.string.ConversationActivity_attachment_exceeds_size_limits,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
result.set(false);
|
result.set(false);
|
||||||
} else {
|
} else {
|
||||||
setSlide(slide);
|
setSlide(slide);
|
||||||
attachmentViewStub.get().setVisibility(View.VISIBLE);
|
result.set(true);
|
||||||
|
|
||||||
if (slide.hasAudio()) {
|
|
||||||
audioView.setAudio((AudioSlide) slide, false);
|
|
||||||
removableMediaView.display(audioView, false);
|
|
||||||
result.set(true);
|
|
||||||
} else if (slide.hasDocument()) {
|
|
||||||
documentView.setDocument((DocumentSlide) slide, false);
|
|
||||||
removableMediaView.display(documentView, false);
|
|
||||||
result.set(true);
|
|
||||||
} else {
|
|
||||||
Attachment attachment = slide.asAttachment();
|
|
||||||
result.deferTo(thumbnail.setImageResource(glideRequests, slide, false, true, attachment.getWidth(), attachment.getHeight()));
|
|
||||||
removableMediaView.display(thumbnail, mediaType == MediaType.IMAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
attachmentListener.onAttachmentChanged();
|
attachmentListener.onAttachmentChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,10 +244,6 @@ public class AttachmentManager {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAttachmentPresent() {
|
|
||||||
return attachmentViewStub.resolved() && attachmentViewStub.get().getVisibility() == View.VISIBLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull SlideDeck buildSlideDeck() {
|
public @NonNull SlideDeck buildSlideDeck() {
|
||||||
SlideDeck deck = new SlideDeck();
|
SlideDeck deck = new SlideDeck();
|
||||||
if (slide.isPresent()) deck.addSlide(slide.get());
|
if (slide.isPresent()) deck.addSlide(slide.get());
|
||||||
@ -354,22 +277,6 @@ public class AttachmentManager {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void selectLocation(Activity activity, int requestCode) {
|
|
||||||
/* Loki - Enable again once we have location sharing
|
|
||||||
Permissions.with(activity)
|
|
||||||
.request(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)
|
|
||||||
.withPermanentDenialDialog(activity.getString(R.string.AttachmentManager_signal_requires_location_information_in_order_to_attach_a_location))
|
|
||||||
.onAllGranted(() -> {
|
|
||||||
try {
|
|
||||||
activity.startActivityForResult(new PlacePicker.IntentBuilder().build(activity), requestCode);
|
|
||||||
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.execute();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void selectGif(Activity activity, int requestCode) {
|
public static void selectGif(Activity activity, int requestCode) {
|
||||||
Intent intent = new Intent(activity, GiphyActivity.class);
|
Intent intent = new Intent(activity, GiphyActivity.class);
|
||||||
intent.putExtra(GiphyActivity.EXTRA_IS_MMS, false);
|
intent.putExtra(GiphyActivity.EXTRA_IS_MMS, false);
|
||||||
@ -445,34 +352,6 @@ public class AttachmentManager {
|
|||||||
constraints.canResize(slide.asAttachment());
|
constraints.canResize(slide.asAttachment());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void previewImageDraft(final @NonNull Slide slide) {
|
|
||||||
if (MediaPreviewActivity.isContentTypeSupported(slide.getContentType()) && slide.getUri() != null) {
|
|
||||||
Intent intent = new Intent(context, MediaPreviewActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, slide.asAttachment().getSize());
|
|
||||||
intent.putExtra(MediaPreviewActivity.CAPTION_EXTRA, slide.getCaption().orNull());
|
|
||||||
intent.putExtra(MediaPreviewActivity.OUTGOING_EXTRA, true);
|
|
||||||
intent.setDataAndType(slide.getUri(), slide.getContentType());
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ThumbnailClickListener implements View.OnClickListener {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (slide.isPresent()) previewImageDraft(slide.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class RemoveButtonListener implements View.OnClickListener {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
cleanup();
|
|
||||||
clear(GlideApp.with(context.getApplicationContext()), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface AttachmentListener {
|
public interface AttachmentListener {
|
||||||
void onAttachmentChanged();
|
void onAttachmentChanged();
|
||||||
}
|
}
|
||||||
|
@ -872,4 +872,6 @@
|
|||||||
<string name="dialog_download_button_title">Download</string>
|
<string name="dialog_download_button_title">Download</string>
|
||||||
|
|
||||||
<string name="activity_conversation_blocked_banner_text">%s is blocked. Unblock them?</string>
|
<string name="activity_conversation_blocked_banner_text">%s is blocked. Unblock them?</string>
|
||||||
|
|
||||||
|
<string name="activity_conversation_attachment_prep_failed">Failed to prepare attachment for sending.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user