Skip to content

Commit a00eeba

Browse files
GrzegorzBobrykTheTechZone
authored andcommitted
Move from enum.values() to enum.entries.
Resolves signalapp#13767
1 parent 2473a8e commit a00eeba

File tree

60 files changed

+95
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+95
-95
lines changed

app/src/main/java/org/thoughtcrime/securesms/ContactSelectionListAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class ContactSelectionListAdapter(
165165
FIND_BY_PHONE_NUMBER("find-by-phone-number");
166166

167167
companion object {
168-
fun fromCode(code: String) = values().first { it.code == code }
168+
fun fromCode(code: String) = entries.first { it.code == code }
169169
}
170170
}
171171

app/src/main/java/org/thoughtcrime/securesms/attachments/AttachmentCreator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ object AttachmentCreator : Parcelable.Creator<Attachment> {
2323

2424
@JvmStatic
2525
fun writeSubclass(dest: Parcel, instance: Attachment) {
26-
val subclass = Subclass.values().firstOrNull { it.clazz == instance::class.java } ?: error("Unexpected subtype ${instance::class.java.simpleName}")
26+
val subclass = Subclass.entries.firstOrNull { it.clazz == instance::class.java } ?: error("Unexpected subtype ${instance::class.java.simpleName}")
2727
dest.writeString(subclass.code)
2828
}
2929

3030
override fun createFromParcel(source: Parcel): Attachment {
3131
val rawCode = source.readString()!!
3232

33-
return when (Subclass.values().first { rawCode == it.code }) {
33+
return when (Subclass.entries.first { rawCode == it.code }) {
3434
Subclass.DATABASE -> DatabaseAttachment(source)
3535
Subclass.POINTER -> PointerAttachment(source)
3636
Subclass.TOMBSTONE -> TombstoneAttachment(source)

app/src/main/java/org/thoughtcrime/securesms/attachments/Cdn.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum class Cdn(private val value: Int) {
3737
}
3838

3939
override fun deserialize(data: Int): Cdn {
40-
return values().first { it.value == data }
40+
return entries.first { it.value == data }
4141
}
4242

4343
fun fromCdnNumber(cdnNumber: Int): Cdn {

app/src/main/java/org/thoughtcrime/securesms/avatar/Avatars.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object Avatars {
3030
A210("A210", 0xFF5C5C5C.toInt());
3131

3232
fun deserialize(code: String): ForegroundColor {
33-
return values().find { it.code == code } ?: throw IllegalArgumentException()
33+
return entries.find { it.code == code } ?: throw IllegalArgumentException()
3434
}
3535

3636
fun serialize(): String = code
@@ -39,7 +39,7 @@ object Avatars {
3939
/**
4040
* Mapping which associates color codes to ColorPair objects containing background and foreground colors.
4141
*/
42-
val colorMap: Map<String, ColorPair> = ForegroundColor.values().map {
42+
val colorMap: Map<String, ColorPair> = ForegroundColor.entries.map {
4343
ColorPair(AvatarColor.deserialize(it.serialize()), it)
4444
}.associateBy {
4545
it.code
@@ -134,7 +134,7 @@ object Avatars {
134134

135135
@JvmStatic
136136
fun getForegroundColor(avatarColor: AvatarColor): ForegroundColor {
137-
return ForegroundColor.values().firstOrNull { it.serialize() == avatarColor.serialize() } ?: ForegroundColor.A210
137+
return ForegroundColor.entries.firstOrNull { it.serialize() == avatarColor.serialize() } ?: ForegroundColor.A210
138138
}
139139

140140
data class DefaultAvatar(

app/src/main/java/org/thoughtcrime/securesms/badges/glide/BadgeSpriteTransformation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class BadgeSpriteTransformation(
190190
private val TAG = Log.tag(BadgeSpriteTransformation::class.java)
191191

192192
private fun getDensity(density: String): Density {
193-
return Density.values().first { it.density == density }
193+
return Density.entries.first { it.density == density }
194194
}
195195

196196
private fun getFrame(size: Size, density: Density, isDarkTheme: Boolean): Frame {

app/src/main/java/org/thoughtcrime/securesms/components/settings/app/AppSettingsActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class AppSettingsActivity : DSLSettingsActivity(), InAppPaymentComponent {
246246

247247
companion object {
248248
fun fromCode(code: Int?): StartLocation {
249-
return values().find { code == it.code } ?: HOME
249+
return entries.find { code == it.code } ?: HOME
250250
}
251251
}
252252
}

app/src/main/java/org/thoughtcrime/securesms/components/settings/app/backups/remote/RemoteBackupsSettingsFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ private fun BackupFrequencyDialog(
10911091
modifier = Modifier.padding(24.dp)
10921092
)
10931093

1094-
BackupFrequency.values().forEach {
1094+
BackupFrequency.entries.forEach {
10951095
Rows.RadioRow(
10961096
selected = selected == it,
10971097
text = getTextForFrequency(backupsFrequency = it),

app/src/main/java/org/thoughtcrime/securesms/components/settings/app/data/DataAndStorageSettingsFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class DataAndStorageSettingsFragment : DSLSettingsFragment(R.string.preferences_
9393
radioListPref(
9494
title = DSLSettingsText.from(R.string.DataAndStorageSettingsFragment__sent_media_quality),
9595
listItems = sentMediaQualityLabels,
96-
selected = SentMediaQuality.values().indexOf(state.sentMediaQuality),
97-
onSelected = { viewModel.setSentMediaQuality(SentMediaQuality.values()[it]) }
96+
selected = SentMediaQuality.entries.indexOf(state.sentMediaQuality),
97+
onSelected = { viewModel.setSentMediaQuality(SentMediaQuality.entries[it]) }
9898
)
9999

100100
textPref(

app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalPendingOneTimeDonationConfigurationFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private fun Content(
140140
expanded = expanded,
141141
onDismissRequest = { expanded = false }
142142
) {
143-
PendingOneTimeDonation.PaymentMethodType.values().forEach { item ->
143+
PendingOneTimeDonation.PaymentMethodType.entries.forEach { item ->
144144
DropdownMenuItem(
145145
text = { Text(text = item.name) },
146146
onClick = {

app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,19 +516,19 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
516516

517517
radioListPref(
518518
title = DSLSettingsText.from("Audio processing method"),
519-
listItems = CallManager.AudioProcessingMethod.values().map { it.name }.toTypedArray(),
520-
selected = CallManager.AudioProcessingMethod.values().indexOf(state.callingAudioProcessingMethod),
519+
listItems = CallManager.AudioProcessingMethod.entries.map { it.name }.toTypedArray(),
520+
selected = CallManager.AudioProcessingMethod.entries.indexOf(state.callingAudioProcessingMethod),
521521
onSelected = {
522-
viewModel.setInternalCallingAudioProcessingMethod(CallManager.AudioProcessingMethod.values()[it])
522+
viewModel.setInternalCallingAudioProcessingMethod(CallManager.AudioProcessingMethod.entries[it])
523523
}
524524
)
525525

526526
radioListPref(
527527
title = DSLSettingsText.from("Bandwidth mode"),
528-
listItems = CallManager.DataMode.values().map { it.name }.toTypedArray(),
529-
selected = CallManager.DataMode.values().indexOf(state.callingDataMode),
528+
listItems = CallManager.DataMode.entries.map { it.name }.toTypedArray(),
529+
selected = CallManager.DataMode.entries.indexOf(state.callingDataMode),
530530
onSelected = {
531-
viewModel.setInternalCallingDataMode(CallManager.DataMode.values()[it])
531+
viewModel.setInternalCallingDataMode(CallManager.DataMode.entries[it])
532532
}
533533
)
534534

0 commit comments

Comments
 (0)