Refactor databinding fields to parent abstract classes
(cherry picked from commit 6a532b836dd86819e97854e56e7524b1b0608786)
This commit is contained in:
parent
2ecac08bcc
commit
56b1c07f58
@ -13,6 +13,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.databinding.PreMigrationControllerBinding
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||
@ -24,10 +25,9 @@ import exh.util.doOnApplyWindowInsets
|
||||
import exh.util.marginBottom
|
||||
import exh.util.updateLayoutParams
|
||||
import exh.util.updatePaddingRelative
|
||||
import kotlinx.android.synthetic.main.pre_migration_controller.*
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), FlexibleAdapter
|
||||
class PreMigrationController(bundle: Bundle? = null) : BaseController<PreMigrationControllerBinding>(bundle), FlexibleAdapter
|
||||
.OnItemClickListener, StartMigrationListener {
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
private val prefs: PreferencesHelper by injectLazy()
|
||||
@ -43,7 +43,8 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
||||
override fun getTitle() = "Select target sources"
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(R.layout.pre_migration_controller, container, false)
|
||||
binding = PreMigrationControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
@ -55,24 +56,24 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
||||
this
|
||||
)
|
||||
adapter = ourAdapter
|
||||
recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
recycler.setHasFixedSize(true)
|
||||
recycler.adapter = ourAdapter
|
||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
binding.recycler.setHasFixedSize(true)
|
||||
binding.recycler.adapter = ourAdapter
|
||||
ourAdapter.itemTouchHelperCallback = null // Reset adapter touch adapter to fix drag after rotation
|
||||
ourAdapter.isHandleDragEnabled = true
|
||||
dialog = null
|
||||
val fabBaseMarginBottom = fab?.marginBottom ?: 0
|
||||
recycler.doOnApplyWindowInsets { v, insets, padding ->
|
||||
val fabBaseMarginBottom = binding.fab?.marginBottom ?: 0
|
||||
binding.recycler.doOnApplyWindowInsets { v, insets, padding ->
|
||||
|
||||
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
binding.fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
// offset the recycler by the fab's inset + some inset on top
|
||||
v.updatePaddingRelative(bottom = padding.bottom + (fab?.marginBottom ?: 0) +
|
||||
fabBaseMarginBottom + (fab?.height ?: 0))
|
||||
v.updatePaddingRelative(bottom = padding.bottom + (binding.fab?.marginBottom ?: 0) +
|
||||
fabBaseMarginBottom + (binding.fab?.height ?: 0))
|
||||
}
|
||||
|
||||
fab.setOnClickListener {
|
||||
binding.fab.setOnClickListener {
|
||||
if (dialog?.isShowing != true) {
|
||||
dialog = MigrationBottomSheetDialog(activity!!, R.style.SheetDialog, this)
|
||||
dialog?.show()
|
||||
|
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.databinding.MigrationListControllerBinding
|
||||
import eu.kanade.tachiyomi.smartsearch.SmartSearchEngine
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
@ -41,7 +42,6 @@ import exh.util.await
|
||||
import exh.util.executeOnIO
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlinx.android.synthetic.main.chapters_controller.*
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -56,7 +56,7 @@ import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
class MigrationListController(bundle: Bundle? = null) : BaseController<MigrationListControllerBinding>(bundle),
|
||||
MigrationProcessAdapter.MigrationProcessInterface, CoroutineScope {
|
||||
|
||||
init {
|
||||
@ -82,7 +82,8 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
private var manaulMigrations = 0
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(R.layout.migration_list_controller, container, false)
|
||||
binding = MigrationListControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun getTitle(): String? {
|
||||
@ -108,10 +109,10 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
|
||||
adapter = MigrationProcessAdapter(this)
|
||||
|
||||
recycler.adapter = adapter
|
||||
recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
recycler.setHasFixedSize(true)
|
||||
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
binding.recycler.adapter = adapter
|
||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
binding.recycler.setHasFixedSize(true)
|
||||
binding.recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
|
||||
adapter?.updateDataSet(newMigratingManga.map { it.toModal() })
|
||||
|
||||
|
@ -4,7 +4,7 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.SmartSearchBinding
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.source.SourceController
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.android.synthetic.main.smart_search.appbar
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
@ -23,7 +22,7 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SmartSearchController(bundle: Bundle? = null) : NucleusController<SmartSearchPresenter>(), CoroutineScope {
|
||||
class SmartSearchController(bundle: Bundle? = null) : NucleusController<SmartSearchBinding, SmartSearchPresenter>(), CoroutineScope {
|
||||
override val coroutineContext = Job() + Dispatchers.Main
|
||||
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
@ -33,8 +32,10 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<SmartSea
|
||||
ARG_SMART_SEARCH_CONFIG
|
||||
)
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) =
|
||||
inflater.inflate(R.layout.smart_search, container, false)!!
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = SmartSearchBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun getTitle() = source?.name ?: ""
|
||||
|
||||
@ -43,7 +44,7 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<SmartSea
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
appbar.bringToFront()
|
||||
binding.appbar.bringToFront()
|
||||
|
||||
if (source == null || smartSearchConfig == null) {
|
||||
router.popCurrentController()
|
||||
|
@ -5,6 +5,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -12,7 +13,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancel
|
||||
|
||||
abstract class BaseExhController(bundle: Bundle? = null) : BaseController(bundle), CoroutineScope {
|
||||
abstract class BaseExhController<VB : ViewBinding>(bundle: Bundle? = null) : BaseController<VB>(bundle), CoroutineScope {
|
||||
abstract val layoutId: Int
|
||||
@LayoutRes get
|
||||
|
||||
|
@ -6,28 +6,23 @@ import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.jakewharton.rxbinding.view.clicks
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.EhFragmentBatchAddBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.util.lang.combineLatest
|
||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.btn_add_galleries
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.galleries_box
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.input_title_view
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_bar
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_dismiss_btn
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_log
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_log_wrapper
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_text
|
||||
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_title_view
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
|
||||
/**
|
||||
* Batch add screen
|
||||
*/
|
||||
class BatchAddController : NucleusController<BatchAddPresenter>() {
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) =
|
||||
inflater.inflate(R.layout.eh_fragment_batch_add, container, false)!!
|
||||
class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAddPresenter>() {
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = EhFragmentBatchAddBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun getTitle() = "Batch add"
|
||||
|
||||
@ -37,11 +32,11 @@ class BatchAddController : NucleusController<BatchAddPresenter>() {
|
||||
super.onViewCreated(view)
|
||||
|
||||
with(view) {
|
||||
btn_add_galleries.clicks().subscribeUntilDestroy {
|
||||
addGalleries(galleries_box.text.toString())
|
||||
binding.btnAddGalleries.clicks().subscribeUntilDestroy {
|
||||
addGalleries(binding.galleriesBox.text.toString())
|
||||
}
|
||||
|
||||
progress_dismiss_btn.clicks().subscribeUntilDestroy {
|
||||
binding.progressDismissBtn.clicks().subscribeUntilDestroy {
|
||||
presenter.currentlyAddingRelay.call(BatchAddPresenter.STATE_PROGRESS_TO_INPUT)
|
||||
}
|
||||
|
||||
@ -55,34 +50,34 @@ class BatchAddController : NucleusController<BatchAddPresenter>() {
|
||||
showProgress(this)
|
||||
progressSubscriptions += presenter.progressRelay
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.combineLatest(presenter.progressTotalRelay, { progress, total ->
|
||||
.combineLatest(presenter.progressTotalRelay) { progress, total ->
|
||||
// Show hide dismiss button
|
||||
progress_dismiss_btn.visibility =
|
||||
if (progress == total)
|
||||
View.VISIBLE
|
||||
else View.GONE
|
||||
binding.progressDismissBtn.visibility =
|
||||
if (progress == total)
|
||||
View.VISIBLE
|
||||
else View.GONE
|
||||
|
||||
formatProgress(progress, total)
|
||||
}).subscribeUntilDestroy {
|
||||
progress_text.text = it
|
||||
}.subscribeUntilDestroy {
|
||||
binding.progressText.text = it
|
||||
}
|
||||
|
||||
progressSubscriptions += presenter.progressTotalRelay
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeUntilDestroy {
|
||||
progress_bar.max = it
|
||||
binding.progressBar.max = it
|
||||
}
|
||||
|
||||
progressSubscriptions += presenter.progressRelay
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeUntilDestroy {
|
||||
progress_bar.progress = it
|
||||
binding.progressBar.progress = it
|
||||
}
|
||||
|
||||
presenter.eventRelay
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribeUntilDestroy {
|
||||
progress_log.append("$it\n")
|
||||
binding.progressLog.append("$it\n")
|
||||
}?.let {
|
||||
progressSubscriptions += it
|
||||
}
|
||||
@ -96,18 +91,18 @@ class BatchAddController : NucleusController<BatchAddPresenter>() {
|
||||
|
||||
private val View.progressViews
|
||||
get() = listOf(
|
||||
progress_title_view,
|
||||
progress_log_wrapper,
|
||||
progress_bar,
|
||||
progress_text,
|
||||
progress_dismiss_btn
|
||||
binding.progressTitleView,
|
||||
binding.progressLogWrapper,
|
||||
binding.progressBar,
|
||||
binding.progressText,
|
||||
binding.progressDismissBtn
|
||||
)
|
||||
|
||||
private val View.inputViews
|
||||
get() = listOf(
|
||||
input_title_view,
|
||||
galleries_box,
|
||||
btn_add_galleries
|
||||
binding.inputTitleView,
|
||||
binding.galleriesBox,
|
||||
binding.btnAddGalleries
|
||||
)
|
||||
|
||||
private var List<View>.visibility: Int
|
||||
|
@ -5,28 +5,28 @@ import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.EhActivityInterceptBinding
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import kotlinx.android.synthetic.main.eh_activity_intercept.intercept_progress
|
||||
import kotlinx.android.synthetic.main.eh_activity_intercept.intercept_status
|
||||
import kotlinx.android.synthetic.main.eh_activity_intercept.toolbar
|
||||
import nucleus.factory.RequiresPresenter
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
|
||||
@RequiresPresenter(InterceptActivityPresenter::class)
|
||||
class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() {
|
||||
class InterceptActivity : BaseRxActivity<EhActivityInterceptBinding, InterceptActivityPresenter>() {
|
||||
private var statusSubscription: Subscription? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.eh_activity_intercept)
|
||||
|
||||
binding = EhActivityInterceptBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
// Show back button
|
||||
setSupportActionBar(toolbar)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
|
||||
processLink()
|
||||
@ -34,8 +34,8 @@ class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() {
|
||||
|
||||
private fun processLink() {
|
||||
if (Intent.ACTION_VIEW == intent.action) {
|
||||
intercept_progress.visible()
|
||||
intercept_status.text = "Loading gallery..."
|
||||
binding.interceptProgress.visible()
|
||||
binding.interceptStatus.text = "Loading gallery..."
|
||||
presenter.loadGallery(intent.dataString)
|
||||
}
|
||||
}
|
||||
@ -56,8 +56,8 @@ class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() {
|
||||
.subscribe {
|
||||
when (it) {
|
||||
is InterceptResult.Success -> {
|
||||
intercept_progress.gone()
|
||||
intercept_status.text = "Launching app..."
|
||||
binding.interceptProgress.gone()
|
||||
binding.interceptStatus.text = "Launching app..."
|
||||
onBackPressed()
|
||||
startActivity(Intent(this, MainActivity::class.java)
|
||||
.setAction(MainActivity.SHORTCUT_MANGA)
|
||||
@ -65,8 +65,8 @@ class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() {
|
||||
.putExtra(MangaController.MANGA_EXTRA, it.mangaId))
|
||||
}
|
||||
is InterceptResult.Failure -> {
|
||||
intercept_progress.gone()
|
||||
intercept_status.text = "Error: ${it.reason}"
|
||||
binding.interceptProgress.gone()
|
||||
binding.interceptStatus.text = "Error: ${it.reason}"
|
||||
MaterialDialog.Builder(this)
|
||||
.title("Error")
|
||||
.content("Could not open this gallery:\n\n${it.reason}")
|
||||
|
@ -13,20 +13,20 @@ import com.mattprecious.swirl.SwirlView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.databinding.ActivityLockBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import exh.util.dpToPx
|
||||
import kotlinx.android.synthetic.main.activity_lock.view.indicator_dots
|
||||
import kotlinx.android.synthetic.main.activity_lock.view.pin_lock_view
|
||||
import kotlinx.android.synthetic.main.activity_lock.view.swirl_container
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class LockController : NucleusController<LockPresenter>() {
|
||||
class LockController : NucleusController<ActivityLockBinding, LockPresenter>() {
|
||||
|
||||
val prefs: PreferencesHelper by injectLazy()
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) =
|
||||
inflater.inflate(R.layout.activity_lock, container, false)!!
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = ActivityLockBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
override fun createPresenter() = LockPresenter()
|
||||
|
||||
override fun getTitle() = "Application locked"
|
||||
@ -41,10 +41,10 @@ class LockController : NucleusController<LockPresenter>() {
|
||||
|
||||
with(view) {
|
||||
// Setup pin lock
|
||||
pin_lock_view.attachIndicatorDots(indicator_dots)
|
||||
binding.pinLockView.attachIndicatorDots(binding.indicatorDots)
|
||||
|
||||
pin_lock_view.pinLength = prefs.eh_lockLength().getOrDefault()
|
||||
pin_lock_view.setPinLockListener(object : PinLockListener {
|
||||
binding.pinLockView.pinLength = prefs.eh_lockLength().getOrDefault()
|
||||
binding.pinLockView.setPinLockListener(object : PinLockListener {
|
||||
override fun onEmpty() {}
|
||||
|
||||
override fun onComplete(pin: String) {
|
||||
@ -60,7 +60,7 @@ class LockController : NucleusController<LockPresenter>() {
|
||||
.positiveText("Ok")
|
||||
.autoDismiss(true)
|
||||
.show()
|
||||
pin_lock_view.resetPinLockView()
|
||||
binding.pinLockView.resetPinLockView()
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,8 +76,8 @@ class LockController : NucleusController<LockPresenter>() {
|
||||
with(view) {
|
||||
// Fingerprint
|
||||
if (presenter.useFingerprint) {
|
||||
swirl_container.visibility = View.VISIBLE
|
||||
swirl_container.removeAllViews()
|
||||
binding.swirlContainer.visibility = View.VISIBLE
|
||||
binding.swirlContainer.removeAllViews()
|
||||
val icon = SwirlView(context).apply {
|
||||
val size = dpToPx(context, 60)
|
||||
layoutParams = (layoutParams ?: ViewGroup.LayoutParams(
|
||||
@ -97,7 +97,7 @@ class LockController : NucleusController<LockPresenter>() {
|
||||
this@with.swirl_container.cardElevation = 0f
|
||||
setState(SwirlView.State.OFF, true)
|
||||
}
|
||||
swirl_container.addView(icon)
|
||||
binding.swirlContainer.addView(icon)
|
||||
icon.setState(SwirlView.State.ON)
|
||||
RxReprint.authenticate()
|
||||
.subscribeUntilDetach {
|
||||
@ -118,7 +118,7 @@ class LockController : NucleusController<LockPresenter>() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
swirl_container.visibility = View.GONE
|
||||
binding.swirlContainer.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import android.view.ViewGroup
|
||||
import android.webkit.CookieManager
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.EhActivityLoginBinding
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
@ -17,14 +17,6 @@ import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import exh.uconfig.WarnConfigureDialogController
|
||||
import java.net.HttpCookie
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.advanced_options
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.btn_advanced
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.btn_alt_login
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.btn_cancel
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.btn_close
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.btn_recheck
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.btn_skip_restyle
|
||||
import kotlinx.android.synthetic.main.eh_activity_login.view.webview
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@ -32,7 +24,7 @@ import uy.kohesive.injekt.injectLazy
|
||||
* LoginController
|
||||
*/
|
||||
|
||||
class LoginController : NucleusController<LoginPresenter>() {
|
||||
class LoginController : NucleusController<EhActivityLoginBinding, LoginPresenter>() {
|
||||
val preferenceManager: PreferencesHelper by injectLazy()
|
||||
|
||||
val sourceManager: SourceManager by injectLazy()
|
||||
@ -41,39 +33,41 @@ class LoginController : NucleusController<LoginPresenter>() {
|
||||
|
||||
override fun createPresenter() = LoginPresenter()
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) =
|
||||
inflater.inflate(R.layout.eh_activity_login, container, false)!!
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = EhActivityLoginBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
with(view) {
|
||||
btn_cancel.setOnClickListener { router.popCurrentController() }
|
||||
binding.btnCancel.setOnClickListener { router.popCurrentController() }
|
||||
|
||||
btn_advanced.setOnClickListener {
|
||||
advanced_options.visible()
|
||||
webview.gone()
|
||||
btn_advanced.isEnabled = false
|
||||
btn_cancel.isEnabled = false
|
||||
binding.btnAdvanced.setOnClickListener {
|
||||
binding.advancedOptions.visible()
|
||||
binding.webview.gone()
|
||||
binding.btnAdvanced.isEnabled = false
|
||||
binding.btnCancel.isEnabled = false
|
||||
}
|
||||
|
||||
btn_close.setOnClickListener {
|
||||
binding.btnClose.setOnClickListener {
|
||||
hideAdvancedOptions(this)
|
||||
}
|
||||
|
||||
btn_recheck.setOnClickListener {
|
||||
binding.btnRecheck.setOnClickListener {
|
||||
hideAdvancedOptions(this)
|
||||
webview.loadUrl("https://exhentai.org/")
|
||||
binding.webview.loadUrl("https://exhentai.org/")
|
||||
}
|
||||
|
||||
btn_alt_login.setOnClickListener {
|
||||
binding.btnAltLogin.setOnClickListener {
|
||||
hideAdvancedOptions(this)
|
||||
webview.loadUrl("https://e-hentai.org/bounce_login.php")
|
||||
binding.webview.loadUrl("https://e-hentai.org/bounce_login.php")
|
||||
}
|
||||
|
||||
btn_skip_restyle.setOnClickListener {
|
||||
binding.btnSkipRestyle.setOnClickListener {
|
||||
hideAdvancedOptions(this)
|
||||
webview.loadUrl("https://forums.e-hentai.org/index.php?act=Login&$PARAM_SKIP_INJECT=true")
|
||||
binding.webview.loadUrl("https://forums.e-hentai.org/index.php?act=Login&$PARAM_SKIP_INJECT=true")
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
@ -91,29 +85,28 @@ class LoginController : NucleusController<LoginPresenter>() {
|
||||
|
||||
private fun hideAdvancedOptions(view: View) {
|
||||
with(view) {
|
||||
advanced_options.gone()
|
||||
webview.visible()
|
||||
btn_advanced.isEnabled = true
|
||||
btn_cancel.isEnabled = true
|
||||
binding.advancedOptions.gone()
|
||||
binding.webview.visible()
|
||||
binding.btnAdvanced.isEnabled = true
|
||||
binding.btnCancel.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
fun startWebview(view: View) {
|
||||
with(view) {
|
||||
webview.settings.javaScriptEnabled = true
|
||||
webview.settings.domStorageEnabled = true
|
||||
binding.webview.settings.javaScriptEnabled = true
|
||||
binding.webview.settings.domStorageEnabled = true
|
||||
|
||||
webview.loadUrl("https://forums.e-hentai.org/index.php?act=Login")
|
||||
binding.webview.loadUrl("https://forums.e-hentai.org/index.php?act=Login")
|
||||
|
||||
webview.webViewClient = object : WebViewClient() {
|
||||
binding.webview.webViewClient = object : WebViewClient() {
|
||||
override fun onPageFinished(view: WebView, url: String) {
|
||||
super.onPageFinished(view, url)
|
||||
Timber.d(url)
|
||||
val parsedUrl = Uri.parse(url)
|
||||
if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) {
|
||||
// Hide distracting content
|
||||
if (!parsedUrl.queryParameterNames.contains(PARAM_SKIP_INJECT) &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||
if (!parsedUrl.queryParameterNames.contains(PARAM_SKIP_INJECT))
|
||||
view.evaluateJavascript(HIDE_JS, null)
|
||||
|
||||
// Check login result
|
||||
|
Loading…
x
Reference in New Issue
Block a user