From 01a1a9ebab09bb81fcb35412b171be794bfb91bf Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 3 Jul 2021 12:50:10 -0400 Subject: [PATCH] Update to Conductor 3.0.0 --- app/build.gradle.kts | 9 ++++----- .../tachiyomi/ui/base/controller/BaseController.kt | 4 +--- .../tachiyomi/ui/base/controller/DialogController.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/browse/BrowseController.kt | 2 +- .../tachiyomi/ui/browse/extension/ExtensionController.kt | 2 +- .../ui/browse/migration/search/SourceSearchController.kt | 2 +- .../ui/browse/source/browse/BrowseSourceController.kt | 2 +- .../tachiyomi/ui/library/DeleteLibraryMangasDialog.kt | 8 ++++++-- .../eu/kanade/tachiyomi/ui/library/LibraryController.kt | 2 +- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 4 ++-- .../java/eu/kanade/tachiyomi/ui/manga/MangaController.kt | 2 +- .../tachiyomi/ui/recent/history/HistoryController.kt | 2 +- .../tachiyomi/ui/setting/SettingsTrackingController.kt | 3 +-- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c78b1746ed..fc9c4716a1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -246,11 +246,10 @@ dependencies { implementation("com.afollestad.material-dialogs:datetime:$materialDialogsVersion") // Conductor - implementation("com.bluelinelabs:conductor:2.1.5") - implementation("com.bluelinelabs:conductor-support:2.1.5") { - exclude(group = "com.android.support") - } - implementation("com.github.tachiyomiorg:conductor-support-preference:2.0.1") + val conductorVersion = "3.0.0" + implementation("com.bluelinelabs:conductor:$conductorVersion") + implementation("com.bluelinelabs:conductor-viewpager:$conductorVersion") + implementation("com.github.tachiyomiorg:conductor-support-preference:$conductorVersion") // FlowBinding val flowbindingVersion = "1.0.0" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt index 44e55b0feb..711a948a9a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt @@ -10,14 +10,12 @@ import androidx.viewbinding.ViewBinding import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeType -import com.bluelinelabs.conductor.RestoreViewOnCreateController import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainScope import kotlinx.coroutines.cancel import timber.log.Timber -abstract class BaseController(bundle: Bundle? = null) : - RestoreViewOnCreateController(bundle) { +abstract class BaseController(bundle: Bundle? = null) : Controller(bundle) { protected lateinit var binding: VB private set diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt index 321d55c402..9fe0cffd2b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt @@ -5,7 +5,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import com.bluelinelabs.conductor.RestoreViewOnCreateController +import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler @@ -16,7 +16,7 @@ import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler * * Implementations should override this class and implement [.onCreateDialog] to create a custom dialog, such as an [android.app.AlertDialog] */ -abstract class DialogController : RestoreViewOnCreateController { +abstract class DialogController : Controller { protected var dialog: Dialog? = null private set diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt index 3107fe5a3c..bdd5ebb026 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt @@ -9,7 +9,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeType import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.RouterTransaction -import com.bluelinelabs.conductor.support.RouterPagerAdapter +import com.bluelinelabs.conductor.viewpager.RouterPagerAdapter import com.google.android.material.badge.BadgeDrawable import com.google.android.material.tabs.TabLayout import com.jakewharton.rxrelay.PublishRelay diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt index 1f7ccd16e8..aeb37fdb1d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt @@ -136,7 +136,7 @@ open class ExtensionController : } searchView.queryTextChanges() - .filter { router.backstack.lastOrNull()?.controller() == this } + .filter { router.backstack.lastOrNull()?.controller == this } .onEach { query = it.toString() drawExtensions() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt index ea50648f46..bba2173371 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchController.kt @@ -26,7 +26,7 @@ class SourceSearchController( override fun onItemClick(view: View, position: Int): Boolean { val item = adapter?.getItem(position) as? SourceItem ?: return false newManga = item.manga - val searchController = router.backstack.findLast { it.controller().javaClass == SearchController::class.java }?.controller() as SearchController? + val searchController = router.backstack.findLast { it.controller.javaClass == SearchController::class.java }?.controller as SearchController? val dialog = SearchController.MigrationDialog(oldManga, newManga, this) dialog.targetController = searchController diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index 6dccc80614..8ed12c54da 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -261,7 +261,7 @@ open class BrowseSourceController(bundle: Bundle) : searchItem.fixExpand( onExpand = { invalidateMenuOnExpand() }, onCollapse = { - if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller() is GlobalSearchController) { + if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller is GlobalSearchController) { router.popController(this) } else { nonSubmittedQuery = "" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt index 4cd2f2bede..0ed8a9eb2f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt @@ -8,6 +8,7 @@ import com.bluelinelabs.conductor.Controller import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.ui.base.controller.DialogController +import eu.kanade.tachiyomi.util.isLocal class DeleteLibraryMangasDialog(bundle: Bundle? = null) : DialogController(bundle) where T : Controller, T : DeleteLibraryMangasDialog.Listener { @@ -20,11 +21,14 @@ class DeleteLibraryMangasDialog(bundle: Bundle? = null) : } override fun onCreateDialog(savedViewState: Bundle?): Dialog { + val canDeleteChapters = mangas.any { !it.isLocal() } + return MaterialDialog(activity!!) .title(R.string.action_remove) .listItemsMultiChoice( - R.array.delete_selected_mangas, - initialSelection = intArrayOf(0) + res = R.array.delete_selected_mangas, + disabledIndices = intArrayOf(1).takeUnless { canDeleteChapters }, + initialSelection = intArrayOf(0), ) { _, selections, _ -> val deleteFromLibrary = 0 in selections val deleteChapters = 1 in selections diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index d377250900..85c9557b69 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -600,7 +600,7 @@ class LibraryController( override fun onSearchViewQueryTextChange(newText: String?) { // Ignore events if this controller isn't at the top to avoid query being reset - if (router.backstack.lastOrNull()?.controller() == this) { + if (router.backstack.lastOrNull()?.controller == this) { presenter.query = newText ?: "" performSearch() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 8bc9354209..d5446b3e68 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -219,7 +219,7 @@ class MainActivity : BaseViewBindingActivity() { } ) - syncActivityViewWithController(router.backstack.lastOrNull()?.controller()) + syncActivityViewWithController(router.backstack.lastOrNull()?.controller) if (savedInstanceState == null) { // Reset Incognito Mode on relaunch @@ -247,7 +247,7 @@ class MainActivity : BaseViewBindingActivity() { // Close BrowseSourceController and its MangaController child when incognito mode is disabled if (!it) { - val fg = router.backstack.last().controller() + val fg = router.backstack.last().controller if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) { router.popToRoot() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 175a8f51f9..e3009f413d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -614,7 +614,7 @@ class MangaController : return } - when (val previousController = router.backstack[router.backstackSize - 2].controller()) { + when (val previousController = router.backstack[router.backstackSize - 2].controller) { is LibraryController -> { router.handleBack() previousController.search(query) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt index 91ac55550a..511acf043b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt @@ -194,7 +194,7 @@ class HistoryController : searchView.clearFocus() } searchView.queryTextChanges() - .filter { router.backstack.lastOrNull()?.controller() == this } + .filter { router.backstack.lastOrNull()?.controller == this } .onEach { query = it.toString() presenter.updateList(query) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt index dbf72ef6ef..42fd558810 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt @@ -71,8 +71,7 @@ class SettingsTrackingController : trackManager.komga.loginNoop() updatePreference(trackManager.komga.id) } - } - preferenceCategory { + infoPreference(R.string.tracking_info) } }