mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 16:45:06 +01:00
Batch select sources for pre migrations
Select none/all, pinned sources, enabled sources from the list
This commit is contained in:
parent
a3305171d6
commit
59c2da3f91
@ -2,6 +2,9 @@ package eu.kanade.tachiyomi.ui.migration.manga.design
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
@ -18,9 +21,9 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
|
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
|
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
import eu.kanade.tachiyomi.util.view.expand
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.liftAppbarWith
|
||||||
import eu.kanade.tachiyomi.util.view.marginBottom
|
import eu.kanade.tachiyomi.util.view.marginBottom
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||||
@ -41,7 +44,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
|||||||
|
|
||||||
private var dialog: BottomSheetDialog? = null
|
private var dialog: BottomSheetDialog? = null
|
||||||
|
|
||||||
override fun getTitle() = view?.context?.getString(R.string.select_target_sources)
|
override fun getTitle() = view?.context?.getString(R.string.select_sources)
|
||||||
|
|
||||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||||
return inflater.inflate(R.layout.pre_migration_controller, container, false)
|
return inflater.inflate(R.layout.pre_migration_controller, container, false)
|
||||||
@ -49,7 +52,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
|||||||
|
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
view.applyWindowInsetsForController()
|
liftAppbarWith(recycler)
|
||||||
|
|
||||||
val ourAdapter = adapter ?: MigrationSourceAdapter(
|
val ourAdapter = adapter ?: MigrationSourceAdapter(
|
||||||
getEnabledSources().map { MigrationSourceItem(it, isEnabled(it.id.toString())) },
|
getEnabledSources().map { MigrationSourceItem(it, isEnabled(it.id.toString())) },
|
||||||
@ -68,9 +71,13 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
|||||||
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||||
}
|
}
|
||||||
|
v.post {
|
||||||
// offset the recycler by the fab's inset + some inset on top
|
// offset the recycler by the fab's inset + some inset on top
|
||||||
v.updatePaddingRelative(bottom = padding.bottom + (fab?.marginBottom ?: 0) +
|
v.updatePaddingRelative(
|
||||||
fabBaseMarginBottom + (fab?.height ?: 0))
|
bottom = insets.systemWindowInsetBottom + (fab?.marginBottom
|
||||||
|
?: 0) + (fab?.height ?: 0)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fab.setOnClickListener {
|
fab.setOnClickListener {
|
||||||
@ -151,6 +158,40 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
|||||||
else sourcesSaved.split("/").contains(id)
|
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.hiddenSources().getOrDefault().mapNotNull { it.toLongOrNull() }
|
||||||
|
} else {
|
||||||
|
prefs.pinnedCatalogues().get()?.mapNotNull { it.toLongOrNull() } ?: emptyList()
|
||||||
|
}
|
||||||
|
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 {
|
companion object {
|
||||||
private const val MANGA_IDS_EXTRA = "manga_ids"
|
private const val MANGA_IDS_EXTRA = "manga_ids"
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
|||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
|
import eu.kanade.tachiyomi.util.view.liftAppbarWith
|
||||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||||
import kotlinx.android.synthetic.main.migration_list_controller.*
|
import kotlinx.android.synthetic.main.migration_list_controller.*
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
@ -95,7 +95,7 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
|
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
view.applyWindowInsetsForController()
|
liftAppbarWith(recycler)
|
||||||
setTitle()
|
setTitle()
|
||||||
val config = this.config ?: return
|
val config = this.config ?: return
|
||||||
|
|
||||||
|
11
app/src/main/res/drawable/ic_select_all_24dp.xml
Normal file
11
app/src/main/res/drawable/ic_select_all_24dp.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!-- drawable/select_all.xml -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/actionBarTintColor"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#000"
|
||||||
|
android:pathData="M9,9H15V15H9M7,17H17V7H7M15,5H17V3H15M15,21H17V19H15M19,17H21V15H19M19,9H21V7H19M19,21A2,2 0 0,0 21,19H19M19,13H21V11H19M11,21H13V19H11M9,3H7V5H9M3,17H5V15H3M5,21V19H3A2,2 0 0,0 5,21M19,3V5H21A2,2 0 0,0 19,3M13,3H11V5H13M3,9H5V7H3M7,21H9V19H7M3,13H5V11H3M3,5H5V3A2,2 0 0,0 3,5Z" />
|
||||||
|
</vector>
|
11
app/src/main/res/drawable/ic_select_none_24dp.xml
Normal file
11
app/src/main/res/drawable/ic_select_none_24dp.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!-- drawable/select_off.xml -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/actionBarTintColor"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#000"
|
||||||
|
android:pathData="M1,4.27L2.28,3L21,21.72L19.73,23L17,20.27V21H15V19H15.73L5,8.27V9H3V7H3.73L1,4.27M20,3A1,1 0 0,1 21,4V5H19V3H20M15,5V3H17V5H15M11,5V3H13V5H11M7,5V3H9V5H7M11,21V19H13V21H11M7,21V19H9V21H7M4,21A1,1 0 0,1 3,20V19H5V21H4M3,15H5V17H3V15M21,15V17H19V15H21M3,11H5V13H3V11M21,11V13H19V11H21M21,7V9H19V7H21Z" />
|
||||||
|
</vector>
|
@ -6,10 +6,10 @@
|
|||||||
android:id="@+id/action_copy_manga"
|
android:id="@+id/action_copy_manga"
|
||||||
android:icon="@drawable/ic_content_copy_24dp"
|
android:icon="@drawable/ic_content_copy_24dp"
|
||||||
android:title="@string/copy"
|
android:title="@string/copy"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_migrate_manga"
|
android:id="@+id/action_migrate_manga"
|
||||||
android:icon="@drawable/ic_done_all_24dp"
|
android:icon="@drawable/ic_done_all_24dp"
|
||||||
android:title="@string/migrate"
|
android:title="@string/migrate"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="ifRoom" />
|
||||||
</menu>
|
</menu>
|
25
app/src/main/res/menu/pre_migration.xml
Normal file
25
app/src/main/res/menu/pre_migration.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_select_none"
|
||||||
|
android:icon="@drawable/ic_select_none_24dp"
|
||||||
|
android:title="@string/select_none"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_select_all"
|
||||||
|
android:icon="@drawable/ic_select_all_24dp"
|
||||||
|
android:title="@string/select_all"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_match_enabled"
|
||||||
|
android:icon="@drawable/ic_browse_24dp"
|
||||||
|
android:title="@string/match_enabled_sources"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_match_pinned"
|
||||||
|
android:icon="@drawable/ic_pin_24dp"
|
||||||
|
android:title="@string/match_pinned_sources"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
</menu>
|
@ -423,7 +423,7 @@
|
|||||||
<string name="add_tracking">Add tracking</string>
|
<string name="add_tracking">Add tracking</string>
|
||||||
|
|
||||||
<!-- Migration -->
|
<!-- Migration -->
|
||||||
<string name="select_target_sources">Select target sources</string>
|
<string name="select_sources">Select sources</string>
|
||||||
<string name="source_migration">Source migration</string>
|
<string name="source_migration">Source migration</string>
|
||||||
<string name="migration">Migration</string>
|
<string name="migration">Migration</string>
|
||||||
<string name="skip_pre_migration">Skip pre-migration</string>
|
<string name="skip_pre_migration">Skip pre-migration</string>
|
||||||
@ -738,6 +738,7 @@
|
|||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
<string name="search">Search</string>
|
<string name="search">Search</string>
|
||||||
<string name="select_all">Select all</string>
|
<string name="select_all">Select all</string>
|
||||||
|
<string name="select_none">Select none</string>
|
||||||
<string name="share">Share</string>
|
<string name="share">Share</string>
|
||||||
<string name="sort">Sort</string>
|
<string name="sort">Sort</string>
|
||||||
<string name="sort_and_filter">Sort & Filter</string>
|
<string name="sort_and_filter">Sort & Filter</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user