mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Convert SentMediaQuality to kotlin.
This commit is contained in:
committed by
Greyson Parrelli
parent
3a035a1b33
commit
b698daa4cf
@@ -489,11 +489,11 @@ public final class SettingsValues extends SignalStoreValues {
|
||||
}
|
||||
|
||||
public void setSentMediaQuality(@NonNull SentMediaQuality sentMediaQuality) {
|
||||
putInteger(SENT_MEDIA_QUALITY, sentMediaQuality.getCode());
|
||||
putInteger(SENT_MEDIA_QUALITY, sentMediaQuality.code);
|
||||
}
|
||||
|
||||
public @NonNull SentMediaQuality getSentMediaQuality() {
|
||||
return SentMediaQuality.fromCode(getInteger(SENT_MEDIA_QUALITY, SentMediaQuality.STANDARD.getCode()));
|
||||
return SentMediaQuality.fromCode(getInteger(SENT_MEDIA_QUALITY, SentMediaQuality.STANDARD.code));
|
||||
}
|
||||
|
||||
public @NonNull CensorshipCircumventionEnabled getCensorshipCircumventionEnabled() {
|
||||
|
||||
@@ -283,7 +283,7 @@ public class MediaRepository {
|
||||
long size = cursor.getLong(cursor.getColumnIndexOrThrow(Images.Media.SIZE));
|
||||
long duration = !isImage ? cursor.getInt(cursor.getColumnIndexOrThrow(Video.Media.DURATION)) : 0;
|
||||
|
||||
media.add(fixMimeType(context, new Media(uri, mimetype, date, width, height, size, duration, false, false, bucketId, null, TransformProperties.forSentMediaQuality(SignalStore.settings().getSentMediaQuality().getCode()), null)));
|
||||
media.add(fixMimeType(context, new Media(uri, mimetype, date, width, height, size, duration, false, false, bucketId, null, TransformProperties.forSentMediaQuality(SignalStore.settings().getSentMediaQuality().code), null)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import static org.thoughtcrime.securesms.database.TransformPropertiesUtilKt.tran
|
||||
|
||||
|
||||
/**
|
||||
* Add a {@link SentMediaQuality} value for {@link TransformProperties#getSentMediaQuality()} on the
|
||||
* Add a {@link SentMediaQuality} value for {@link TransformProperties#sentMediaQuality} on the
|
||||
* transformed media. Safe to use in a pipeline with other transforms.
|
||||
*/
|
||||
public final class SentMediaQualityTransform implements MediaTransform {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package org.thoughtcrime.securesms.mms;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Quality levels to send media at.
|
||||
*/
|
||||
public enum SentMediaQuality {
|
||||
STANDARD(0, R.string.DataAndStorageSettingsFragment__standard),
|
||||
HIGH(1, R.string.DataAndStorageSettingsFragment__high);
|
||||
|
||||
|
||||
private final int code;
|
||||
private final int label;
|
||||
|
||||
SentMediaQuality(int code, @StringRes int label) {
|
||||
this.code = code;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static @NonNull SentMediaQuality fromCode(int code) {
|
||||
if (HIGH.code == code) {
|
||||
return HIGH;
|
||||
}
|
||||
return STANDARD;
|
||||
}
|
||||
|
||||
public static @NonNull String[] getLabels(@NonNull Context context) {
|
||||
return Arrays.stream(values()).map(q -> context.getString(q.label)).toArray(String[]::new);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.thoughtcrime.securesms.mms
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.StringRes
|
||||
import org.thoughtcrime.securesms.R
|
||||
|
||||
/**
|
||||
* Quality levels to send media at.
|
||||
*/
|
||||
enum class SentMediaQuality(@JvmField val code: Int, @param:StringRes private val label: Int) {
|
||||
STANDARD(0, R.string.DataAndStorageSettingsFragment__standard),
|
||||
HIGH(1, R.string.DataAndStorageSettingsFragment__high);
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromCode(code: Int): SentMediaQuality {
|
||||
return if (HIGH.code == code) {
|
||||
HIGH
|
||||
} else {
|
||||
STANDARD
|
||||
}
|
||||
}
|
||||
|
||||
fun getLabels(context: Context): Array<String> {
|
||||
return entries.map { context.getString(it.label) }.toTypedArray()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public final class SlideFactory {
|
||||
case IMAGE: return new ImageSlide(context, uri, mimeType, dataSize, width, height, false, null, blurHash, transformProperties);
|
||||
case GIF: return new GifSlide(context, uri, dataSize, width, height);
|
||||
case AUDIO: return new AudioSlide(context, uri, dataSize, false);
|
||||
case VIDEO: return new VideoSlide(context, uri, dataSize, gif, null, TransformProperties.forSentMediaQuality(transformProperties != null ? transformProperties.sentMediaQuality : SentMediaQuality.STANDARD.getCode()));
|
||||
case VIDEO: return new VideoSlide(context, uri, dataSize, gif, null, TransformProperties.forSentMediaQuality(transformProperties != null ? transformProperties.sentMediaQuality : SentMediaQuality.STANDARD.code));
|
||||
case VCARD:
|
||||
case DOCUMENT: return new DocumentSlide(context, uri, mimeType, dataSize, fileName);
|
||||
default: throw new AssertionError("unrecognized enum");
|
||||
|
||||
@@ -354,7 +354,7 @@ public final class MultiShareSender {
|
||||
private static Slide ensureDefaultQuality(@NonNull Context context, @NonNull ImageSlide imageSlide) {
|
||||
Attachment attachment = imageSlide.asAttachment();
|
||||
final TransformProperties transformProperties = attachment.transformProperties;
|
||||
if (transformProperties != null && transformProperties.sentMediaQuality == SentMediaQuality.HIGH.getCode()) {
|
||||
if (transformProperties != null && transformProperties.sentMediaQuality == SentMediaQuality.HIGH.code) {
|
||||
return new ImageSlide(
|
||||
context,
|
||||
attachment.getUri(),
|
||||
|
||||
Reference in New Issue
Block a user