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
This commit is contained in:
Jays2Kings 2021-05-01 21:52:55 -04:00
parent 59c98f03d5
commit dbc3d335a0
11 changed files with 47 additions and 50 deletions

View File

@ -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}")

View File

@ -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<VB : ViewBinding>(bundle: Bundle? = null) :
RestoreViewOnCreateController(bundle) {
Controller(bundle) {
lateinit var binding: VB
lateinit var viewScope: CoroutineScope
@ -73,7 +72,7 @@ abstract class BaseController<VB : ViewBinding>(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<VB : ViewBinding>(bundle: Bundle? = null) :
parentController = parentController.parentController
}
if (router.backstack.lastOrNull()?.controller() == this) {
if (router.backstack.lastOrNull()?.controller == this) {
(activity as? AppCompatActivity)?.supportActionBar?.title = getTitle()
}
}

View File

@ -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

View File

@ -110,7 +110,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), 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<MainActivityBinding>(), DownloadServiceLi
diffY <= 0
) {
val bottomSheetController =
router.backstack.lastOrNull()?.controller() as? BottomSheetController
router.backstack.lastOrNull()?.controller as? BottomSheetController
bottomSheetController?.showSheet()
}
result = true

View File

@ -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() {

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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("")

View File

@ -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
) {