From dbc3d335a02d03535ccfcf9390904b0c5dd557a7 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sat, 1 May 2021 21:52:55 -0400 Subject: [PATCH] Upping to conductor v3.0.0 Had to fork off conductor-support-preference to up that to 3.0.0 as well. @arkon if you want I can submit a pr for main/conductor-support-preference for this but I'm just validating all is fine first (also I dont need the viepager library so it's easier for me to it), still double checking if it's all good first anyway --- app/build.gradle.kts | 8 ++--- .../ui/base/controller/BaseController.kt | 7 ++-- .../ui/base/controller/DialogController.kt | 4 +-- .../kanade/tachiyomi/ui/main/MainActivity.kt | 32 +++++++++---------- .../tachiyomi/ui/main/SearchActivity.kt | 4 +-- .../ui/manga/MangaDetailsController.kt | 12 +++---- .../manga/process/MigrationListController.kt | 10 +++--- .../tachiyomi/ui/recents/RecentsController.kt | 2 +- .../ui/setting/SettingsSourcesController.kt | 2 +- .../source/browse/BrowseSourceController.kt | 4 +-- .../util/view/ControllerExtensions.kt | 12 +++---- 11 files changed, 47 insertions(+), 50 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ef8c2e8cd5..ce65c34edb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -227,11 +227,9 @@ dependencies { implementation("com.getkeepsafe.taptargetview:taptargetview:1.13.0") // 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.0") + val conductorVersion = "3.0.0" + implementation("com.bluelinelabs:conductor:$conductorVersion") + implementation("com.github.jays2kings:conductor-support-preference:3.0.0") // RxBindings implementation("com.jakewharton.rxbinding:rxbinding-kotlin:${Versions.RX_BINDING}") 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 c3710e422e..93cfce0972 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 @@ -11,7 +11,6 @@ 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 eu.kanade.tachiyomi.util.view.removeQueryListener import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainScope @@ -19,7 +18,7 @@ import kotlinx.coroutines.cancel import timber.log.Timber abstract class BaseController(bundle: Bundle? = null) : - RestoreViewOnCreateController(bundle) { + Controller(bundle) { lateinit var binding: VB lateinit var viewScope: CoroutineScope @@ -73,7 +72,7 @@ abstract class BaseController(bundle: Bundle? = null) : } val onRoot: Boolean - get() = router.backstack.lastOrNull()?.controller() == this + get() = router.backstack.lastOrNull()?.controller == this open fun getTitle(): String? { return null @@ -93,7 +92,7 @@ abstract class BaseController(bundle: Bundle? = null) : parentController = parentController.parentController } - if (router.backstack.lastOrNull()?.controller() == this) { + if (router.backstack.lastOrNull()?.controller == this) { (activity as? AppCompatActivity)?.supportActionBar?.title = getTitle() } } 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 9fecbecda4..2a9cb7a037 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 @@ -17,7 +17,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/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index ea52c53a16..fbb92c706c 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 @@ -110,7 +110,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi private val downloadManager: DownloadManager by injectLazy() private val mangaShortcutManager: MangaShortcutManager by injectLazy() private val hideBottomNav - get() = router.backstackSize > 1 && router.backstack[1].controller() !is DialogController + get() = router.backstackSize > 1 && router.backstack[1].controller !is DialogController private val updateChecker by lazy { UpdateChecker.getUpdateChecker() } private val isUpdaterEnabled = BuildConfig.INCLUDE_UPDATER @@ -190,7 +190,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi binding.bottomNav.selectedItemId = id binding.bottomNav.post { val controller = - router.backstack.firstOrNull()?.controller() as? BottomSheetController + router.backstack.firstOrNull()?.controller as? BottomSheetController controller?.showSheet() } true @@ -198,7 +198,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi } binding.bottomNav.setOnNavigationItemSelectedListener { item -> val id = item.itemId - val currentController = router.backstack.lastOrNull()?.controller() + val currentController = router.backstack.lastOrNull()?.controller if (!continueSwitchingTabs && currentController is BottomNavBarInterface) { if (!currentController.canChangeTabs { continueSwitchingTabs = true @@ -271,14 +271,14 @@ open class MainActivity : BaseActivity(), DownloadServiceLi } binding.toolbar.setNavigationOnClickListener { - val rootSearchController = router.backstack.lastOrNull()?.controller() + val rootSearchController = router.backstack.lastOrNull()?.controller if (rootSearchController is RootSearchInterface) { rootSearchController.expandSearch() } else onBackPressed() } binding.cardToolbar.setNavigationOnClickListener { - val rootSearchController = router.backstack.lastOrNull()?.controller() + val rootSearchController = router.backstack.lastOrNull()?.controller if (rootSearchController is RootSearchInterface) { rootSearchController.expandSearch() } else onBackPressed() @@ -322,11 +322,11 @@ open class MainActivity : BaseActivity(), DownloadServiceLi } ) - syncActivityViewWithController(router.backstack.lastOrNull()?.controller()) + syncActivityViewWithController(router.backstack.lastOrNull()?.controller) binding.toolbar.navigationIcon = if (router.backstackSize > 1) drawerArrow else searchDrawable - (router.backstack.lastOrNull()?.controller() as? BaseController<*>)?.setTitle() - (router.backstack.lastOrNull()?.controller() as? SettingsController)?.setTitle() + (router.backstack.lastOrNull()?.controller as? BaseController<*>)?.setTitle() + (router.backstack.lastOrNull()?.controller as? SettingsController)?.setTitle() if (savedInstanceState == null) { // Show changelog if needed @@ -348,7 +348,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi binding.cardToolbar.setIncognitoMode(it) } setExtensionsBadge() - setFloatingToolbar(canShowFloatingToolbar(router.backstack.lastOrNull()?.controller())) + setFloatingToolbar(canShowFloatingToolbar(router.backstack.lastOrNull()?.controller)) } open fun setFloatingToolbar(show: Boolean, solidBG: Boolean = false) { @@ -367,7 +367,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi if (show && !solidBG) Color.TRANSPARENT else getResourceColor(R.attr.colorSecondary) ) currentToolbar?.setNavigationOnClickListener { - val rootSearchController = router.backstack.lastOrNull()?.controller() + val rootSearchController = router.backstack.lastOrNull()?.controller if (rootSearchController is RootSearchInterface) { rootSearchController.expandSearch() } else onBackPressed() @@ -549,7 +549,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi } binding.bottomNav.post { val controller = - router.backstack.firstOrNull()?.controller() as? RecentsController + router.backstack.firstOrNull()?.controller as? RecentsController controller?.tempJumpTo( when (intent.action) { SHORTCUT_RECENTLY_UPDATED -> RecentsPresenter.VIEW_TYPE_ONLY_UPDATES @@ -567,7 +567,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi } binding.bottomNav.post { val controller = - router.backstack.firstOrNull()?.controller() as? BrowseController + router.backstack.firstOrNull()?.controller as? BrowseController controller?.showSheet() } } @@ -579,7 +579,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi SHORTCUT_UPDATE_NOTES -> { val extras = intent.extras ?: return false if (router.backstack.isEmpty()) binding.bottomNav.selectedItemId = R.id.nav_library - if (router.backstack.lastOrNull()?.controller() !is AboutController.NewUpdateDialogController) { + if (router.backstack.lastOrNull()?.controller !is AboutController.NewUpdateDialogController) { AboutController.NewUpdateDialogController(extras).showDialog(router) } } @@ -593,7 +593,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi router.popToRoot() binding.bottomNav.post { val controller = - router.backstack.firstOrNull()?.controller() as? RecentsController + router.backstack.firstOrNull()?.controller as? RecentsController controller?.showSheet() } } @@ -614,7 +614,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi } override fun onBackPressed() { - val sheetController = router.backstack.last().controller() as? BottomSheetController + val sheetController = router.backstack.last().controller as? BottomSheetController if (if (router.backstackSize == 1) !(sheetController?.handleSheetBack() ?: false) else !router.handleBack() ) { @@ -874,7 +874,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi diffY <= 0 ) { val bottomSheetController = - router.backstack.lastOrNull()?.controller() as? BottomSheetController + router.backstack.lastOrNull()?.controller as? BottomSheetController bottomSheetController?.showSheet() } result = true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt index f2e50d6e66..310ad71fe7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt @@ -28,8 +28,8 @@ class SearchActivity : MainActivity() { binding.cardToolbar.navigationIcon = drawerArrow binding.toolbar.setNavigationOnClickListener { popToRoot() } binding.cardToolbar.setNavigationOnClickListener { popToRoot() } - (router.backstack.lastOrNull()?.controller() as? BaseController<*>)?.setTitle() - (router.backstack.lastOrNull()?.controller() as? SettingsController)?.setTitle() + (router.backstack.lastOrNull()?.controller as? BaseController<*>)?.setTitle() + (router.backstack.lastOrNull()?.controller as? SettingsController)?.setTitle() } override fun onBackPressed() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index ec5927294f..00b2fd45c0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -284,7 +284,7 @@ class MangaDetailsController : if (isColor == toolbarIsColored) return toolbarIsColored = isColor val isCurrentController = - router?.backstack?.lastOrNull()?.controller() == this@MangaDetailsController + router?.backstack?.lastOrNull()?.controller == this@MangaDetailsController if (isCurrentController) setTitle() if (actionMode != null) { activityBinding?.toolbar?.setBackgroundColor(Color.TRANSPARENT) @@ -421,7 +421,7 @@ class MangaDetailsController : } // fetch cover again in case the user set a new cover while reading setPaletteColor() - val isCurrentController = router?.backstack?.lastOrNull()?.controller() == + val isCurrentController = router?.backstack?.lastOrNull()?.controller == this if (isCurrentController) { setStatusBarAndToolbar() @@ -434,7 +434,7 @@ class MangaDetailsController : setActionBar(true) setStatusBarAndToolbar() } else if (type == ControllerChangeType.PUSH_EXIT || type == ControllerChangeType.POP_EXIT) { - if (router.backstack.lastOrNull()?.controller() is DialogController) { + if (router.backstack.lastOrNull()?.controller is DialogController) { return } if (type == ControllerChangeType.POP_EXIT) { @@ -447,9 +447,9 @@ class MangaDetailsController : R.attr.colorSecondary ) ?: Color.BLACK if (router.backstackSize > 0 && - router.backstack.last().controller() !is MangaDetailsController + router.backstack.last().controller !is MangaDetailsController ) { - if (router.backstack.last().controller() !is FloatingSearchInterface) { + if (router.backstack.last().controller !is FloatingSearchInterface) { activityBinding?.appBar?.setBackgroundColor(colorSecondary) } activityBinding?.toolbar?.setBackgroundColor(colorSecondary) @@ -1064,7 +1064,7 @@ class MangaDetailsController : } override fun tagClicked(text: String) { - val firstController = router.backstack.first()?.controller() + val firstController = router.backstack.first()?.controller if (firstController is LibraryController && router.backstack.size == 2) { router.handleBack() firstController.search(text) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt index 899db83744..8c13c0e816 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt @@ -273,7 +273,7 @@ class MigrationListController(bundle: Bundle? = null) : override fun updateCount() { launchUI { - if (router.backstack.last().controller() == this@MigrationListController) { + if (router.backstack.last().controller == this@MigrationListController) { setTitle() } } @@ -407,16 +407,16 @@ class MigrationListController(bundle: Bundle? = null) : private fun navigateOut() { if (migratingManga?.size == 1) { launchUI { - val hasDetails = router.backstack.any { it.controller() is MangaDetailsController } + val hasDetails = router.backstack.any { it.controller is MangaDetailsController } if (hasDetails) { val manga = migratingManga?.firstOrNull()?.searchResult?.get()?.let { db.getManga(it).executeOnIO() } if (manga != null) { val newStack = router.backstack.filter { - it.controller() !is MangaDetailsController && - it.controller() !is MigrationListController && - it.controller() !is PreMigrationController + it.controller !is MangaDetailsController && + it.controller !is MigrationListController && + it.controller !is PreMigrationController } + MangaDetailsController(manga).withFadeTransaction() router.setBackstack(newStack, FadeChangeHandler()) return@launchUI diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index 30ec0f3b7b..6bf0d6ad39 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -642,7 +642,7 @@ class RecentsController(bundle: Bundle? = null) : } } else { if (type == ControllerChangeType.POP_EXIT) presenter.onDestroy() - if (router.backstack.lastOrNull()?.controller() !is DialogController) { + if (router.backstack.lastOrNull()?.controller !is DialogController) { (activity as? MainActivity)?.showTabBar(false) } snack?.dismiss() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesController.kt index 9ab700f6e2..92475ebff5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesController.kt @@ -175,7 +175,7 @@ class SettingsSourcesController : SettingsController() { searchView.clearFocus() } - searchView.queryTextChanges().filter { router.backstack.lastOrNull()?.controller() == this } + searchView.queryTextChanges().filter { router.backstack.lastOrNull()?.controller == this } .subscribeUntilDestroy { query = it.toString() drawSources() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt index 4e4d7649b6..6e461c99ef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt @@ -218,7 +218,7 @@ open class BrowseSourceController(bundle: Bundle) : // val searchEventsObservable = searchView.queryTextChangeEvents() // .skip(1) -// .filter { router.backstack.lastOrNull()?.controller() == this@BrowseSourceController } +// .filter { router.backstack.lastOrNull()?.controller == this@BrowseSourceController } // .share() // val writingObservable = searchEventsObservable // .filter { !it.isSubmitted } @@ -239,7 +239,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 { searchWithQuery("") diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt index 01b1e63df0..f27f738e4c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt @@ -49,7 +49,7 @@ fun Controller.setOnQueryTextChangeListener( object : SearchView.OnQueryTextListener { override fun onQueryTextChange(newText: String?): Boolean { if (!onlyOnSubmit && router.backstack.lastOrNull() - ?.controller() == this@setOnQueryTextChangeListener + ?.controller == this@setOnQueryTextChangeListener ) { return f(newText) } @@ -57,7 +57,7 @@ fun Controller.setOnQueryTextChangeListener( } override fun onQueryTextSubmit(query: String?): Boolean { - if (router.backstack.lastOrNull()?.controller() == this@setOnQueryTextChangeListener) { + if (router.backstack.lastOrNull()?.controller == this@setOnQueryTextChangeListener) { if (hideKbOnSubmit) { val imm = activity?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager @@ -147,7 +147,7 @@ fun Controller.liftAppbarWith(recycler: RecyclerView, padView: Boolean = false) override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) if (router?.backstack?.lastOrNull() - ?.controller() == this@liftAppbarWith && activity != null + ?.controller == this@liftAppbarWith && activity != null ) { val notAtTop = recycler.canScrollVertically(-1) if (notAtTop != elevate) elevateFunc(notAtTop) @@ -286,7 +286,7 @@ fun Controller.scrollViewWith( if (!customPadding && lastY == 0f && ( ( this@scrollViewWith !is FloatingSearchInterface && router.backstack.lastOrNull() - ?.controller() is MangaDetailsController + ?.controller is MangaDetailsController ) || includeTabView ) ) { @@ -332,7 +332,7 @@ fun Controller.scrollViewWith( super.onScrolled(recyclerView, dx, dy) if (recyclerView.tag == MaterialFastScroll.noUpdate) return if (router?.backstack?.lastOrNull() - ?.controller() == this@scrollViewWith && statusBarHeight > -1 && + ?.controller == this@scrollViewWith && statusBarHeight > -1 && activity != null && activityBinding!!.appBar.height > 0 && recycler.translationY == 0f ) { @@ -396,7 +396,7 @@ fun Controller.scrollViewWith( super.onScrollStateChanged(recyclerView, newState) if (newState == RecyclerView.SCROLL_STATE_IDLE) { if (router?.backstack?.lastOrNull() - ?.controller() == this@scrollViewWith && statusBarHeight > -1 && + ?.controller == this@scrollViewWith && statusBarHeight > -1 && activity != null && activityBinding!!.appBar.height > 0 && recycler.translationY == 0f ) {