mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Convert some SignalServiceAttachment* classes to kotlin.
This commit is contained in:
committed by
mtang-signal
parent
bb01c0501b
commit
8932eef991
@@ -73,10 +73,10 @@ public final class ImageCompressionUtil {
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Result compress(@NonNull Context context,
|
||||
@NonNull String mimeType,
|
||||
@NonNull Object glideModel,
|
||||
int maxDimension,
|
||||
@IntRange(from = 0, to = 100) int quality)
|
||||
@Nullable String contentType,
|
||||
@NonNull Object glideModel,
|
||||
int maxDimension,
|
||||
@IntRange(from = 0, to = 100) int quality)
|
||||
throws BitmapDecodingException
|
||||
{
|
||||
Bitmap scaledBitmap;
|
||||
@@ -121,16 +121,16 @@ public final class ImageCompressionUtil {
|
||||
}
|
||||
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
Bitmap.CompressFormat format = mimeTypeToCompressFormat(mimeType);
|
||||
Bitmap.CompressFormat format = mimeTypeToCompressFormat(contentType);
|
||||
scaledBitmap.compress(format, quality, output);
|
||||
|
||||
byte[] data = output.toByteArray();
|
||||
|
||||
Log.d(TAG, "[Input] mimeType: " + mimeType + " [Output] format: " + format + ", maxDimension: " + maxDimension + ", quality: " + quality + ", size(KiB): " + new ByteSize(data.length).getInWholeKibiBytes());
|
||||
Log.d(TAG, "[Input] mimeType: " + contentType + " [Output] format: " + format + ", maxDimension: " + maxDimension + ", quality: " + quality + ", size(KiB): " + new ByteSize(data.length).getInWholeKibiBytes());
|
||||
return new Result(data, compressFormatToMimeType(format), scaledBitmap.getWidth(), scaledBitmap.getHeight());
|
||||
}
|
||||
|
||||
private static @NonNull Bitmap.CompressFormat mimeTypeToCompressFormat(@NonNull String mimeType) {
|
||||
private static @NonNull Bitmap.CompressFormat mimeTypeToCompressFormat(@Nullable String mimeType) {
|
||||
if (MediaUtil.isJpegType(mimeType) ||
|
||||
MediaUtil.isHeicType(mimeType) ||
|
||||
MediaUtil.isHeifType(mimeType) ||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class MediaUtil {
|
||||
public static final String UNKNOWN = "*/*";
|
||||
public static final String OCTET = "application/octet-stream";
|
||||
|
||||
public static SlideType getSlideTypeFromContentType(@NonNull String contentType) {
|
||||
public static SlideType getSlideTypeFromContentType(@Nullable String contentType) {
|
||||
if (isGif(contentType)) {
|
||||
return SlideType.GIF;
|
||||
} else if (isImageType(contentType)) {
|
||||
@@ -356,7 +356,7 @@ public class MediaUtil {
|
||||
}
|
||||
|
||||
public static boolean isNonGifVideo(Media media) {
|
||||
return isVideo(media.getMimeType()) && !media.isVideoGif();
|
||||
return isVideo(media.getContentType()) && !media.isVideoGif();
|
||||
}
|
||||
|
||||
public static boolean isImageType(String contentType) {
|
||||
|
||||
@@ -408,9 +408,12 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
||||
public String contentType;
|
||||
public long date;
|
||||
|
||||
public Attachment(@NonNull Uri uri, @NonNull String contentType,
|
||||
long date, @Nullable String fileName)
|
||||
{
|
||||
public Attachment(
|
||||
@NonNull Uri uri,
|
||||
@Nullable String contentType,
|
||||
long date,
|
||||
@Nullable String fileName
|
||||
) {
|
||||
if (uri == null || contentType == null || date < 0) {
|
||||
throw new AssertionError("uri, content type, and date must all be specified");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user