diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/TipView.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/TipView.kt index 362a13ba0..a481f156b 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/TipView.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/TipView.kt @@ -75,7 +75,7 @@ class TipView @JvmOverloads constructor( icon = getDrawableCompat(context, R.styleable.TipView_icon) primaryButtonText = getString(R.styleable.TipView_primaryButtonText) secondaryButtonText = getString(R.styleable.TipView_secondaryButtonText) - val shapeAppearanceModel = ShapeAppearanceModel.builder(context, attrs, defStyleAttr, 0).setAllCornerSizes(12f).build() + val shapeAppearanceModel = ShapeAppearanceModel.builder(context, attrs, defStyleAttr, 0).build() background = MaterialShapeDrawable(shapeAppearanceModel).also { it.fillColor = getColorStateList(R.styleable.TipView_cardBackgroundColor) ?: context.getThemeColorStateList(materialR.attr.colorBackgroundFloating) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreViewModel.kt index 0f163d92f..128c2ef0a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreViewModel.kt @@ -25,6 +25,7 @@ import org.koitharu.kotatsu.explore.domain.ExploreRepository import org.koitharu.kotatsu.explore.ui.model.ExploreItem import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaSource +import org.koitharu.kotatsu.parsers.model.MangaState import javax.inject.Inject private const val TIP_SUGGESTIONS = "suggestions" @@ -102,6 +103,26 @@ class ExploreViewModel @Inject constructor( result += ExploreItem.Buttons( isSuggestionsEnabled = settings.isSuggestionsEnabled, ) + result += ExploreItem.Header(R.string.suggestions, isButtonVisible = false) + result += ExploreItem.Recommendation( + Manga( + 0, + "Test", + "Test", + "Test", + "Test", + 0f, + false, + "http://images.ctfassets.net/yadj1kx9rmg0/wtrHxeu3zEoEce2MokCSi/cf6f68efdcf625fdc060607df0f3baef/quwowooybuqbl6ntboz3.jpg", + emptySet(), + MangaState.ONGOING, + "Test", + "http://images.ctfassets.net/yadj1kx9rmg0/wtrHxeu3zEoEce2MokCSi/cf6f68efdcf625fdc060607df0f3baef/quwowooybuqbl6ntboz3.jpg", + "Test", + emptyList(), + MangaSource.DESUME, + ), + ) // TODO result += ExploreItem.Header(R.string.remote_sources, sources.isNotEmpty()) if (sources.isNotEmpty()) { sources.mapTo(result) { ExploreItem.Source(it, isGrid) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapter.kt index f8386cda1..111611cc0 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapter.kt @@ -16,6 +16,8 @@ class ExploreAdapter( init { delegatesManager .addDelegate(ITEM_TYPE_BUTTONS, exploreButtonsAD(listener)) + .addDelegate(ITEM_TYPE_RECOMMENDATION_HEADER, exploreRecommendationHeaderAD()) + .addDelegate(ITEM_TYPE_RECOMMENDATION, exploreRecommendationItemAD(coil, lifecycleOwner)) .addDelegate(ITEM_TYPE_HEADER, exploreSourcesHeaderAD(listener)) .addDelegate(ITEM_TYPE_SOURCE_LIST, exploreSourceListItemAD(coil, clickListener, lifecycleOwner)) .addDelegate(ITEM_TYPE_SOURCE_GRID, exploreSourceGridItemAD(coil, clickListener, lifecycleOwner)) @@ -31,5 +33,7 @@ class ExploreAdapter( const val ITEM_TYPE_SOURCE_GRID = 3 const val ITEM_TYPE_HINT = 4 const val ITEM_TYPE_LOADING = 5 + const val ITEM_TYPE_RECOMMENDATION_HEADER = 6 + const val ITEM_TYPE_RECOMMENDATION = 7 } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt index c440e322a..fd4601588 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt @@ -21,6 +21,7 @@ import org.koitharu.kotatsu.databinding.ItemExploreButtonsBinding import org.koitharu.kotatsu.databinding.ItemExploreSourceGridBinding import org.koitharu.kotatsu.databinding.ItemExploreSourceListBinding import org.koitharu.kotatsu.databinding.ItemHeaderButtonBinding +import org.koitharu.kotatsu.databinding.ItemRecommendationBinding import org.koitharu.kotatsu.explore.ui.model.ExploreItem import org.koitharu.kotatsu.list.ui.adapter.ListStateHolderListener @@ -42,6 +43,37 @@ fun exploreButtonsAD( //} } +fun exploreRecommendationHeaderAD() = adapterDelegateViewBinding( + { layoutInflater, parent -> ItemHeaderButtonBinding.inflate(layoutInflater, parent, false) } +) { + + bind { + binding.textViewTitle.setText(item.titleResId) + binding.buttonMore.isVisible = false + } +} + +fun exploreRecommendationItemAD( + coil: ImageLoader, + lifecycleOwner: LifecycleOwner, +) = adapterDelegateViewBinding( + { layoutInflater, parent -> ItemRecommendationBinding.inflate(layoutInflater, parent, false) } +) { + + bind { + binding.textViewTitle.text = item.manga.title + binding.textViewSubtitle.text = item.manga.title + binding.imageViewCover.newImageRequest(lifecycleOwner, item.manga.coverUrl)?.run { + source(item.manga.source) + enqueueWith(coil) + } + } + + onViewRecycled { + binding.imageViewCover.disposeImageRequest() + } +} + fun exploreSourcesHeaderAD( listener: ExploreListEventListener, ) = adapterDelegateViewBinding( diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/ExploreItem.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/ExploreItem.kt index 9449ee21a..e8abfb0e5 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/ExploreItem.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/ExploreItem.kt @@ -4,6 +4,7 @@ import androidx.annotation.DrawableRes import androidx.annotation.StringRes import org.koitharu.kotatsu.list.ui.model.EmptyState import org.koitharu.kotatsu.list.ui.model.ListModel +import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaSource sealed interface ExploreItem : ListModel { @@ -48,6 +49,25 @@ sealed interface ExploreItem : ListModel { } } + class Recommendation( + val manga: Manga + ) : ExploreItem { + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Recommendation + + return manga == other.manga + } + + override fun hashCode(): Int { + return 31 * manga.hashCode() + } + + } + class Source( val source: MangaSource, val isGrid: Boolean, diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/tools/views/MemoryUsageView.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/tools/views/MemoryUsageView.kt index 544105f35..c73ae6b67 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/tools/views/MemoryUsageView.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/tools/views/MemoryUsageView.kt @@ -41,7 +41,7 @@ class MemoryUsageView @JvmOverloads constructor( fun bind(usage: StorageUsage?) { val storageSegment = SegmentedBarView.Segment(usage?.savedManga?.percent ?: 0f, segmentColor(com.google.android.material.R.attr.colorPrimary)) - val pagesSegment = SegmentedBarView.Segment(usage?.pagesCache?.percent ?: 0f, segmentColor(com.google.android.material.R.attr.colorSecondary)) + val pagesSegment = SegmentedBarView.Segment(usage?.pagesCache?.percent ?: 0f, segmentColor(com.google.android.material.R.attr.colorOnPrimaryContainer)) val otherSegment = SegmentedBarView.Segment(usage?.otherCache?.percent ?: 0f, segmentColor(com.google.android.material.R.attr.colorTertiary)) with(binding) { diff --git a/app/src/main/res/drawable/bg_rounded_square.xml b/app/src/main/res/drawable/bg_rounded_square.xml new file mode 100644 index 000000000..48edee83b --- /dev/null +++ b/app/src/main/res/drawable/bg_rounded_square.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/app/src/main/res/layout/item_recommendation.xml b/app/src/main/res/layout/item_recommendation.xml new file mode 100644 index 000000000..be8db323e --- /dev/null +++ b/app/src/main/res/layout/item_recommendation.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/layout_memory_usage.xml b/app/src/main/res/layout/layout_memory_usage.xml index d1135f812..54bdcc752 100644 --- a/app/src/main/res/layout/layout_memory_usage.xml +++ b/app/src/main/res/layout/layout_memory_usage.xml @@ -49,7 +49,7 @@ android:layout_marginTop="@dimen/margin_normal" android:layout_marginEnd="@dimen/screen_padding" android:text="@string/saved_manga" - app:drawableStartCompat="@drawable/bg_circle" + app:drawableStartCompat="@drawable/bg_rounded_square" tools:drawableTint="?colorPrimary" /> diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml index 0e796d4f9..c62bb5477 100644 --- a/app/src/main/res/values/constants.xml +++ b/app/src/main/res/values/constants.xml @@ -56,10 +56,8 @@ SOCKS - #E480F4 - #6CC3F3 - #7167ED - #D9455F - #6054EA + #6750A4 + #21005E + #7D5260 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 5b6f7a48a..f40da5a33 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -9,7 +9,7 @@