Refactoring + fixes for auto-migrate
This commit is contained in:
parent
d64754e3e0
commit
142dc1c12a
@ -44,7 +44,7 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
|
|||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationInterface
|
import eu.kanade.tachiyomi.ui.migration.MigrationInterface
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.design.MigrationDesignController
|
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
|
||||||
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.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.doOnApplyWindowInsets
|
||||||
@ -478,7 +478,7 @@ class LibraryController(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MigrationDesignController.create( selectedMangas.mapNotNull { it.id } )
|
PreMigrationController.create( selectedMangas.mapNotNull { it.id } )
|
||||||
}
|
}
|
||||||
.withFadeTransaction())
|
.withFadeTransaction())
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
|
@ -17,7 +17,7 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.design.MigrationDesignController
|
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
||||||
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
||||||
import eu.kanade.tachiyomi.util.await
|
import eu.kanade.tachiyomi.util.await
|
||||||
@ -147,7 +147,7 @@ class MigrationController : NucleusController<MigrationPresenter>(),
|
|||||||
MigrationProcedureConfig( sourceMangas, null)
|
MigrationProcedureConfig( sourceMangas, null)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else { MigrationDesignController.create(sourceMangas) }
|
else { PreMigrationController.create(sourceMangas) }
|
||||||
.withFadeTransaction())
|
.withFadeTransaction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ import eu.kanade.tachiyomi.source.SourceManager
|
|||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class MigrationSourceAdapter(var items: List<MigrationSourceItem>,
|
class MigrationSourceAdapter(var items: List<MigrationSourceItem>,
|
||||||
val controller: MigrationDesignController
|
val controllerPre: PreMigrationController
|
||||||
): FlexibleAdapter<MigrationSourceItem>(
|
): FlexibleAdapter<MigrationSourceItem>(
|
||||||
items,
|
items,
|
||||||
controller,
|
controllerPre,
|
||||||
true
|
true
|
||||||
) {
|
) {
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
@ -7,6 +7,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
@ -21,11 +22,11 @@ import eu.kanade.tachiyomi.util.marginBottom
|
|||||||
import eu.kanade.tachiyomi.util.updateLayoutParams
|
import eu.kanade.tachiyomi.util.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.updatePaddingRelative
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
|
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
|
||||||
import kotlinx.android.synthetic.main.migration_design_controller.fab
|
import kotlinx.android.synthetic.main.pre_migration_controller.fab
|
||||||
import kotlinx.android.synthetic.main.migration_design_controller.recycler
|
import kotlinx.android.synthetic.main.pre_migration_controller.recycler
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class MigrationDesignController(bundle: Bundle? = null) : BaseController(bundle), FlexibleAdapter
|
class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), FlexibleAdapter
|
||||||
.OnItemClickListener, StartMigrationListener {
|
.OnItemClickListener, StartMigrationListener {
|
||||||
private val sourceManager: SourceManager by injectLazy()
|
private val sourceManager: SourceManager by injectLazy()
|
||||||
private val prefs: PreferencesHelper by injectLazy()
|
private val prefs: PreferencesHelper by injectLazy()
|
||||||
@ -36,10 +37,12 @@ class MigrationDesignController(bundle: Bundle? = null) : BaseController(bundle)
|
|||||||
|
|
||||||
private var showingOptions = false
|
private var showingOptions = false
|
||||||
|
|
||||||
|
private var dialog:BottomSheetDialog? = null
|
||||||
|
|
||||||
override fun getTitle() = "Select target sources"
|
override fun getTitle() = "Select target sources"
|
||||||
|
|
||||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||||
return inflater.inflate(R.layout.migration_design_controller, container, false)
|
return inflater.inflate(R.layout.pre_migration_controller, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
@ -55,7 +58,7 @@ class MigrationDesignController(bundle: Bundle? = null) : BaseController(bundle)
|
|||||||
recycler.adapter = ourAdapter
|
recycler.adapter = ourAdapter
|
||||||
ourAdapter.itemTouchHelperCallback = null // Reset adapter touch adapter to fix drag after rotation
|
ourAdapter.itemTouchHelperCallback = null // Reset adapter touch adapter to fix drag after rotation
|
||||||
ourAdapter.isHandleDragEnabled = true
|
ourAdapter.isHandleDragEnabled = true
|
||||||
|
dialog = null
|
||||||
val fabBaseMarginBottom = fab?.marginBottom ?: 0
|
val fabBaseMarginBottom = fab?.marginBottom ?: 0
|
||||||
recycler.doOnApplyWindowInsets { v, insets, padding ->
|
recycler.doOnApplyWindowInsets { v, insets, padding ->
|
||||||
|
|
||||||
@ -68,16 +71,18 @@ class MigrationDesignController(bundle: Bundle? = null) : BaseController(bundle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fab.setOnClickListener {
|
fab.setOnClickListener {
|
||||||
val dialog = MigrationBottomSheetDialog(activity!!, R.style.SheetDialog, this)
|
if (dialog?.isShowing != true) {
|
||||||
dialog.show()
|
dialog = MigrationBottomSheetDialog(activity!!, R.style.SheetDialog, this)
|
||||||
val bottomSheet =
|
dialog?.show()
|
||||||
dialog.findViewById<FrameLayout>(com.google.android.material.R.id
|
val bottomSheet = dialog?.findViewById<FrameLayout>(
|
||||||
.design_bottom_sheet)
|
com.google.android.material.R.id.design_bottom_sheet
|
||||||
|
)
|
||||||
val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet)
|
val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet)
|
||||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
behavior.skipCollapsed = true
|
behavior.skipCollapsed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun startMigration(extraParam:String?) {
|
override fun startMigration(extraParam:String?) {
|
||||||
val listOfSources = adapter?.items?.filter {
|
val listOfSources = adapter?.items?.filter {
|
||||||
@ -145,8 +150,8 @@ class MigrationDesignController(bundle: Bundle? = null) : BaseController(bundle)
|
|||||||
companion object {
|
companion object {
|
||||||
private const val MANGA_IDS_EXTRA = "manga_ids"
|
private const val MANGA_IDS_EXTRA = "manga_ids"
|
||||||
|
|
||||||
fun create(mangaIds: List<Long>): MigrationDesignController {
|
fun create(mangaIds: List<Long>): PreMigrationController {
|
||||||
return MigrationDesignController(Bundle().apply {
|
return PreMigrationController(Bundle().apply {
|
||||||
putLongArray(MANGA_IDS_EXTRA, mangaIds.toLongArray())
|
putLongArray(MANGA_IDS_EXTRA, mangaIds.toLongArray())
|
||||||
})
|
})
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user