Update explore navigation

pull/554/head
Koitharu 3 years ago
parent b093a885c9
commit b928c4123c
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -1,6 +1,7 @@
package org.koitharu.kotatsu.explore.ui package org.koitharu.kotatsu.explore.ui
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem 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.search.ui.MangaListActivity
import org.koitharu.kotatsu.settings.SettingsActivity import org.koitharu.kotatsu.settings.SettingsActivity
import org.koitharu.kotatsu.settings.newsources.NewSourcesDialogFragment import org.koitharu.kotatsu.settings.newsources.NewSourcesDialogFragment
import org.koitharu.kotatsu.settings.sources.catalog.SourcesCatalogActivity
import org.koitharu.kotatsu.suggestions.ui.SuggestionsActivity import org.koitharu.kotatsu.suggestions.ui.SuggestionsActivity
import javax.inject.Inject import javax.inject.Inject
@ -109,7 +111,7 @@ class ExploreFragment :
} }
override fun onListHeaderClick(item: ListHeader, view: View) { override fun onListHeaderClick(item: ListHeader, view: View) {
startActivity(SettingsActivity.newManageSourcesIntent(view.context)) startActivity(Intent(view.context, SourcesCatalogActivity::class.java))
} }
override fun onPrimaryButtonClick(tipView: TipView) { override fun onPrimaryButtonClick(tipView: TipView) {

@ -6,6 +6,7 @@ import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import org.koitharu.kotatsu.R import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.settings.SettingsActivity
class ExploreMenuProvider( class ExploreMenuProvider(
private val context: Context, private val context: Context,
@ -23,6 +24,11 @@ class ExploreMenuProvider(
true true
} }
R.id.action_manage -> {
context.startActivity(SettingsActivity.newManageSourcesIntent(context))
true
}
else -> false else -> false
} }
} }

@ -137,7 +137,7 @@ class ExploreViewModel @Inject constructor(
result += RecommendationsItem(recommendation) result += RecommendationsItem(recommendation)
} }
if (sources.isNotEmpty()) { if (sources.isNotEmpty()) {
result += ListHeader(R.string.remote_sources, R.string.manage) result += ListHeader(R.string.remote_sources, R.string.catalog)
if (newSources.isNotEmpty()) { if (newSources.isNotEmpty()) {
result += TipModel( result += TipModel(
key = TIP_NEW_SOURCES, key = TIP_NEW_SOURCES,

@ -86,7 +86,7 @@ class SourcesManageFragment :
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activity?.setTitle(R.string.remote_sources) activity?.setTitle(R.string.manage_sources)
} }
override fun onDestroyView() { override fun onDestroyView() {

@ -31,6 +31,7 @@ class SourcesCatalogViewModel @Inject constructor(
) : BaseViewModel() { ) : BaseViewModel() {
private val lifecycle = RetainedLifecycleImpl() private val lifecycle = RetainedLifecycleImpl()
private var searchQuery: String = ""
val onActionDone = MutableEventFlow<ReversibleAction>() val onActionDone = MutableEventFlow<ReversibleAction>()
val contentType = MutableStateFlow(ContentType.entries.first()) val contentType = MutableStateFlow(ContentType.entries.first())
val locales = getLocalesImpl() val locales = getLocalesImpl()
@ -40,7 +41,9 @@ class SourcesCatalogViewModel @Inject constructor(
locale, locale,
contentType, contentType,
) { lc, type -> ) { lc, type ->
listProducerFactory.create(lc, type, lifecycle) listProducerFactory.create(lc, type, lifecycle).also {
it.setQuery(searchQuery)
}
}.stateIn(viewModelScope, SharingStarted.Eagerly, null) }.stateIn(viewModelScope, SharingStarted.Eagerly, null)
val content = listProducer.flatMapLatest { val content = listProducer.flatMapLatest {
@ -53,6 +56,7 @@ class SourcesCatalogViewModel @Inject constructor(
} }
fun performSearch(query: String) { fun performSearch(query: String) {
searchQuery = query
listProducer.value?.setQuery(query) listProducer.value?.setQuery(query)
} }

@ -8,4 +8,9 @@
android:title="@string/show_in_grid_view" android:title="@string/show_in_grid_view"
android:titleCondensed="@string/grid" /> android:titleCondensed="@string/grid" />
<item
android:id="@+id/action_manage"
android:title="@string/manage_sources"
android:titleCondensed="@string/manage" />
</menu> </menu>

@ -521,4 +521,6 @@
<string name="source_enabled">Source enabled</string> <string name="source_enabled">Source enabled</string>
<string name="no_manga_sources_catalog_text">No available sources in this section yet. Stay tuned</string> <string name="no_manga_sources_catalog_text">No available sources in this section yet. Stay tuned</string>
<string name="no_manga_sources_found">No available manga sources found by your query</string> <string name="no_manga_sources_found">No available manga sources found by your query</string>
<string name="catalog">Catalog</string>
<string name="manage_sources">Manage sources</string>
</resources> </resources>

Loading…
Cancel
Save