Fix default value for some preferences
This commit is contained in:
@@ -30,7 +30,10 @@ class ChaptersAdapter(
|
||||
return oldItem.chapter.id == newItem.chapter.id
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: ChapterListItem, newItem: ChapterListItem): Boolean {
|
||||
override fun areContentsTheSame(
|
||||
oldItem: ChapterListItem,
|
||||
newItem: ChapterListItem
|
||||
): Boolean {
|
||||
return Intrinsics.areEqual(oldItem, newItem)
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,11 @@ class HistoryListViewModel(
|
||||
settings.historyGrouping = isGroupingEnabled
|
||||
}
|
||||
|
||||
private fun mapList(list: List<MangaWithHistory>, grouped: Boolean, mode: ListMode): List<ListModel> {
|
||||
private fun mapList(
|
||||
list: List<MangaWithHistory>,
|
||||
grouped: Boolean,
|
||||
mode: ListMode
|
||||
): List<ListModel> {
|
||||
val result = ArrayList<ListModel>(if (grouped) (list.size * 1.4).toInt() else list.size)
|
||||
var prevDate: DateTimeAgo? = null
|
||||
for ((manga, history) in list) {
|
||||
|
||||
@@ -30,17 +30,18 @@ fun Manga.toGridModel() = MangaGridModel(
|
||||
manga = this
|
||||
)
|
||||
|
||||
fun List<Manga>.toUi(mode: ListMode): List<ListModel> = when(mode) {
|
||||
fun List<Manga>.toUi(mode: ListMode): List<ListModel> = when (mode) {
|
||||
ListMode.LIST -> map(Manga::toListModel)
|
||||
ListMode.DETAILED_LIST -> map(Manga::toListDetailedModel)
|
||||
ListMode.GRID -> map(Manga::toGridModel)
|
||||
}
|
||||
|
||||
fun <C : MutableCollection<ListModel>> List<Manga>.toUi(destination: C, mode: ListMode): C = when(mode) {
|
||||
ListMode.LIST -> mapTo(destination, Manga::toListModel)
|
||||
ListMode.DETAILED_LIST -> mapTo(destination, Manga::toListDetailedModel)
|
||||
ListMode.GRID -> mapTo(destination, Manga::toGridModel)
|
||||
}
|
||||
fun <C : MutableCollection<ListModel>> List<Manga>.toUi(destination: C, mode: ListMode): C =
|
||||
when (mode) {
|
||||
ListMode.LIST -> mapTo(destination, Manga::toListModel)
|
||||
ListMode.DETAILED_LIST -> mapTo(destination, Manga::toListDetailedModel)
|
||||
ListMode.GRID -> mapTo(destination, Manga::toGridModel)
|
||||
}
|
||||
|
||||
fun Throwable.toErrorState(canRetry: Boolean = true) = ErrorState(
|
||||
exception = this,
|
||||
|
||||
@@ -23,10 +23,7 @@ import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.core.prefs.ListMode
|
||||
import org.koitharu.kotatsu.settings.utils.MultiSummaryProvider
|
||||
import org.koitharu.kotatsu.tracker.work.TrackWorker
|
||||
import org.koitharu.kotatsu.utils.ext.getStorageName
|
||||
import org.koitharu.kotatsu.utils.ext.md5
|
||||
import org.koitharu.kotatsu.utils.ext.names
|
||||
import org.koitharu.kotatsu.utils.ext.viewLifecycleScope
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
import java.io.File
|
||||
|
||||
|
||||
@@ -43,24 +40,20 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
true
|
||||
}
|
||||
}
|
||||
preferenceScreen?.findPreference<ListPreference>(AppSettings.KEY_ZOOM_MODE)?.run {
|
||||
entryValues = ZoomMode.values().names()
|
||||
setDefaultValueCompat(ZoomMode.FIT_CENTER.name)
|
||||
}
|
||||
preferenceScreen?.findPreference<ListPreference>(AppSettings.KEY_LIST_MODE)?.run {
|
||||
entryValues = ListMode.values().names()
|
||||
setDefaultValueCompat(ListMode.GRID.name)
|
||||
}
|
||||
findPreference<MultiSelectListPreference>(AppSettings.KEY_READER_SWITCHERS)?.summaryProvider =
|
||||
MultiSummaryProvider(R.string.gestures_only)
|
||||
findPreference<MultiSelectListPreference>(AppSettings.KEY_TRACK_SOURCES)?.summaryProvider =
|
||||
MultiSummaryProvider(R.string.dont_check)
|
||||
}
|
||||
|
||||
override fun setPreferenceScreen(preferenceScreen: PreferenceScreen?) {
|
||||
preferenceScreen?.findPreference<ListPreference>(AppSettings.KEY_ZOOM_MODE)?.run {
|
||||
entryValues = ZoomMode.values().names()
|
||||
setDefaultValue(ZoomMode.FIT_CENTER.name)
|
||||
}
|
||||
preferenceScreen?.findPreference<ListPreference>(AppSettings.KEY_LIST_MODE)?.run {
|
||||
entryValues = ListMode.values().names()
|
||||
setDefaultValue(ListMode.GRID.name)
|
||||
}
|
||||
super.setPreferenceScreen(preferenceScreen)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
findPreference<Preference>(AppSettings.KEY_APP_UPDATE_AUTO)?.run {
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.koitharu.kotatsu.core.model.ZoomMode
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.settings.utils.MultiSummaryProvider
|
||||
import org.koitharu.kotatsu.utils.ext.names
|
||||
import org.koitharu.kotatsu.utils.ext.setDefaultValueCompat
|
||||
|
||||
class ReaderSettingsFragment : BasePreferenceFragment(R.string.reader_settings) {
|
||||
|
||||
@@ -19,7 +20,7 @@ class ReaderSettingsFragment : BasePreferenceFragment(R.string.reader_settings)
|
||||
}
|
||||
findPreference<ListPreference>(AppSettings.KEY_ZOOM_MODE)?.let {
|
||||
it.entryValues = ZoomMode.values().names()
|
||||
it.setDefaultValue(ZoomMode.FIT_CENTER.name)
|
||||
it.setDefaultValueCompat(ZoomMode.FIT_CENTER.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import androidx.preference.ListPreference
|
||||
|
||||
fun ListPreference.setDefaultValueCompat(defaultValue: String) {
|
||||
if (value == null) {
|
||||
value = defaultValue
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
android:padding="4dp">
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@null"
|
||||
android:id="@+id/imageView_icon"
|
||||
tools:src="@drawable/ic_alert_outline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
tools:src="@drawable/ic_alert_outline" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/list_footer_height"
|
||||
android:padding="6dp">
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="grid_spacing">5dp</dimen>
|
||||
<dimen name="manga_list_item_height">84dp</dimen>
|
||||
<dimen name="manga_list_details_item_height">120dp</dimen>
|
||||
<dimen name="chapter_list_item_height">46dp</dimen>
|
||||
<dimen name="preferred_grid_width">120dp</dimen>
|
||||
<dimen name="manga_list_item_height">84dp</dimen>
|
||||
<dimen name="manga_list_details_item_height">120dp</dimen>
|
||||
<dimen name="chapter_list_item_height">46dp</dimen>
|
||||
<dimen name="preferred_grid_width">120dp</dimen>
|
||||
<dimen name="header_height">34dp</dimen>
|
||||
<dimen name="elevation_large">16dp</dimen>
|
||||
<dimen name="list_footer_height">48dp</dimen>
|
||||
|
||||
Reference in New Issue
Block a user