From b928c4123cd23fdd9610bd775fd0824fdd2462b9 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 12 Nov 2023 13:15:30 +0200 Subject: [PATCH] Update explore navigation --- .../org/koitharu/kotatsu/explore/ui/ExploreFragment.kt | 4 +++- .../org/koitharu/kotatsu/explore/ui/ExploreMenuProvider.kt | 6 ++++++ .../org/koitharu/kotatsu/explore/ui/ExploreViewModel.kt | 2 +- .../kotatsu/settings/sources/SourcesManageFragment.kt | 2 +- .../settings/sources/catalog/SourcesCatalogViewModel.kt | 6 +++++- app/src/main/res/menu/opt_explore.xml | 5 +++++ app/src/main/res/values/strings.xml | 2 ++ 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt index 49350c2b2..3632bf345 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreFragment.kt @@ -1,6 +1,7 @@ package org.koitharu.kotatsu.explore.ui import android.content.DialogInterface +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.MenuItem @@ -46,6 +47,7 @@ import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.search.ui.MangaListActivity import org.koitharu.kotatsu.settings.SettingsActivity import org.koitharu.kotatsu.settings.newsources.NewSourcesDialogFragment +import org.koitharu.kotatsu.settings.sources.catalog.SourcesCatalogActivity import org.koitharu.kotatsu.suggestions.ui.SuggestionsActivity import javax.inject.Inject @@ -109,7 +111,7 @@ class ExploreFragment : } override fun onListHeaderClick(item: ListHeader, view: View) { - startActivity(SettingsActivity.newManageSourcesIntent(view.context)) + startActivity(Intent(view.context, SourcesCatalogActivity::class.java)) } override fun onPrimaryButtonClick(tipView: TipView) { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreMenuProvider.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreMenuProvider.kt index 1151b00de..96689878b 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreMenuProvider.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/ExploreMenuProvider.kt @@ -6,6 +6,7 @@ import android.view.MenuInflater import android.view.MenuItem import androidx.core.view.MenuProvider import org.koitharu.kotatsu.R +import org.koitharu.kotatsu.settings.SettingsActivity class ExploreMenuProvider( private val context: Context, @@ -23,6 +24,11 @@ class ExploreMenuProvider( true } + R.id.action_manage -> { + context.startActivity(SettingsActivity.newManageSourcesIntent(context)) + true + } + else -> false } } 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 14836b6d4..3beb078ef 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 @@ -137,7 +137,7 @@ class ExploreViewModel @Inject constructor( result += RecommendationsItem(recommendation) } if (sources.isNotEmpty()) { - result += ListHeader(R.string.remote_sources, R.string.manage) + result += ListHeader(R.string.remote_sources, R.string.catalog) if (newSources.isNotEmpty()) { result += TipModel( key = TIP_NEW_SOURCES, diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourcesManageFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourcesManageFragment.kt index 9a7cb22d5..1cc4083f3 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourcesManageFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourcesManageFragment.kt @@ -86,7 +86,7 @@ class SourcesManageFragment : override fun onResume() { super.onResume() - activity?.setTitle(R.string.remote_sources) + activity?.setTitle(R.string.manage_sources) } override fun onDestroyView() { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/catalog/SourcesCatalogViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/catalog/SourcesCatalogViewModel.kt index 08aa0f5a8..9eb9b763f 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/catalog/SourcesCatalogViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/catalog/SourcesCatalogViewModel.kt @@ -31,6 +31,7 @@ class SourcesCatalogViewModel @Inject constructor( ) : BaseViewModel() { private val lifecycle = RetainedLifecycleImpl() + private var searchQuery: String = "" val onActionDone = MutableEventFlow() val contentType = MutableStateFlow(ContentType.entries.first()) val locales = getLocalesImpl() @@ -40,7 +41,9 @@ class SourcesCatalogViewModel @Inject constructor( locale, contentType, ) { lc, type -> - listProducerFactory.create(lc, type, lifecycle) + listProducerFactory.create(lc, type, lifecycle).also { + it.setQuery(searchQuery) + } }.stateIn(viewModelScope, SharingStarted.Eagerly, null) val content = listProducer.flatMapLatest { @@ -53,6 +56,7 @@ class SourcesCatalogViewModel @Inject constructor( } fun performSearch(query: String) { + searchQuery = query listProducer.value?.setQuery(query) } diff --git a/app/src/main/res/menu/opt_explore.xml b/app/src/main/res/menu/opt_explore.xml index 67f6f9617..63a51f4ea 100644 --- a/app/src/main/res/menu/opt_explore.xml +++ b/app/src/main/res/menu/opt_explore.xml @@ -8,4 +8,9 @@ android:title="@string/show_in_grid_view" android:titleCondensed="@string/grid" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7fe845d30..0fd0c1181 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -521,4 +521,6 @@ Source enabled No available sources in this section yet. Stay tuned No available manga sources found by your query + Catalog + Manage sources