diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt index b50c472f2..79aac0eb9 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt @@ -37,10 +37,10 @@ import org.koitharu.kotatsu.list.domain.MangaListMapper import org.koitharu.kotatsu.list.domain.QuickFilterListener import org.koitharu.kotatsu.list.ui.MangaListViewModel import org.koitharu.kotatsu.list.ui.model.EmptyState +import org.koitharu.kotatsu.list.ui.model.InfoModel import org.koitharu.kotatsu.list.ui.model.ListHeader import org.koitharu.kotatsu.list.ui.model.ListModel import org.koitharu.kotatsu.list.ui.model.LoadingState -import org.koitharu.kotatsu.list.ui.model.TipModel import org.koitharu.kotatsu.list.ui.model.toErrorState import org.koitharu.kotatsu.local.data.LocalMangaRepository import org.koitharu.kotatsu.parsers.model.Manga @@ -175,13 +175,11 @@ class HistoryListViewModel @Inject constructor( val result = ArrayList((if (grouped) (list.size * 1.4).toInt() else list.size) + 2) result += quickFilter.filterItem(filters) if (isIncognito) { - result += TipModel( + result += InfoModel( key = AppSettings.KEY_INCOGNITO_MODE, title = R.string.incognito_mode, text = R.string.incognito_mode_hint, icon = R.drawable.ic_incognito, - primaryButtonText = 0, - secondaryButtonText = 0, ) } val order = sortOrder.value diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/InfoAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/InfoAD.kt new file mode 100644 index 000000000..f00d899df --- /dev/null +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/InfoAD.kt @@ -0,0 +1,20 @@ +package org.koitharu.kotatsu.list.ui.adapter + +import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding +import org.koitharu.kotatsu.core.util.ext.setTextAndVisible +import org.koitharu.kotatsu.databinding.ItemInfoBinding +import org.koitharu.kotatsu.list.ui.model.InfoModel +import org.koitharu.kotatsu.list.ui.model.ListModel + +fun infoAD() = adapterDelegateViewBinding( + { layoutInflater, parent -> ItemInfoBinding.inflate(layoutInflater, parent, false) }, +) { + + bind { + binding.textViewTitle.setText(item.title) + binding.textViewBody.setTextAndVisible(item.text) + binding.textViewTitle.setCompoundDrawablesRelativeWithIntrinsicBounds( + item.icon, 0, 0, 0, + ) + } +} diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt index 5ced570e7..a9a6fba62 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/ListItemType.kt @@ -23,6 +23,7 @@ enum class ListItemType { EXPLORE_SOURCE_LIST, EXPLORE_SUGGESTION, TIP, + INFO, HINT_EMPTY, PAGE_THUMB, FEED, diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt index 4589d3467..782fec1f9 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt @@ -26,5 +26,6 @@ open class MangaListAdapter( addDelegate(ListItemType.HEADER, listHeaderAD(listener)) addDelegate(ListItemType.FILTER_HEADER, quickFilterAD(listener)) addDelegate(ListItemType.TIP, tipAD(listener)) + addDelegate(ListItemType.INFO, infoAD()) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt index 39e158d6d..0ed80dcbd 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/TypedListSpacingDecoration.kt @@ -63,6 +63,7 @@ class TypedListSpacingDecoration( ListItemType.CATEGORY_LARGE, ListItemType.NAV_ITEM, ListItemType.CHAPTER_LIST, + ListItemType.INFO, null, -> outRect.set(0) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/model/InfoModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/model/InfoModel.kt new file mode 100644 index 000000000..7defeb0d6 --- /dev/null +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/model/InfoModel.kt @@ -0,0 +1,16 @@ +package org.koitharu.kotatsu.list.ui.model + +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes + +data class InfoModel( + val key: String, + @StringRes val title: Int, + @StringRes val text: Int, + @DrawableRes val icon: Int, +) : ListModel { + + override fun areItemsTheSame(other: ListModel): Boolean { + return other is InfoModel && other.key == key + } +} diff --git a/app/src/main/res/layout/item_info.xml b/app/src/main/res/layout/item_info.xml new file mode 100644 index 000000000..48c51a55d --- /dev/null +++ b/app/src/main/res/layout/item_info.xml @@ -0,0 +1,49 @@ + + + + + + + + + +