mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
clean & minor fix
This commit is contained in:
parent
2db567144d
commit
c8149209a1
@ -6,6 +6,8 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
@ -50,7 +52,7 @@ public class AudioRecorder {
|
||||
|
||||
captureUri = BlobProvider.getInstance()
|
||||
.forData(new ParcelFileDescriptor.AutoCloseInputStream(fds[0]), 0)
|
||||
.withMimeType(MediaUtil.AUDIO_AAC)
|
||||
.withMimeType(MediaTypes.AUDIO_AAC)
|
||||
.createForSingleSessionOnDisk(context, e -> Log.w(TAG, "Error during recording", e));
|
||||
audioCodec = new AudioCodec();
|
||||
|
||||
|
@ -85,6 +85,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.session.libsignal.libsignal.InvalidMessageException;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.session.libsignal.service.loki.api.opengroups.PublicChat;
|
||||
@ -1900,7 +1901,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
String filename = String.format("signal-%s.txt", timestamp);
|
||||
Uri textUri = BlobProvider.getInstance()
|
||||
.forData(textData)
|
||||
.withMimeType(MediaUtil.LONG_TEXT)
|
||||
.withMimeType(MediaTypes.LONG_TEXT)
|
||||
.withFileName(filename)
|
||||
.createForSingleSessionInMemory();
|
||||
|
||||
@ -2186,7 +2187,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
int subscriptionId = -1;
|
||||
long expiresIn = recipient.getExpireMessages() * 1000L;
|
||||
boolean initiating = threadId == -1;
|
||||
AudioSlide audioSlide = new AudioSlide(ConversationActivity.this, result.first, result.second, MediaUtil.AUDIO_AAC, true);
|
||||
AudioSlide audioSlide = new AudioSlide(ConversationActivity.this, result.first, result.second, MediaTypes.AUDIO_AAC, true);
|
||||
SlideDeck slideDeck = new SlideDeck();
|
||||
slideDeck.addSlide(audioSlide);
|
||||
|
||||
|
@ -38,6 +38,7 @@ import net.sqlcipher.database.SQLiteDatabase;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.session.libsignal.libsignal.logging.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.AttachmentSecret;
|
||||
@ -797,7 +798,7 @@ public class AttachmentDatabase extends Database {
|
||||
if (thumbnailUri != null) {
|
||||
try (InputStream attachmentStream = PartAuthority.getAttachmentStream(context, thumbnailUri)) {
|
||||
Pair<Integer, Integer> dimens;
|
||||
if (attachment.getContentType().equals(MediaUtil.IMAGE_GIF)) {
|
||||
if (attachment.getContentType().equals(MediaTypes.IMAGE_GIF)) {
|
||||
dimens = new Pair<>(attachment.getWidth(), attachment.getHeight());
|
||||
} else {
|
||||
dimens = BitmapUtil.getDimensions(attachmentStream);
|
||||
|
@ -18,10 +18,10 @@ import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -110,7 +110,7 @@ public class GiphyActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
return BlobProvider.getInstance()
|
||||
.forData(data)
|
||||
.withMimeType(MediaUtil.IMAGE_GIF)
|
||||
.withMimeType(MediaTypes.IMAGE_GIF)
|
||||
.createForSingleSessionOnDisk(GiphyActivity.this, e -> Log.w(TAG, "Failed to write to disk.", e));
|
||||
} catch (InterruptedException | ExecutionException | IOException e) {
|
||||
Log.w(TAG, e);
|
||||
|
@ -14,6 +14,7 @@ import org.session.libsession.messaging.sending_receiving.attachments.UriAttachm
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.utilities.GroupUtil;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
@ -24,11 +25,9 @@ import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsignal.service.api.util.InvalidNumberException;
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos.GroupContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -192,7 +191,7 @@ public class GroupManager {
|
||||
|
||||
if (avatar != null) {
|
||||
Uri avatarUri = BlobProvider.getInstance().forData(avatar).createForSingleUseInMemory();
|
||||
avatarAttachment = new UriAttachment(avatarUri, MediaUtil.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length, null, false, false, null, null);
|
||||
avatarAttachment = new UriAttachment(avatarUri, MediaTypes.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length, null, false, false, null, null);
|
||||
}
|
||||
|
||||
OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, groupContext, avatarAttachment, System.currentTimeMillis(), 0, null, Collections.emptyList(), Collections.emptyList());
|
||||
|
@ -15,6 +15,7 @@ import com.annimon.stream.Collectors;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.session.libsession.messaging.jobs.Data;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.session.libsignal.metadata.InvalidMetadataMessageException;
|
||||
import org.session.libsignal.metadata.InvalidMetadataVersionException;
|
||||
import org.session.libsignal.metadata.ProtocolDuplicateMessageException;
|
||||
@ -98,7 +99,6 @@ import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
import org.session.libsignal.utilities.Hex;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsignal.libsignal.InvalidMessageException;
|
||||
import org.session.libsignal.libsignal.loki.SessionResetProtocol;
|
||||
import org.session.libsignal.libsignal.state.SignalProtocolStore;
|
||||
@ -1170,7 +1170,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
if (stickerRecord != null) {
|
||||
return Optional.of(new UriAttachment(stickerRecord.getUri(),
|
||||
stickerRecord.getUri(),
|
||||
MediaUtil.IMAGE_WEBP,
|
||||
MediaTypes.IMAGE_WEBP,
|
||||
AttachmentDatabase.TRANSFER_PROGRESS_DONE,
|
||||
stickerRecord.getSize(),
|
||||
StickerSlide.WIDTH,
|
||||
|
@ -10,6 +10,7 @@ import com.annimon.stream.Stream;
|
||||
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.session.libsession.messaging.sending_receiving.contacts.Contact;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.session.libsignal.utilities.Base64;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.Util;
|
||||
@ -191,7 +192,7 @@ public abstract class PushSendJob extends SendJob {
|
||||
for (Attachment attachment : message.getOutgoingQuote().getAttachments()) {
|
||||
BitmapUtil.ScaleResult thumbnailData = null;
|
||||
SignalServiceAttachment thumbnail = null;
|
||||
String thumbnailType = MediaUtil.IMAGE_JPEG;
|
||||
String thumbnailType = MediaTypes.IMAGE_JPEG;
|
||||
|
||||
try {
|
||||
if (MediaUtil.isImageType(attachment.getContentType()) && attachment.getDataUri() != null) {
|
||||
|
@ -18,7 +18,7 @@ import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.service.UpdateApkReadyListener;
|
||||
import org.thoughtcrime.securesms.util.FileUtils;
|
||||
import org.session.libsession.utilities.FileUtils;
|
||||
import org.session.libsignal.utilities.Hex;
|
||||
import org.session.libsignal.utilities.JsonUtil;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
@ -11,6 +11,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.google.android.gms.common.util.IOUtils;
|
||||
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
@ -24,7 +25,6 @@ import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.stickers.StickerRemoteUri;
|
||||
import org.thoughtcrime.securesms.stickers.StickerUrl;
|
||||
import org.session.libsignal.utilities.Hex;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsignal.libsignal.InvalidMessageException;
|
||||
import org.session.libsignal.libsignal.util.Pair;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
@ -175,7 +175,7 @@ public class LinkPreviewRepository implements InjectableType {
|
||||
|
||||
byte[] data = IOUtils.readInputStreamFully(bodyStream);
|
||||
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||
Optional<Attachment> thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.JPEG, MediaUtil.IMAGE_JPEG);
|
||||
Optional<Attachment> thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.JPEG, MediaTypes.IMAGE_JPEG);
|
||||
|
||||
if (bitmap != null) bitmap.recycle();
|
||||
|
||||
@ -225,7 +225,7 @@ public class LinkPreviewRepository implements InjectableType {
|
||||
Uri uri = BlobProvider.getInstance().forData(bytes).createForSingleSessionInMemory();
|
||||
Optional<Attachment> thumbnail = Optional.of(new UriAttachment(uri,
|
||||
uri,
|
||||
MediaUtil.IMAGE_WEBP,
|
||||
MediaTypes.IMAGE_WEBP,
|
||||
AttachmentDatabase.TRANSFER_PROGRESS_STARTED,
|
||||
bytes.length,
|
||||
bitmap.getWidth(),
|
||||
|
@ -20,13 +20,13 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
@ -266,10 +266,10 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
||||
try {
|
||||
Uri uri = BlobProvider.getInstance()
|
||||
.forData(data)
|
||||
.withMimeType(MediaUtil.IMAGE_JPEG)
|
||||
.withMimeType(MediaTypes.IMAGE_JPEG)
|
||||
.createForSingleSessionOnDisk(this, e -> Log.w(TAG, "Failed to write to disk.", e));
|
||||
return new Media(uri,
|
||||
MediaUtil.IMAGE_JPEG,
|
||||
MediaTypes.IMAGE_JPEG,
|
||||
System.currentTimeMillis(),
|
||||
width,
|
||||
height,
|
||||
|
@ -28,6 +28,7 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.components.ComposeText;
|
||||
import org.thoughtcrime.securesms.components.ControllableViewPager;
|
||||
import org.thoughtcrime.securesms.components.InputAwareLayout;
|
||||
@ -44,7 +45,6 @@ import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
||||
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
@ -453,10 +453,10 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
||||
|
||||
Uri uri = BlobProvider.getInstance()
|
||||
.forData(baos.toByteArray())
|
||||
.withMimeType(MediaUtil.IMAGE_JPEG)
|
||||
.withMimeType(MediaTypes.IMAGE_JPEG)
|
||||
.createForSingleSessionOnDisk(context, e -> Log.w(TAG, "Failed to write to disk.", e));
|
||||
|
||||
Media updated = new Media(uri, MediaUtil.IMAGE_JPEG, media.getDate(), bitmap.getWidth(), bitmap.getHeight(), baos.size(), media.getBucketId(), media.getCaption());
|
||||
Media updated = new Media(uri, MediaTypes.IMAGE_JPEG, media.getDate(), bitmap.getWidth(), bitmap.getHeight(), baos.size(), media.getBucketId(), media.getCaption());
|
||||
|
||||
updatedMedia.add(updated);
|
||||
renderTimer.split("item");
|
||||
|
@ -39,7 +39,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
||||
import org.thoughtcrime.securesms.loki.views.MessageAudioView;
|
||||
import org.thoughtcrime.securesms.components.DocumentView;
|
||||
@ -213,7 +213,7 @@ public class AttachmentManager {
|
||||
byte[] blob = BitmapUtil.toByteArray(result);
|
||||
Uri uri = BlobProvider.getInstance()
|
||||
.forData(blob)
|
||||
.withMimeType(MediaUtil.IMAGE_JPEG)
|
||||
.withMimeType(MediaTypes.IMAGE_JPEG)
|
||||
.createForSingleSessionInMemory();
|
||||
LocationSlide locationSlide = new LocationSlide(context, uri, blob.length, place);
|
||||
|
||||
|
@ -26,15 +26,15 @@ import androidx.annotation.Nullable;
|
||||
import network.loki.messenger.R;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.UriAttachment;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
|
||||
|
||||
public class AudioSlide extends Slide {
|
||||
|
||||
public AudioSlide(Context context, Uri uri, long dataSize, boolean voiceNote) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, null, null, voiceNote, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaTypes.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, null, null, voiceNote, false));
|
||||
}
|
||||
|
||||
public AudioSlide(Context context, Uri uri, long dataSize, String contentType, boolean voiceNote) {
|
||||
|
@ -5,7 +5,7 @@ import android.net.Uri;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
|
||||
public class GifSlide extends ImageSlide {
|
||||
|
||||
@ -19,7 +19,7 @@ public class GifSlide extends ImageSlide {
|
||||
}
|
||||
|
||||
public GifSlide(Context context, Uri uri, long size, int width, int height, @Nullable String caption) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_GIF, size, width, height, true, null, caption, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaTypes.IMAGE_GIF, size, width, height, true, null, caption, null, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
|
||||
public class ImageSlide extends Slide {
|
||||
|
||||
@ -41,7 +41,7 @@ public class ImageSlide extends Slide {
|
||||
}
|
||||
|
||||
public ImageSlide(Context context, Uri uri, long size, int width, int height, @Nullable String caption) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_JPEG, size, width, height, true, null, caption, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaTypes.IMAGE_JPEG, size, width, height, true, null, caption, null, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,8 @@ import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
@ -75,7 +77,7 @@ public abstract class MediaConstraints {
|
||||
try {
|
||||
// XXX - This is loading everything into memory! We want the send path to be stream-like.
|
||||
BitmapUtil.ScaleResult scaleResult = BitmapUtil.createScaledBytes(context, new DecryptableUri(attachment.getDataUri()), this);
|
||||
return new MediaStream(new ByteArrayInputStream(scaleResult.getBitmap()), MediaUtil.IMAGE_JPEG, scaleResult.getWidth(), scaleResult.getHeight());
|
||||
return new MediaStream(new ByteArrayInputStream(scaleResult.getBitmap()), MediaTypes.IMAGE_JPEG, scaleResult.getWidth(), scaleResult.getHeight());
|
||||
} catch (BitmapDecodingException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
@ -23,7 +23,7 @@ public class StickerSlide extends Slide {
|
||||
}
|
||||
|
||||
public StickerSlide(Context context, Uri uri, long size, @NonNull StickerLocator stickerLocator) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_WEBP, size, WIDTH, HEIGHT, true, null, null, stickerLocator, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaTypes.IMAGE_WEBP, size, WIDTH, HEIGHT, true, null, null, stickerLocator, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
|
||||
public class TextSlide extends Slide {
|
||||
|
||||
@ -16,6 +16,6 @@ public class TextSlide extends Slide {
|
||||
}
|
||||
|
||||
public TextSlide(@NonNull Context context, @NonNull Uri uri, @Nullable String filename, long size) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.LONG_TEXT, size, 0, 0, true, filename, null, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaTypes.LONG_TEXT, size, 0, 0, true, filename, null, null, false, false));
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
|
||||
@ -35,7 +36,7 @@ public class VideoSlide extends Slide {
|
||||
}
|
||||
|
||||
public VideoSlide(Context context, Uri uri, long dataSize, @Nullable String caption) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.VIDEO_UNSPECIFIED, dataSize, 0, 0, MediaUtil.hasVideoThumbnail(uri), null, caption, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaTypes.VIDEO_UNSPECIFIED, dataSize, 0, 0, MediaUtil.hasVideoThumbnail(uri), null, caption, null, false, false));
|
||||
}
|
||||
|
||||
public VideoSlide(Context context, Attachment attachment) {
|
||||
|
@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||
import network.loki.messenger.R;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||
import org.thoughtcrime.securesms.util.FileUtils;
|
||||
import org.session.libsession.utilities.FileUtils;
|
||||
import org.session.libsignal.utilities.Hex;
|
||||
import org.session.libsession.utilities.ServiceUtil;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
@ -18,6 +18,7 @@ import android.util.Pair;
|
||||
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
@ -203,9 +204,9 @@ public class BitmapUtil {
|
||||
if (contentType == null) return CompressFormat.JPEG;
|
||||
|
||||
switch (contentType) {
|
||||
case MediaUtil.IMAGE_JPEG: return CompressFormat.JPEG;
|
||||
case MediaUtil.IMAGE_PNG: return CompressFormat.PNG;
|
||||
case MediaUtil.IMAGE_WEBP: return CompressFormat.WEBP;
|
||||
case MediaTypes.IMAGE_JPEG: return CompressFormat.JPEG;
|
||||
case MediaTypes.IMAGE_PNG: return CompressFormat.PNG;
|
||||
case MediaTypes.IMAGE_WEBP: return CompressFormat.WEBP;
|
||||
default: return CompressFormat.JPEG;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -18,7 +16,6 @@ import network.loki.messenger.R;
|
||||
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
|
||||
public class CommunicationActions {
|
||||
|
@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
public class Dialogs {
|
||||
public static void showAlertDialog(Context context, String title, String message) {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
|
||||
dialog.setTitle(title);
|
||||
dialog.setMessage(message);
|
||||
dialog.setIconAttribute(R.attr.dialog_alert_icon);
|
||||
dialog.setPositiveButton(android.R.string.ok, null);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showInfoDialog(Context context, String title, String message) {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
|
||||
dialog.setTitle(title);
|
||||
dialog.setMessage(message);
|
||||
dialog.setIconAttribute(R.attr.dialog_info_icon);
|
||||
dialog.setPositiveButton(android.R.string.ok, null);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class MathUtils {
|
||||
|
||||
/**
|
||||
* For more info:
|
||||
* <a href="http://math.stackexchange.com/questions/190111/how-to-check-if-a-point-is-inside-a-rectangle">StackOverflow: How to check point is in rectangle</a>
|
||||
*
|
||||
* @param pt point to check
|
||||
* @param v1 vertex 1 of the triangle
|
||||
* @param v2 vertex 2 of the triangle
|
||||
* @param v3 vertex 3 of the triangle
|
||||
* @return true if point (x, y) is inside the triangle
|
||||
*/
|
||||
public static boolean pointInTriangle(@NonNull PointF pt, @NonNull PointF v1,
|
||||
@NonNull PointF v2, @NonNull PointF v3) {
|
||||
|
||||
boolean b1 = crossProduct(pt, v1, v2) < 0.0f;
|
||||
boolean b2 = crossProduct(pt, v2, v3) < 0.0f;
|
||||
boolean b3 = crossProduct(pt, v3, v1) < 0.0f;
|
||||
|
||||
return (b1 == b2) && (b2 == b3);
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates cross product of vectors AB and AC
|
||||
*
|
||||
* @param a beginning of 2 vectors
|
||||
* @param b end of vector 1
|
||||
* @param c enf of vector 2
|
||||
* @return cross product AB * AC
|
||||
*/
|
||||
private static float crossProduct(@NonNull PointF a, @NonNull PointF b, @NonNull PointF c) {
|
||||
return crossProduct(a.x, a.y, b.x, b.y, c.x, c.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates cross product of vectors AB and AC
|
||||
*
|
||||
* @param ax X coordinate of point A
|
||||
* @param ay Y coordinate of point A
|
||||
* @param bx X coordinate of point B
|
||||
* @param by Y coordinate of point B
|
||||
* @param cx X coordinate of point C
|
||||
* @param cy Y coordinate of point C
|
||||
* @return cross product AB * AC
|
||||
*/
|
||||
private static float crossProduct(float ax, float ay, float bx, float by, float cx, float cy) {
|
||||
return (ax - cx) * (by - cy) - (bx - cx) * (ay - cy);
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
||||
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.AudioSlide;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
||||
@ -39,17 +40,6 @@ public class MediaUtil {
|
||||
|
||||
private static final String TAG = MediaUtil.class.getSimpleName();
|
||||
|
||||
public static final String IMAGE_PNG = "image/png";
|
||||
public static final String IMAGE_JPEG = "image/jpeg";
|
||||
public static final String IMAGE_WEBP = "image/webp";
|
||||
public static final String IMAGE_GIF = "image/gif";
|
||||
public static final String AUDIO_AAC = "audio/aac";
|
||||
public static final String AUDIO_UNSPECIFIED = "audio/*";
|
||||
public static final String VIDEO_UNSPECIFIED = "video/*";
|
||||
public static final String VCARD = "text/x-vcard";
|
||||
public static final String LONG_TEXT = "text/x-signal-plain";
|
||||
|
||||
|
||||
public static Slide getSlideForAttachment(Context context, Attachment attachment) {
|
||||
Slide slide = null;
|
||||
if (attachment.isSticker()) {
|
||||
@ -94,8 +84,8 @@ public class MediaUtil {
|
||||
|
||||
switch(mimeType) {
|
||||
case "image/jpg":
|
||||
return MimeTypeMap.getSingleton().hasMimeType(IMAGE_JPEG)
|
||||
? IMAGE_JPEG
|
||||
return MimeTypeMap.getSingleton().hasMimeType(MediaTypes.IMAGE_JPEG)
|
||||
? MediaTypes.IMAGE_JPEG
|
||||
: mimeType;
|
||||
default:
|
||||
return mimeType;
|
||||
@ -206,7 +196,7 @@ public class MediaUtil {
|
||||
}
|
||||
|
||||
public static boolean isVcard(String contentType) {
|
||||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(VCARD);
|
||||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(MediaTypes.VCARD);
|
||||
}
|
||||
|
||||
public static boolean isGif(String contentType) {
|
||||
@ -214,7 +204,7 @@ public class MediaUtil {
|
||||
}
|
||||
|
||||
public static boolean isJpegType(String contentType) {
|
||||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(IMAGE_JPEG);
|
||||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(MediaTypes.IMAGE_JPEG);
|
||||
}
|
||||
|
||||
public static boolean isFile(Attachment attachment) {
|
||||
@ -240,7 +230,7 @@ public class MediaUtil {
|
||||
}
|
||||
|
||||
public static boolean isLongTextType(String contentType) {
|
||||
return (null != contentType) && contentType.equals(LONG_TEXT);
|
||||
return (null != contentType) && contentType.equals(MediaTypes.LONG_TEXT);
|
||||
}
|
||||
|
||||
public static boolean hasVideoThumbnail(Uri uri) {
|
||||
|
@ -79,8 +79,8 @@ public abstract class Attachment {
|
||||
}
|
||||
|
||||
public boolean isInProgress() {
|
||||
return transferState != AttachmentTransferProgress.TRANSFER_PROGRESS_DONE.getValue() &&
|
||||
transferState != AttachmentTransferProgress.TRANSFER_PROGRESS_FAILED.getValue();
|
||||
return transferState != AttachmentTransferProgress.TRANSFER_PROGRESS_DONE &&
|
||||
transferState != AttachmentTransferProgress.TRANSFER_PROGRESS_FAILED;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.session.libsession.messaging.sending_receiving.attachments
|
||||
|
||||
enum class AttachmentTransferProgress(val value: Int) {
|
||||
TRANSFER_PROGRESS_DONE(0),
|
||||
TRANSFER_PROGRESS_STARTED(1),
|
||||
TRANSFER_PROGRESS_PENDING(2),
|
||||
TRANSFER_PROGRESS_FAILED(3)
|
||||
object AttachmentTransferProgress {
|
||||
const val TRANSFER_PROGRESS_DONE = 0
|
||||
const val TRANSFER_PROGRESS_STARTED = 1
|
||||
const val TRANSFER_PROGRESS_PENDING = 2
|
||||
const val TRANSFER_PROGRESS_FAILED = 3
|
||||
}
|
@ -104,7 +104,7 @@ public class PointerAttachment extends Attachment {
|
||||
}
|
||||
|
||||
return Optional.of(new PointerAttachment(pointer.get().getContentType(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING.getValue(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING,
|
||||
pointer.get().asPointer().getSize().or(0),
|
||||
pointer.get().asPointer().getFileName().orNull(),
|
||||
String.valueOf(pointer.get().asPointer().getId()),
|
||||
@ -122,7 +122,7 @@ public class PointerAttachment extends Attachment {
|
||||
|
||||
public static Optional<Attachment> forPointer(SignalServiceProtos.AttachmentPointer pointer) {
|
||||
return Optional.of(new PointerAttachment(pointer.getContentType(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING.getValue(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING,
|
||||
(long)pointer.getSize(),
|
||||
pointer.getFileName(),
|
||||
String.valueOf(pointer != null ? pointer.getId() : 0),
|
||||
@ -142,7 +142,7 @@ public class PointerAttachment extends Attachment {
|
||||
SignalServiceProtos.AttachmentPointer thumbnail = pointer.getThumbnail();
|
||||
|
||||
return Optional.of(new PointerAttachment(pointer.getContentType(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING.getValue(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING,
|
||||
thumbnail != null ? (long)thumbnail.getSize() : 0,
|
||||
thumbnail.getFileName(),
|
||||
String.valueOf(thumbnail != null ? thumbnail.getId() : 0),
|
||||
@ -162,7 +162,7 @@ public class PointerAttachment extends Attachment {
|
||||
SignalServiceAttachment thumbnail = pointer.getThumbnail();
|
||||
|
||||
return Optional.of(new PointerAttachment(pointer.getContentType(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING.getValue(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING,
|
||||
thumbnail != null ? thumbnail.asPointer().getSize().or(0) : 0,
|
||||
pointer.getFileName(),
|
||||
String.valueOf(thumbnail != null ? thumbnail.asPointer().getId() : 0),
|
||||
|
@ -643,7 +643,7 @@ public class Contact implements Parcelable {
|
||||
|
||||
private static Attachment attachmentFromUri(@Nullable Uri uri) {
|
||||
if (uri == null) return null;
|
||||
return new UriAttachment(uri, MediaTypes.IMAGE_JPEG.getValue(), AttachmentTransferProgress.TRANSFER_PROGRESS_DONE.getValue(), 0, null, false, false, null, null);
|
||||
return new UriAttachment(uri, MediaTypes.IMAGE_JPEG, AttachmentTransferProgress.TRANSFER_PROGRESS_DONE, 0, null, false, false, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
package org.session.libsession.utilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
@ -1,13 +1,13 @@
|
||||
package org.session.libsession.utilities
|
||||
|
||||
enum class MediaTypes(val value: String) {
|
||||
IMAGE_PNG("image/png"),
|
||||
IMAGE_JPEG("image/jpeg"),
|
||||
IMAGE_WEBP("image/webp"),
|
||||
IMAGE_GIF("image/gif"),
|
||||
AUDIO_AAC("audio/aac"),
|
||||
AUDIO_UNSPECIFIED("audio/*"),
|
||||
VIDEO_UNSPECIFIED("video/*"),
|
||||
VCARD("text/x-vcard"),
|
||||
LONG_TEXT("text/x-signal-plain")
|
||||
object MediaTypes {
|
||||
const val IMAGE_PNG = "image/png"
|
||||
const val IMAGE_JPEG = "image/jpeg"
|
||||
const val IMAGE_WEBP = "image/webp"
|
||||
const val IMAGE_GIF = "image/gif"
|
||||
const val AUDIO_AAC = "audio/aac"
|
||||
const val AUDIO_UNSPECIFIED = "audio/*"
|
||||
const val VIDEO_UNSPECIFIED = "video/*"
|
||||
const val VCARD = "text/x-vcard"
|
||||
const val LONG_TEXT = "text/x-signal-plain"
|
||||
}
|
@ -98,7 +98,7 @@ public class SettableFuture<T> implements ListenableFuture<T> {
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
while (!completed && System.currentTimeMillis() - startTime > unit.toMillis(timeout)) {
|
||||
while (!completed && System.currentTimeMillis() - startTime < unit.toMillis(timeout)) {
|
||||
wait(unit.toMillis(timeout));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user