mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 13:17:42 +02:00
refactor: enum values() deprecation
This commit is contained in:
@ -69,8 +69,8 @@ class ExportChatMessages : AbstractAction() {
|
||||
context.runOnUiThread {
|
||||
ViewAppearanceHelper.newAlertDialogBuilder(context.mainActivity)
|
||||
.setTitle(context.translation["chat_export.select_export_format"])
|
||||
.setItems(ExportFormat.values().map { it.name }.toTypedArray()) { _, which ->
|
||||
cont.resumeWith(Result.success(ExportFormat.values()[which]))
|
||||
.setItems(ExportFormat.entries.map { it.name }.toTypedArray()) { _, which ->
|
||||
cont.resumeWith(Result.success(ExportFormat.entries[which]))
|
||||
}
|
||||
.setOnCancelListener {
|
||||
cont.resumeWith(Result.success(null))
|
||||
|
@ -18,7 +18,7 @@ enum class BridgeFileType(val value: Int, val fileName: String, val displayName:
|
||||
|
||||
companion object {
|
||||
fun fromValue(value: Int): BridgeFileType? {
|
||||
return values().firstOrNull { it.value == value }
|
||||
return entries.firstOrNull { it.value == value }
|
||||
}
|
||||
}
|
||||
}
|
@ -39,8 +39,8 @@ class ConfigParams(
|
||||
var customTranslationPath: String? = null,
|
||||
var customOptionTranslationPath: String? = null
|
||||
) {
|
||||
val notices get() = _notices?.let { FeatureNotice.values().filter { flag -> it and flag.id != 0 } } ?: emptyList()
|
||||
val flags get() = _flags?.let { ConfigFlag.values().filter { flag -> it and flag.id != 0 } } ?: emptyList()
|
||||
val notices get() = _notices?.let { FeatureNotice.entries.filter { flag -> it and flag.id != 0 } } ?: emptyList()
|
||||
val flags get() = _flags?.let { ConfigFlag.entries.filter { flag -> it and flag.id != 0 } } ?: emptyList()
|
||||
|
||||
fun addNotices(vararg values: FeatureNotice) {
|
||||
this._notices = (this._notices ?: 0) or values.fold(0) { acc, featureNotice -> acc or featureNotice.id }
|
||||
|
@ -14,7 +14,7 @@ class Rules : ConfigContainer() {
|
||||
}
|
||||
|
||||
init {
|
||||
MessagingRuleType.values().toList().filter { it.listMode }.forEach { ruleType ->
|
||||
MessagingRuleType.entries.filter { it.listMode }.forEach { ruleType ->
|
||||
rules[ruleType] = unique(ruleType.key,"whitelist", "blacklist") {
|
||||
customTranslationPath = "rules.properties.${ruleType.key}"
|
||||
customOptionTranslationPath = "rules.modes"
|
||||
|
@ -22,7 +22,7 @@ enum class MediaDownloadSource(
|
||||
companion object {
|
||||
fun fromKey(key: String?): MediaDownloadSource {
|
||||
if (key == null) return NONE
|
||||
return values().find { it.key == key } ?: NONE
|
||||
return entries.find { it.key == key } ?: NONE
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ enum class LogChannel(
|
||||
|
||||
companion object {
|
||||
fun fromChannel(channel: String): LogChannel? {
|
||||
return values().find { it.channel == channel }
|
||||
return entries.find { it.channel == channel }
|
||||
}
|
||||
}
|
||||
}
|
@ -16,15 +16,15 @@ enum class LogLevel(
|
||||
|
||||
companion object {
|
||||
fun fromLetter(letter: String): LogLevel? {
|
||||
return values().find { it.letter == letter }
|
||||
return entries.find { it.letter == letter }
|
||||
}
|
||||
|
||||
fun fromShortName(shortName: String): LogLevel? {
|
||||
return values().find { it.shortName == shortName }
|
||||
return entries.find { it.shortName == shortName }
|
||||
}
|
||||
|
||||
fun fromPriority(priority: Int): LogLevel? {
|
||||
return values().find { it.priority == priority }
|
||||
return entries.find { it.priority == priority }
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ enum class RuleState(
|
||||
WHITELIST("whitelist");
|
||||
|
||||
companion object {
|
||||
fun getByName(name: String) = values().first { it.key == name }
|
||||
fun getByName(name: String) = entries.first { it.key == name }
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ enum class SocialScope(
|
||||
GROUP("group", "group_info/{id}");
|
||||
|
||||
companion object {
|
||||
fun getByName(name: String) = values().first { it.key == name }
|
||||
fun getByName(name: String) = entries.first { it.key == name }
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ enum class MessagingRuleType(
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getByName(name: String) = values().firstOrNull { it.key == name }
|
||||
fun getByName(name: String) = entries.firstOrNull { it.key == name }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,6 @@ enum class WireType(val value: Int) {
|
||||
FIXED32(5);
|
||||
|
||||
companion object {
|
||||
fun fromValue(value: Int) = values().firstOrNull { it.value == value }
|
||||
fun fromValue(value: Int) = entries.firstOrNull { it.value == value }
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ enum class FileType(
|
||||
)
|
||||
|
||||
fun fromString(string: String?): FileType {
|
||||
return values().firstOrNull { it.fileExtension.equals(string, ignoreCase = true) } ?: UNKNOWN
|
||||
return entries.firstOrNull { it.fileExtension.equals(string, ignoreCase = true) } ?: UNKNOWN
|
||||
}
|
||||
|
||||
private fun bytesToHex(bytes: ByteArray): String {
|
||||
|
@ -26,15 +26,15 @@ enum class NotificationType (
|
||||
|
||||
companion object {
|
||||
fun getIncomingValues(): List<NotificationType> {
|
||||
return values().filter { it.isIncoming }.toList()
|
||||
return entries.filter { it.isIncoming }.toList()
|
||||
}
|
||||
|
||||
fun getOutgoingValues(): List<NotificationType> {
|
||||
return values().filter { it.associatedOutgoingContentType != null }.toList()
|
||||
return entries.filter { it.associatedOutgoingContentType != null }.toList()
|
||||
}
|
||||
|
||||
fun fromContentType(contentType: ContentType): NotificationType? {
|
||||
return values().firstOrNull { it.associatedOutgoingContentType == contentType }
|
||||
return entries.firstOrNull { it.associatedOutgoingContentType == contentType }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ enum class ContentType(val id: Int) {
|
||||
|
||||
companion object {
|
||||
fun fromId(i: Int): ContentType {
|
||||
return values().firstOrNull { it.id == i } ?: UNKNOWN
|
||||
return entries.firstOrNull { it.id == i } ?: UNKNOWN
|
||||
}
|
||||
|
||||
fun fromMessageContainer(protoReader: ProtoReader?): ContentType? {
|
||||
@ -165,7 +165,7 @@ enum class FriendLinkType(val value: Int, val shortName: String) {
|
||||
|
||||
companion object {
|
||||
fun fromValue(value: Int): FriendLinkType {
|
||||
return values().firstOrNull { it.value == value } ?: MUTUAL
|
||||
return entries.firstOrNull { it.value == value } ?: MUTUAL
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ class ActionManager(
|
||||
private val actions = mutableMapOf<String, AbstractAction>()
|
||||
|
||||
override fun init() {
|
||||
EnumAction.values().forEach { enumAction ->
|
||||
EnumAction.entries.forEach { enumAction ->
|
||||
actions[enumAction.key] = enumAction.clazz.java.getConstructor().newInstance().apply {
|
||||
this.context = modContext
|
||||
}
|
||||
@ -24,7 +24,7 @@ class ActionManager(
|
||||
|
||||
fun onNewIntent(intent: Intent?) {
|
||||
val action = intent?.getStringExtra(ACTION_PARAMETER) ?: return
|
||||
execute(EnumAction.values().find { it.key == action } ?: return)
|
||||
execute(EnumAction.entries.find { it.key == action } ?: return)
|
||||
intent.removeExtra(ACTION_PARAMETER)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user