Batch select sources for pre migrations
Select none/all, pinned sources, enabled sources from the list (cherry picked from commit 59c2da3f91052dfb0a292cb23ccb9d39055aadc7) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/PreMigrationController.kt # app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt # app/src/main/res/drawable/ic_select_all_24dp.xml # app/src/main/res/values/strings.xml
This commit is contained in:
+47
-8
@@ -2,6 +2,9 @@ package eu.kanade.tachiyomi.ui.migration.manga.design
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
@@ -19,7 +22,6 @@ import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
|
||||
import exh.util.applyWindowInsetsForController
|
||||
import exh.util.doOnApplyWindowInsets
|
||||
import exh.util.marginBottom
|
||||
import exh.util.updateLayoutParams
|
||||
@@ -42,7 +44,7 @@ class PreMigrationController(bundle: Bundle? = null) :
|
||||
|
||||
private var dialog: BottomSheetDialog? = null
|
||||
|
||||
override fun getTitle() = "Select target sources"
|
||||
override fun getTitle() = view?.context?.getString(R.string.select_sources)
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = PreMigrationControllerBinding.inflate(inflater)
|
||||
@@ -51,7 +53,6 @@ class PreMigrationController(bundle: Bundle? = null) :
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
view.applyWindowInsetsForController()
|
||||
|
||||
val ourAdapter = adapter ?: MigrationSourceAdapter(
|
||||
getEnabledSources().map { MigrationSourceItem(it, isEnabled(it.id.toString())) },
|
||||
@@ -70,11 +71,15 @@ class PreMigrationController(bundle: Bundle? = null) :
|
||||
binding.fab.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
// offset the recycler by the fab's inset + some inset on top
|
||||
v.updatePaddingRelative(
|
||||
bottom = padding.bottom + (binding.fab.marginBottom) +
|
||||
fabBaseMarginBottom + (binding.fab.height)
|
||||
)
|
||||
v.post {
|
||||
// offset the recycler by the fab's inset + some inset on top
|
||||
v.updatePaddingRelative(
|
||||
bottom = insets.systemWindowInsetBottom + (
|
||||
binding.fab.marginBottom
|
||||
?: 0
|
||||
) + (binding.fab.height ?: 0)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
binding.fab.setOnClickListener {
|
||||
@@ -159,6 +164,40 @@ class PreMigrationController(bundle: Bundle? = null) :
|
||||
else sourcesSaved.split("/").contains(id)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.pre_migration, menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_select_all, R.id.action_select_none -> {
|
||||
adapter?.currentItems?.forEach {
|
||||
it.sourceEnabled = item.itemId == R.id.action_select_all
|
||||
}
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
R.id.action_match_enabled, R.id.action_match_pinned -> {
|
||||
val enabledSources = if (item.itemId == R.id.action_match_enabled) {
|
||||
prefs.hiddenCatalogues().get().mapNotNull { it.toLongOrNull() }
|
||||
} else {
|
||||
prefs.pinnedCatalogues().get().mapNotNull { it.toLongOrNull() }
|
||||
}
|
||||
val items = adapter?.currentItems?.toList() ?: return true
|
||||
items.forEach {
|
||||
it.sourceEnabled = if (item.itemId == R.id.action_match_enabled) {
|
||||
it.source.id !in enabledSources
|
||||
} else {
|
||||
it.source.id in enabledSources
|
||||
}
|
||||
}
|
||||
val sortedItems = items.sortedBy { it.source.name }.sortedBy { !it.sourceEnabled }
|
||||
adapter?.updateDataSet(sortedItems)
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MANGA_IDS_EXTRA = "manga_ids"
|
||||
|
||||
|
||||
-2
@@ -37,7 +37,6 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.smartsearch.SmartSearchEngine
|
||||
import exh.util.RecyclerWindowInsetsListener
|
||||
import exh.util.applyWindowInsetsForController
|
||||
import exh.util.await
|
||||
import exh.util.executeOnIO
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
@@ -96,7 +95,6 @@ class MigrationListController(bundle: Bundle? = null) :
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
view.applyWindowInsetsForController()
|
||||
setTitle()
|
||||
val config = this.config ?: return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user