mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Convert SentMediaQuality to kotlin.
This commit is contained in:
committed by
Greyson Parrelli
parent
3a035a1b33
commit
b698daa4cf
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user