Fix ignoring external sources in global search
This commit is contained in:
@@ -61,7 +61,13 @@ class MangaSourcesRepository @Inject constructor(
|
|||||||
suspend fun getEnabledSources(): List<MangaSource> {
|
suspend fun getEnabledSources(): List<MangaSource> {
|
||||||
assimilateNewSources()
|
assimilateNewSources()
|
||||||
val order = settings.sourcesSortOrder
|
val order = settings.sourcesSortOrder
|
||||||
return dao.findAllEnabled(order).toSources(settings.isNsfwContentDisabled, order)
|
return dao.findAllEnabled(order).toSources(settings.isNsfwContentDisabled, order).let { enabled ->
|
||||||
|
val external = getExternalSources()
|
||||||
|
val list = ArrayList<MangaSourceInfo>(enabled.size + external.size)
|
||||||
|
external.mapTo(list) { MangaSourceInfo(it, isEnabled = true, isPinned = true) }
|
||||||
|
list.addAll(enabled)
|
||||||
|
list
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getPinnedSources(): Set<MangaSource> {
|
suspend fun getPinnedSources(): Set<MangaSource> {
|
||||||
@@ -308,8 +314,6 @@ class MangaSourcesRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun observeExternalSources(): Flow<List<ExternalMangaSource>> {
|
private fun observeExternalSources(): Flow<List<ExternalMangaSource>> {
|
||||||
val intent = Intent("app.kotatsu.parser.PROVIDE_MANGA")
|
|
||||||
val pm = context.packageManager
|
|
||||||
return callbackFlow {
|
return callbackFlow {
|
||||||
val receiver = object : BroadcastReceiver() {
|
val receiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
@@ -333,15 +337,19 @@ class MangaSourcesRepository @Inject constructor(
|
|||||||
}.onStart {
|
}.onStart {
|
||||||
emit(null)
|
emit(null)
|
||||||
}.map {
|
}.map {
|
||||||
pm.queryIntentContentProviders(intent, 0).map { resolveInfo ->
|
getExternalSources()
|
||||||
ExternalMangaSource(
|
|
||||||
packageName = resolveInfo.providerInfo.packageName,
|
|
||||||
authority = resolveInfo.providerInfo.authority,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}.distinctUntilChanged()
|
}.distinctUntilChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getExternalSources() = context.packageManager.queryIntentContentProviders(
|
||||||
|
Intent("app.kotatsu.parser.PROVIDE_MANGA"), 0,
|
||||||
|
).map { resolveInfo ->
|
||||||
|
ExternalMangaSource(
|
||||||
|
packageName = resolveInfo.providerInfo.packageName,
|
||||||
|
authority = resolveInfo.providerInfo.authority,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun List<MangaSourceEntity>.toSources(
|
private fun List<MangaSourceEntity>.toSources(
|
||||||
skipNsfwSources: Boolean,
|
skipNsfwSources: Boolean,
|
||||||
sortOrder: SourcesSortOrder?,
|
sortOrder: SourcesSortOrder?,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class UpdatesFragment : MangaListFragment() {
|
|||||||
return when (item.itemId) {
|
return when (item.itemId) {
|
||||||
R.id.action_remove -> {
|
R.id.action_remove -> {
|
||||||
viewModel.remove(controller.snapshot())
|
viewModel.remove(controller.snapshot())
|
||||||
|
mode.finish()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user