Update gradle and kotlin

This commit is contained in:
Koitharu
2023-08-04 15:15:30 +03:00
parent c5c907c8dc
commit 496f3637c4
20 changed files with 42 additions and 45 deletions

View File

@@ -15,7 +15,7 @@ class Migration16To17(context: Context) : Migration(16, 17) {
database.execSQL("CREATE INDEX `index_sources_sort_key` ON `sources` (`sort_key`)")
val hiddenSources = prefs.getStringSet("sources_hidden", null).orEmpty()
val order = prefs.getString("sources_order_2", null)?.split('|').orEmpty()
val sources = MangaSource.values()
val sources = MangaSource.entries
for (source in sources) {
if (source == MangaSource.LOCAL) {
continue

View File

@@ -10,7 +10,7 @@ fun MangaSource.getLocaleTitle(): String? {
}
fun MangaSource(name: String): MangaSource {
MangaSource.values().forEach {
MangaSource.entries.forEach {
if (it.name == name) return it
}
return MangaSource.DUMMY

View File

@@ -4,6 +4,7 @@ import androidx.annotation.StringRes
import androidx.annotation.StyleRes
import com.google.android.material.color.DynamicColors
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.parsers.util.find
enum class ColorScheme(
@StyleRes val styleResId: Int,
@@ -31,7 +32,7 @@ enum class ColorScheme(
}
fun getAvailableList(): List<ColorScheme> {
val list = enumValues<ColorScheme>().toMutableList()
val list = ColorScheme.entries.toMutableList()
if (!DynamicColors.isDynamicColorAvailable()) {
list.remove(MONET)
}
@@ -39,7 +40,7 @@ enum class ColorScheme(
}
fun safeValueOf(name: String): ColorScheme? {
return enumValues<ColorScheme>().find { it.name == name }
return ColorScheme.entries.find(name)
}
}
}

View File

@@ -20,7 +20,7 @@ enum class NetworkPolicy(
fun from(key: String?, default: NetworkPolicy): NetworkPolicy {
val intKey = key?.toIntOrNull() ?: return default
return enumValues<NetworkPolicy>().find { it.key == intKey } ?: default
return NetworkPolicy.entries.find { it.key == intKey } ?: default
}
}
}

View File

@@ -519,7 +519,7 @@ class FastScroller @JvmOverloads constructor(
private fun TypedArray.getBubbleSize(@StyleableRes index: Int, defaultValue: BubbleSize): BubbleSize {
val ordinal = getInt(index, -1)
return BubbleSize.values().getOrNull(ordinal) ?: defaultValue
return BubbleSize.entries.getOrNull(ordinal) ?: defaultValue
}
private fun findValidParent(view: View): ViewGroup? = view.parents.firstNotNullOfOrNull { p ->

View File

@@ -88,7 +88,7 @@ class ScrobblingInfoSheet :
viewModel.updateScrobbling(
index = scrobblerIndex,
rating = requireViewBinding().ratingBar.rating / requireViewBinding().ratingBar.numStars,
status = enumValues<ScrobblingStatus>().getOrNull(position),
status = ScrobblingStatus.entries.getOrNull(position),
)
}
@@ -99,7 +99,7 @@ class ScrobblingInfoSheet :
viewModel.updateScrobbling(
index = scrobblerIndex,
rating = rating / ratingBar.numStars,
status = enumValues<ScrobblingStatus>().getOrNull(requireViewBinding().spinnerStatus.selectedItemPosition),
status = ScrobblingStatus.entries.getOrNull(requireViewBinding().spinnerStatus.selectedItemPosition),
)
}
}

View File

@@ -1,6 +1,7 @@
package org.koitharu.kotatsu.favourites.domain.model
import org.koitharu.kotatsu.parsers.model.MangaSource
import org.koitharu.kotatsu.parsers.util.find
class Cover(
val url: String,
@@ -8,7 +9,7 @@ class Cover(
) {
val mangaSource: MangaSource?
get() = if (source.isEmpty()) null else MangaSource.values().find { it.name == source }
get() = if (source.isEmpty()) null else MangaSource.entries.find(source)
override fun equals(other: Any?): Boolean {
if (this === other) return true

View File

@@ -38,7 +38,7 @@ class FavouritesListMenuProvider(
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
if (menuItem.groupId == R.id.group_order) {
val order = enumValues<SortOrder>()[menuItem.order]
val order = SortOrder.entries[menuItem.order]
viewModel.setSortOrder(order)
return true
}

View File

@@ -23,7 +23,7 @@ class HistoryListMenuProvider(
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.opt_history, menu)
val subMenu = menu.findItem(R.id.action_order)?.subMenu ?: return
for (order in HistoryOrder.values()) {
for (order in HistoryOrder.entries) {
subMenu.add(R.id.group_order, Menu.NONE, order.ordinal, order.titleResId)
}
subMenu.setGroupCheckable(R.id.group_order, true, true)
@@ -31,7 +31,7 @@ class HistoryListMenuProvider(
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
if (menuItem.groupId == R.id.group_order) {
val order = enumValues<HistoryOrder>()[menuItem.order]
val order = HistoryOrder.entries[menuItem.order]
viewModel.setSortOrder(order)
return true
}
@@ -51,7 +51,7 @@ class HistoryListMenuProvider(
}
override fun onPrepareMenu(menu: Menu) {
val order = viewModel.sortOrder.value ?: return
val order = viewModel.sortOrder.value
menu.findItem(R.id.action_order)?.subMenu?.forEach { item ->
if (item.order == order.ordinal) {
item.isChecked = true

View File

@@ -21,7 +21,7 @@ class TypedListSpacingDecoration(
state: RecyclerView.State
) {
val itemType = parent.getChildViewHolder(view)?.itemViewType?.let {
ListItemType.values().getOrNull(it)
ListItemType.entries.getOrNull(it)
}
when (itemType) {
ListItemType.FILTER_SORT,

View File

@@ -9,6 +9,7 @@ import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.model.MangaSource
import org.koitharu.kotatsu.parsers.model.MangaState
import org.koitharu.kotatsu.parsers.model.MangaTag
import org.koitharu.kotatsu.parsers.util.find
import org.koitharu.kotatsu.parsers.util.json.getBooleanOrDefault
import org.koitharu.kotatsu.parsers.util.json.getLongOrDefault
import org.koitharu.kotatsu.parsers.util.json.getStringOrNull
@@ -67,7 +68,7 @@ class MangaIndex(source: String?) {
isNsfw = json.getBooleanOrDefault("nsfw", false),
coverUrl = json.getString("cover"),
state = json.getStringOrNull("state")?.let { stateString ->
MangaState.values().find { it.name == stateString }
MangaState.entries.find(stateString)
},
description = json.getStringOrNull("description"),
tags = json.getJSONArray("tags").mapJSONToSet { x ->

View File

@@ -84,7 +84,7 @@ class ScrobblerConfigViewModel @Inject constructor(
)
}
val grouped = list.groupBy { it.status }
val statuses = enumValues<ScrobblingStatus>()
val statuses = ScrobblingStatus.entries
val result = ArrayList<ListModel>(list.size + statuses.size)
for (st in statuses) {
val subList = grouped[st]
@@ -102,7 +102,7 @@ class ScrobblerConfigViewModel @Inject constructor(
): ScrobblerService {
val serviceId = savedStateHandle.get<Int>(ScrobblerConfigActivity.EXTRA_SERVICE_ID) ?: 0
if (serviceId != 0) {
return enumValues<ScrobblerService>().first { it.id == serviceId }
return ScrobblerService.entries.first { it.id == serviceId }
}
val uri = savedStateHandle.require<Uri>(BaseActivity.EXTRA_DATA)
return when (uri.host) {

View File

@@ -49,7 +49,7 @@ class AppearanceSettingsFragment :
}
}
findPreference<ListPreference>(AppSettings.KEY_LIST_MODE)?.run {
entryValues = ListMode.values().names()
entryValues = ListMode.entries.names()
setDefaultValueCompat(ListMode.GRID.name)
}
findPreference<ActivityListPreference>(AppSettings.KEY_APP_LOCALE)?.run {

View File

@@ -29,12 +29,7 @@ class NetworkSettingsFragment :
addPreferencesFromResource(R.xml.pref_network)
findPreference<Preference>(AppSettings.KEY_PREFETCH_CONTENT)?.isVisible = contentCache.isCachingEnabled
findPreference<ListPreference>(AppSettings.KEY_DOH)?.run {
entryValues = arrayOf(
DoHProvider.NONE,
DoHProvider.GOOGLE,
DoHProvider.CLOUDFLARE,
DoHProvider.ADGUARD,
).names()
entryValues = DoHProvider.entries.names()
setDefaultValueCompat(DoHProvider.NONE.name)
}
bindProxySummary()

View File

@@ -25,18 +25,18 @@ class ReaderSettingsFragment :
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_reader)
findPreference<ListPreference>(AppSettings.KEY_READER_MODE)?.run {
entryValues = ReaderMode.values().names()
entryValues = ReaderMode.entries.names()
setDefaultValueCompat(ReaderMode.STANDARD.name)
}
findPreference<ListPreference>(AppSettings.KEY_READER_BACKGROUND)?.run {
entryValues = ReaderBackground.values().names()
entryValues = ReaderBackground.entries.names()
setDefaultValueCompat(ReaderBackground.DEFAULT.name)
}
findPreference<MultiSelectListPreference>(AppSettings.KEY_READER_SWITCHERS)?.run {
summaryProvider = MultiSummaryProvider(R.string.gestures_only)
}
findPreference<ListPreference>(AppSettings.KEY_ZOOM_MODE)?.run {
entryValues = ZoomMode.values().names()
entryValues = ZoomMode.entries.names()
setDefaultValueCompat(ZoomMode.FIT_CENTER.name)
}
updateReaderModeDependency()

View File

@@ -43,7 +43,7 @@ class UserDataSettingsViewModel @Inject constructor(
private var storageUsageJob: Job? = null
init {
CacheDir.values().forEach {
CacheDir.entries.forEach {
cacheSizes[it] = MutableStateFlow(-1L)
}
launchJob(Dispatchers.Default) {
@@ -52,7 +52,7 @@ class UserDataSettingsViewModel @Inject constructor(
launchJob(Dispatchers.Default) {
feedItemsCount.value = trackingRepository.getLogsCount()
}
CacheDir.values().forEach { cache ->
CacheDir.entries.forEach { cache ->
launchJob(Dispatchers.Default) {
checkNotNull(cacheSizes[cache]).value = storageManager.computeCacheSize(cache)
}