This commit is contained in:
Rani Sargees 2020-04-21 16:53:15 -04:00 committed by Jobobby04
commit 03502f6533
20 changed files with 150 additions and 156 deletions

View File

@ -136,7 +136,7 @@ class ExtensionManager(
// EXH --> // EXH -->
fun <T : Extension> Iterable<T>.filterNotBlacklisted(): List<T> { fun <T : Extension> Iterable<T>.filterNotBlacklisted(): List<T> {
val blacklistEnabled = preferences.eh_enableSourceBlacklist().getOrDefault() val blacklistEnabled = preferences.eh_enableSourceBlacklist().get()
return filter { return filter {
if (it.isBlacklisted(blacklistEnabled)) { if (it.isBlacklisted(blacklistEnabled)) {
XLog.d("[EXH] Removing blacklisted extension: (name: %s, pkgName: %s)!", it.name, it.pkgName) XLog.d("[EXH] Removing blacklisted extension: (name: %s, pkgName: %s)!", it.name, it.pkgName)
@ -145,8 +145,10 @@ class ExtensionManager(
} }
} }
fun Extension.isBlacklisted(blacklistEnabled: Boolean = fun Extension.isBlacklisted(
preferences.eh_enableSourceBlacklist().getOrDefault()): Boolean { blacklistEnabled: Boolean =
preferences.eh_enableSourceBlacklist().get()
): Boolean {
return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled
} }
// EXH <-- // EXH <--

View File

@ -394,7 +394,7 @@ class LibraryPresenter(
replace: Boolean replace: Boolean
) { ) {
val flags = preferences.migrateFlags().getOrDefault() val flags = preferences.migrateFlags().get()
val migrateChapters = MigrationFlags.hasChapters(flags) val migrateChapters = MigrationFlags.hasChapters(flags)
val migrateCategories = MigrationFlags.hasCategories(flags) val migrateCategories = MigrationFlags.hasCategories(flags)
val migrateTracks = MigrationFlags.hasTracks(flags) val migrateTracks = MigrationFlags.hasTracks(flags)

View File

@ -28,9 +28,9 @@ import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.main.MainActivity 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.manga.design.PreMigrationController
import eu.kanade.tachiyomi.ui.recent.history.HistoryController import eu.kanade.tachiyomi.ui.recent.history.HistoryController
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.ui.source.SourceController import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
@ -328,6 +328,12 @@ class MangaInfoController(private val fromSource: Boolean = false) :
thumbnailUrl = manga.thumbnail_url thumbnailUrl = manga.thumbnail_url
val mangaThumbnail = manga.toMangaThumbnail() val mangaThumbnail = manga.toMangaThumbnail()
binding.mangaCoverCard.radius = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
preferences.eh_library_corner_radius().getOrDefault().toFloat(),
view.context.resources.displayMetrics
)
GlideApp.with(view.context) GlideApp.with(view.context)
.load(mangaThumbnail) .load(mangaThumbnail)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)

View File

@ -73,7 +73,7 @@ class MigrationBottomSheetDialog(
* Init general reader preferences. * Init general reader preferences.
*/ */
private fun initPreferences() { private fun initPreferences() {
val flags = preferences.migrateFlags().getOrDefault() val flags = preferences.migrateFlags().get()
mig_chapters.isChecked = MigrationFlags.hasChapters(flags) mig_chapters.isChecked = MigrationFlags.hasChapters(flags)
mig_categories.isChecked = MigrationFlags.hasCategories(flags) mig_categories.isChecked = MigrationFlags.hasCategories(flags)

View File

@ -13,6 +13,7 @@ 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
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.databinding.PreMigrationControllerBinding
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.controller.BaseController import eu.kanade.tachiyomi.ui.base.controller.BaseController
@ -24,10 +25,9 @@ import exh.util.doOnApplyWindowInsets
import exh.util.marginBottom import exh.util.marginBottom
import exh.util.updateLayoutParams import exh.util.updateLayoutParams
import exh.util.updatePaddingRelative import exh.util.updatePaddingRelative
import kotlinx.android.synthetic.main.pre_migration_controller.*
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), FlexibleAdapter class PreMigrationController(bundle: Bundle? = null) : BaseController<PreMigrationControllerBinding>(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()
@ -43,7 +43,8 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
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.pre_migration_controller, container, false) binding = PreMigrationControllerBinding.inflate(inflater)
return binding.root
} }
override fun onViewCreated(view: View) { override fun onViewCreated(view: View) {
@ -55,24 +56,24 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
this this
) )
adapter = ourAdapter adapter = ourAdapter
recycler.layoutManager = LinearLayoutManager(view.context) binding.recycler.layoutManager = LinearLayoutManager(view.context)
recycler.setHasFixedSize(true) binding.recycler.setHasFixedSize(true)
recycler.adapter = ourAdapter binding.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 dialog = null
val fabBaseMarginBottom = fab?.marginBottom ?: 0 val fabBaseMarginBottom = binding.fab?.marginBottom ?: 0
recycler.doOnApplyWindowInsets { v, insets, padding -> binding.recycler.doOnApplyWindowInsets { v, insets, padding ->
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> { binding.fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
} }
// offset the recycler by the fab's inset + some inset on top // offset the recycler by the fab's inset + some inset on top
v.updatePaddingRelative(bottom = padding.bottom + (fab?.marginBottom ?: 0) + v.updatePaddingRelative(bottom = padding.bottom + (binding.fab?.marginBottom ?: 0) +
fabBaseMarginBottom + (fab?.height ?: 0)) fabBaseMarginBottom + (binding.fab?.height ?: 0))
} }
fab.setOnClickListener { binding.fab.setOnClickListener {
if (dialog?.isShowing != true) { if (dialog?.isShowing != true) {
dialog = MigrationBottomSheetDialog(activity!!, R.style.SheetDialog, this) dialog = MigrationBottomSheetDialog(activity!!, R.style.SheetDialog, this)
dialog?.show() dialog?.show()

View File

@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.databinding.MigrationListControllerBinding
import eu.kanade.tachiyomi.smartsearch.SmartSearchEngine import eu.kanade.tachiyomi.smartsearch.SmartSearchEngine
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
@ -41,7 +42,6 @@ import exh.util.await
import exh.util.executeOnIO import exh.util.executeOnIO
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
import kotlinx.android.synthetic.main.chapters_controller.*
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -56,7 +56,7 @@ import rx.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
class MigrationListController(bundle: Bundle? = null) : BaseController(bundle), class MigrationListController(bundle: Bundle? = null) : BaseController<MigrationListControllerBinding>(bundle),
MigrationProcessAdapter.MigrationProcessInterface, CoroutineScope { MigrationProcessAdapter.MigrationProcessInterface, CoroutineScope {
init { init {
@ -82,7 +82,8 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
private var manaulMigrations = 0 private var manaulMigrations = 0
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { 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? { override fun getTitle(): String? {
@ -108,10 +109,10 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
adapter = MigrationProcessAdapter(this) adapter = MigrationProcessAdapter(this)
recycler.adapter = adapter binding.recycler.adapter = adapter
recycler.layoutManager = LinearLayoutManager(view.context) binding.recycler.layoutManager = LinearLayoutManager(view.context)
recycler.setHasFixedSize(true) binding.recycler.setHasFixedSize(true)
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener) binding.recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
adapter?.updateDataSet(newMigratingManga.map { it.toModal() }) adapter?.updateDataSet(newMigratingManga.map { it.toModal() })

View File

@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.database.models.MangaCategory import eu.kanade.tachiyomi.data.database.models.MangaCategory
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.ui.migration.MigrationFlags import eu.kanade.tachiyomi.ui.migration.MigrationFlags
import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.lang.launchUI
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -97,7 +96,7 @@ class MigrationProcessAdapter(
replace: Boolean replace: Boolean
) { ) {
if (controller.config == null) return if (controller.config == null) return
val flags = preferences.migrateFlags().getOrDefault() val flags = preferences.migrateFlags().get()
// Update chapters read // Update chapters read
if (MigrationFlags.hasChapters(flags)) { if (MigrationFlags.hasChapters(flags)) {
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking() val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()

View File

@ -48,12 +48,6 @@ class SettingsAdvancedController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
titleRes = R.string.pref_category_advanced titleRes = R.string.pref_category_advanced
switchPreference {
key = "acra.enable"
titleRes = R.string.pref_enable_acra
summaryRes = R.string.pref_acra_summary
defaultValue = true
}
preference { preference {
key = CLEAR_CACHE_KEY key = CLEAR_CACHE_KEY
titleRes = R.string.pref_clear_chapter_cache titleRes = R.string.pref_clear_chapter_cache

View File

@ -4,7 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup 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.CatalogueSource
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.base.controller.NucleusController 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.SourceController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import kotlinx.android.synthetic.main.smart_search.appbar
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@ -23,7 +22,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import uy.kohesive.injekt.injectLazy 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 override val coroutineContext = Job() + Dispatchers.Main
private val sourceManager: SourceManager by injectLazy() private val sourceManager: SourceManager by injectLazy()
@ -33,8 +32,10 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<SmartSea
ARG_SMART_SEARCH_CONFIG ARG_SMART_SEARCH_CONFIG
) )
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) = override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
inflater.inflate(R.layout.smart_search, container, false)!! binding = SmartSearchBinding.inflate(inflater)
return binding.root
}
override fun getTitle() = source?.name ?: "" override fun getTitle() = source?.name ?: ""
@ -43,7 +44,7 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<SmartSea
override fun onViewCreated(view: View) { override fun onViewCreated(view: View) {
super.onViewCreated(view) super.onViewCreated(view)
appbar.bringToFront() binding.appbar.bringToFront()
if (source == null || smartSearchConfig == null) { if (source == null || smartSearchConfig == null) {
router.popCurrentController() router.popCurrentController()

View File

@ -11,7 +11,6 @@ import com.ms_square.debugoverlay.OverlayModule
import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -58,7 +57,7 @@ class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(n
<b>Version code:</b> ${BuildConfig.VERSION_CODE}<br> <b>Version code:</b> ${BuildConfig.VERSION_CODE}<br>
<b>Commit SHA:</b> ${BuildConfig.COMMIT_SHA}<br> <b>Commit SHA:</b> ${BuildConfig.COMMIT_SHA}<br>
<b>Log level:</b> ${EHLogLevel.currentLogLevel.name.toLowerCase()}<br> <b>Log level:</b> ${EHLogLevel.currentLogLevel.name.toLowerCase()}<br>
<b>Source blacklist:</b> ${prefs.eh_enableSourceBlacklist().getOrDefault().asEnabledString()} <b>Source blacklist:</b> ${prefs.eh_enableSourceBlacklist().get().asEnabledString()}
""".trimIndent() """.trimIndent()
private fun Boolean.asEnabledString() = if (this) "enabled" else "disabled" private fun Boolean.asEnabledString() = if (this) "enabled" else "disabled"

View File

@ -5,7 +5,6 @@ import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.Router
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
@ -32,7 +31,7 @@ class WarnConfigureDialogController : DialogController() {
companion object { companion object {
fun uploadSettings(router: Router) { fun uploadSettings(router: Router) {
if (Injekt.get<PreferencesHelper>().eh_showSettingsUploadWarning().getOrDefault()) if (Injekt.get<PreferencesHelper>().eh_showSettingsUploadWarning().get())
WarnConfigureDialogController().showDialog(router) WarnConfigureDialogController().showDialog(router)
else else
ConfiguringDialogController().showDialog(router) ConfiguringDialogController().showDialog(router)

View File

@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.viewbinding.ViewBinding
import eu.kanade.tachiyomi.ui.base.controller.BaseController import eu.kanade.tachiyomi.ui.base.controller.BaseController
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -12,7 +13,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel 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 abstract val layoutId: Int
@LayoutRes get @LayoutRes get

View File

@ -5,29 +5,26 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.jakewharton.rxbinding.view.clicks import eu.kanade.tachiyomi.databinding.EhFragmentBatchAddBinding
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.util.lang.combineLatest import eu.kanade.tachiyomi.util.lang.combineLatest
import eu.kanade.tachiyomi.util.lang.launchInUI
import eu.kanade.tachiyomi.util.lang.plusAssign 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.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
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_log_wrapper import kotlinx.coroutines.flow.onEach
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_text import reactivecircus.flowbinding.android.view.clicks
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_title_view
import rx.android.schedulers.AndroidSchedulers import rx.android.schedulers.AndroidSchedulers
import rx.subscriptions.CompositeSubscription import rx.subscriptions.CompositeSubscription
/** /**
* Batch add screen * Batch add screen
*/ */
class BatchAddController : NucleusController<BatchAddPresenter>() { class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAddPresenter>() {
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) = override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
inflater.inflate(R.layout.eh_fragment_batch_add, container, false)!! binding = EhFragmentBatchAddBinding.inflate(inflater)
return binding.root
}
override fun getTitle() = "Batch add" override fun getTitle() = "Batch add"
@ -37,13 +34,17 @@ class BatchAddController : NucleusController<BatchAddPresenter>() {
super.onViewCreated(view) super.onViewCreated(view)
with(view) { with(view) {
btn_add_galleries.clicks().subscribeUntilDestroy { binding.btnAddGalleries.clicks()
addGalleries(galleries_box.text.toString()) .onEach {
} addGalleries(binding.galleriesBox.text.toString())
}
.launchInUI()
progress_dismiss_btn.clicks().subscribeUntilDestroy { binding.progressDismissBtn.clicks()
presenter.currentlyAddingRelay.call(BatchAddPresenter.STATE_PROGRESS_TO_INPUT) .onEach {
} presenter.currentlyAddingRelay.call(BatchAddPresenter.STATE_PROGRESS_TO_INPUT)
}
.launchInUI()
val progressSubscriptions = CompositeSubscription() val progressSubscriptions = CompositeSubscription()
@ -55,34 +56,34 @@ class BatchAddController : NucleusController<BatchAddPresenter>() {
showProgress(this) showProgress(this)
progressSubscriptions += presenter.progressRelay progressSubscriptions += presenter.progressRelay
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.combineLatest(presenter.progressTotalRelay, { progress, total -> .combineLatest(presenter.progressTotalRelay) { progress, total ->
// Show hide dismiss button // Show hide dismiss button
progress_dismiss_btn.visibility = binding.progressDismissBtn.visibility =
if (progress == total) if (progress == total)
View.VISIBLE View.VISIBLE
else View.GONE else View.GONE
formatProgress(progress, total) formatProgress(progress, total)
}).subscribeUntilDestroy { }.subscribeUntilDestroy {
progress_text.text = it binding.progressText.text = it
} }
progressSubscriptions += presenter.progressTotalRelay progressSubscriptions += presenter.progressTotalRelay
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeUntilDestroy { .subscribeUntilDestroy {
progress_bar.max = it binding.progressBar.max = it
} }
progressSubscriptions += presenter.progressRelay progressSubscriptions += presenter.progressRelay
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeUntilDestroy { .subscribeUntilDestroy {
progress_bar.progress = it binding.progressBar.progress = it
} }
presenter.eventRelay presenter.eventRelay
?.observeOn(AndroidSchedulers.mainThread()) ?.observeOn(AndroidSchedulers.mainThread())
?.subscribeUntilDestroy { ?.subscribeUntilDestroy {
progress_log.append("$it\n") binding.progressLog.append("$it\n")
}?.let { }?.let {
progressSubscriptions += it progressSubscriptions += it
} }
@ -96,18 +97,18 @@ class BatchAddController : NucleusController<BatchAddPresenter>() {
private val View.progressViews private val View.progressViews
get() = listOf( get() = listOf(
progress_title_view, binding.progressTitleView,
progress_log_wrapper, binding.progressLogWrapper,
progress_bar, binding.progressBar,
progress_text, binding.progressText,
progress_dismiss_btn binding.progressDismissBtn
) )
private val View.inputViews private val View.inputViews
get() = listOf( get() = listOf(
input_title_view, binding.inputTitleView,
galleries_box, binding.galleriesBox,
btn_add_galleries binding.btnAddGalleries
) )
private var List<View>.visibility: Int private var List<View>.visibility: Int

View File

@ -5,28 +5,28 @@ import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.EhActivityInterceptBinding
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
import eu.kanade.tachiyomi.ui.main.MainActivity 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.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible 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 nucleus.factory.RequiresPresenter
import rx.Subscription import rx.Subscription
import rx.android.schedulers.AndroidSchedulers import rx.android.schedulers.AndroidSchedulers
@RequiresPresenter(InterceptActivityPresenter::class) @RequiresPresenter(InterceptActivityPresenter::class)
class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() { class InterceptActivity : BaseRxActivity<EhActivityInterceptBinding, InterceptActivityPresenter>() {
private var statusSubscription: Subscription? = null private var statusSubscription: Subscription? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.eh_activity_intercept)
binding = EhActivityInterceptBinding.inflate(layoutInflater)
setContentView(binding.root)
// Show back button // Show back button
setSupportActionBar(toolbar) setSupportActionBar(binding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
processLink() processLink()
@ -34,8 +34,8 @@ class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() {
private fun processLink() { private fun processLink() {
if (Intent.ACTION_VIEW == intent.action) { if (Intent.ACTION_VIEW == intent.action) {
intercept_progress.visible() binding.interceptProgress.visible()
intercept_status.text = "Loading gallery..." binding.interceptStatus.text = "Loading gallery..."
presenter.loadGallery(intent.dataString) presenter.loadGallery(intent.dataString)
} }
} }
@ -56,8 +56,8 @@ class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() {
.subscribe { .subscribe {
when (it) { when (it) {
is InterceptResult.Success -> { is InterceptResult.Success -> {
intercept_progress.gone() binding.interceptProgress.gone()
intercept_status.text = "Launching app..." binding.interceptStatus.text = "Launching app..."
onBackPressed() onBackPressed()
startActivity(Intent(this, MainActivity::class.java) startActivity(Intent(this, MainActivity::class.java)
.setAction(MainActivity.SHORTCUT_MANGA) .setAction(MainActivity.SHORTCUT_MANGA)
@ -65,8 +65,8 @@ class InterceptActivity : BaseRxActivity<InterceptActivityPresenter>() {
.putExtra(MangaController.MANGA_EXTRA, it.mangaId)) .putExtra(MangaController.MANGA_EXTRA, it.mangaId))
} }
is InterceptResult.Failure -> { is InterceptResult.Failure -> {
intercept_progress.gone() binding.interceptProgress.gone()
intercept_status.text = "Error: ${it.reason}" binding.interceptStatus.text = "Error: ${it.reason}"
MaterialDialog.Builder(this) MaterialDialog.Builder(this)
.title("Error") .title("Error")
.content("Could not open this gallery:\n\n${it.reason}") .content("Could not open this gallery:\n\n${it.reason}")

View File

@ -6,11 +6,17 @@ import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
object LockActivityDelegate { object LockActivityDelegate {
private val preferences by injectLazy<PreferencesHelper>() private val preferences by injectLazy<PreferencesHelper>()
val uiScope = CoroutineScope(Dispatchers.Main)
var willLock: Boolean = true var willLock: Boolean = true
fun doLock(router: Router, animate: Boolean = false) { fun doLock(router: Router, animate: Boolean = false) {
@ -19,14 +25,15 @@ object LockActivityDelegate {
} }
fun onCreate(activity: FragmentActivity) { fun onCreate(activity: FragmentActivity) {
preferences.secureScreen().asObservable() preferences.secureScreen().asFlow()
.subscribe { .onEach {
if (it) { if (it) {
activity.window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) activity.window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
} else { } else {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
} }
} }
.launchIn(uiScope)
} }
fun onResume(activity: FragmentActivity, router: Router) { fun onResume(activity: FragmentActivity, router: Router) {

View File

@ -13,20 +13,20 @@ import com.mattprecious.swirl.SwirlView
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.databinding.ActivityLockBinding
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import exh.util.dpToPx 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 kotlinx.android.synthetic.main.activity_lock.view.swirl_container
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
class LockController : NucleusController<LockPresenter>() { class LockController : NucleusController<ActivityLockBinding, LockPresenter>() {
val prefs: PreferencesHelper by injectLazy() val prefs: PreferencesHelper by injectLazy()
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) = override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
inflater.inflate(R.layout.activity_lock, container, false)!! binding = ActivityLockBinding.inflate(inflater)
return binding.root
}
override fun createPresenter() = LockPresenter() override fun createPresenter() = LockPresenter()
override fun getTitle() = "Application locked" override fun getTitle() = "Application locked"
@ -41,10 +41,10 @@ class LockController : NucleusController<LockPresenter>() {
with(view) { with(view) {
// Setup pin lock // Setup pin lock
pin_lock_view.attachIndicatorDots(indicator_dots) binding.pinLockView.attachIndicatorDots(binding.indicatorDots)
pin_lock_view.pinLength = prefs.eh_lockLength().getOrDefault() binding.pinLockView.pinLength = prefs.eh_lockLength().getOrDefault()
pin_lock_view.setPinLockListener(object : PinLockListener { binding.pinLockView.setPinLockListener(object : PinLockListener {
override fun onEmpty() {} override fun onEmpty() {}
override fun onComplete(pin: String) { override fun onComplete(pin: String) {
@ -60,7 +60,7 @@ class LockController : NucleusController<LockPresenter>() {
.positiveText("Ok") .positiveText("Ok")
.autoDismiss(true) .autoDismiss(true)
.show() .show()
pin_lock_view.resetPinLockView() binding.pinLockView.resetPinLockView()
} }
} }
@ -76,8 +76,8 @@ class LockController : NucleusController<LockPresenter>() {
with(view) { with(view) {
// Fingerprint // Fingerprint
if (presenter.useFingerprint) { if (presenter.useFingerprint) {
swirl_container.visibility = View.VISIBLE binding.swirlContainer.visibility = View.VISIBLE
swirl_container.removeAllViews() binding.swirlContainer.removeAllViews()
val icon = SwirlView(context).apply { val icon = SwirlView(context).apply {
val size = dpToPx(context, 60) val size = dpToPx(context, 60)
layoutParams = (layoutParams ?: ViewGroup.LayoutParams( layoutParams = (layoutParams ?: ViewGroup.LayoutParams(
@ -97,7 +97,7 @@ class LockController : NucleusController<LockPresenter>() {
this@with.swirl_container.cardElevation = 0f this@with.swirl_container.cardElevation = 0f
setState(SwirlView.State.OFF, true) setState(SwirlView.State.OFF, true)
} }
swirl_container.addView(icon) binding.swirlContainer.addView(icon)
icon.setState(SwirlView.State.ON) icon.setState(SwirlView.State.ON)
RxReprint.authenticate() RxReprint.authenticate()
.subscribeUntilDetach { .subscribeUntilDetach {
@ -118,7 +118,7 @@ class LockController : NucleusController<LockPresenter>() {
} }
} }
} else { } else {
swirl_container.visibility = View.GONE binding.swirlContainer.visibility = View.GONE
} }
} }
} }

View File

@ -8,8 +8,8 @@ import android.view.ViewGroup
import android.webkit.CookieManager import android.webkit.CookieManager
import android.webkit.WebView import android.webkit.WebView
import android.webkit.WebViewClient import android.webkit.WebViewClient
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.EhActivityLoginBinding
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.util.lang.launchUI 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 eu.kanade.tachiyomi.util.view.visible
import exh.uconfig.WarnConfigureDialogController import exh.uconfig.WarnConfigureDialogController
import java.net.HttpCookie 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 timber.log.Timber
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -32,7 +24,7 @@ import uy.kohesive.injekt.injectLazy
* LoginController * LoginController
*/ */
class LoginController : NucleusController<LoginPresenter>() { class LoginController : NucleusController<EhActivityLoginBinding, LoginPresenter>() {
val preferenceManager: PreferencesHelper by injectLazy() val preferenceManager: PreferencesHelper by injectLazy()
val sourceManager: SourceManager by injectLazy() val sourceManager: SourceManager by injectLazy()
@ -41,39 +33,41 @@ class LoginController : NucleusController<LoginPresenter>() {
override fun createPresenter() = LoginPresenter() override fun createPresenter() = LoginPresenter()
override fun inflateView(inflater: LayoutInflater, container: ViewGroup) = override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
inflater.inflate(R.layout.eh_activity_login, container, false)!! binding = EhActivityLoginBinding.inflate(inflater)
return binding.root
}
override fun onViewCreated(view: View) { override fun onViewCreated(view: View) {
super.onViewCreated(view) super.onViewCreated(view)
with(view) { with(view) {
btn_cancel.setOnClickListener { router.popCurrentController() } binding.btnCancel.setOnClickListener { router.popCurrentController() }
btn_advanced.setOnClickListener { binding.btnAdvanced.setOnClickListener {
advanced_options.visible() binding.advancedOptions.visible()
webview.gone() binding.webview.gone()
btn_advanced.isEnabled = false binding.btnAdvanced.isEnabled = false
btn_cancel.isEnabled = false binding.btnCancel.isEnabled = false
} }
btn_close.setOnClickListener { binding.btnClose.setOnClickListener {
hideAdvancedOptions(this) hideAdvancedOptions(this)
} }
btn_recheck.setOnClickListener { binding.btnRecheck.setOnClickListener {
hideAdvancedOptions(this) hideAdvancedOptions(this)
webview.loadUrl("https://exhentai.org/") binding.webview.loadUrl("https://exhentai.org/")
} }
btn_alt_login.setOnClickListener { binding.btnAltLogin.setOnClickListener {
hideAdvancedOptions(this) 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) 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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@ -91,29 +85,28 @@ class LoginController : NucleusController<LoginPresenter>() {
private fun hideAdvancedOptions(view: View) { private fun hideAdvancedOptions(view: View) {
with(view) { with(view) {
advanced_options.gone() binding.advancedOptions.gone()
webview.visible() binding.webview.visible()
btn_advanced.isEnabled = true binding.btnAdvanced.isEnabled = true
btn_cancel.isEnabled = true binding.btnCancel.isEnabled = true
} }
} }
fun startWebview(view: View) { fun startWebview(view: View) {
with(view) { with(view) {
webview.settings.javaScriptEnabled = true binding.webview.settings.javaScriptEnabled = true
webview.settings.domStorageEnabled = 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) { override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url) super.onPageFinished(view, url)
Timber.d(url) Timber.d(url)
val parsedUrl = Uri.parse(url) val parsedUrl = Uri.parse(url)
if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) { if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) {
// Hide distracting content // Hide distracting content
if (!parsedUrl.queryParameterNames.contains(PARAM_SKIP_INJECT) && if (!parsedUrl.queryParameterNames.contains(PARAM_SKIP_INJECT))
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
view.evaluateJavascript(HIDE_JS, null) view.evaluateJavascript(HIDE_JS, null)
// Check login result // Check login result

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectable_library_drawable"> android:background="@drawable/library_item_selector">
<FrameLayout <FrameLayout
android:id="@+id/card" android:id="@+id/card"
@ -42,7 +42,7 @@
<TextView <TextView
android:id="@+id/manga_chapters" android:id="@+id/manga_chapters"
style="@style/TextAppearance.Regular.Caption.Light" style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/md_teal_500" android:background="@color/md_teal_500"
@ -60,7 +60,7 @@
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/title" android:id="@+id/title"
style="@style/TextAppearance.Regular.Body1.Light" style="@style/TextAppearance.Regular.Body1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"

View File

@ -309,16 +309,6 @@
<style name="FilePickerAlertDialogTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert" /> <style name="FilePickerAlertDialogTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert" />
<style name="reader_settings_popup_animation">
<item name="android:windowEnterAnimation">@anim/enter_from_right</item>
<item name="android:windowExitAnimation">@anim/exit_to_right</item>
</style>
<style name="reader_brightness_popup_animation">
<item name="android:windowEnterAnimation">@anim/enter_from_left</item>
<item name="android:windowExitAnimation">@anim/exit_to_left</item>
</style>
<style name="SheetDialog" parent="Theme.Design.Light.BottomSheetDialog"> <style name="SheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
<!--<item name="android:windowCloseOnTouchOutside">false</item>--> <!--<item name="android:windowCloseOnTouchOutside">false</item>-->
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>