This commit is contained in:
Rani Sargees
2020-04-21 16:53:15 -04:00
committed by Jobobby04
20 changed files with 150 additions and 156 deletions
@@ -136,7 +136,7 @@ class ExtensionManager(
// EXH -->
fun <T : Extension> Iterable<T>.filterNotBlacklisted(): List<T> {
val blacklistEnabled = preferences.eh_enableSourceBlacklist().getOrDefault()
val blacklistEnabled = preferences.eh_enableSourceBlacklist().get()
return filter {
if (it.isBlacklisted(blacklistEnabled)) {
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 =
preferences.eh_enableSourceBlacklist().getOrDefault()): Boolean {
fun Extension.isBlacklisted(
blacklistEnabled: Boolean =
preferences.eh_enableSourceBlacklist().get()
): Boolean {
return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled
}
// EXH <--
@@ -394,7 +394,7 @@ class LibraryPresenter(
replace: Boolean
) {
val flags = preferences.migrateFlags().getOrDefault()
val flags = preferences.migrateFlags().get()
val migrateChapters = MigrationFlags.hasChapters(flags)
val migrateCategories = MigrationFlags.hasCategories(flags)
val migrateTracks = MigrationFlags.hasTracks(flags)
@@ -28,9 +28,9 @@ import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.main.MainActivity
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.updates.UpdatesController
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
@@ -328,6 +328,12 @@ class MangaInfoController(private val fromSource: Boolean = false) :
thumbnailUrl = manga.thumbnail_url
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)
.load(mangaThumbnail)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
@@ -73,7 +73,7 @@ class MigrationBottomSheetDialog(
* Init general reader preferences.
*/
private fun initPreferences() {
val flags = preferences.migrateFlags().getOrDefault()
val flags = preferences.migrateFlags().get()
mig_chapters.isChecked = MigrationFlags.hasChapters(flags)
mig_categories.isChecked = MigrationFlags.hasCategories(flags)
@@ -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() })
@@ -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.MangaCategory
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.util.lang.launchUI
import kotlinx.coroutines.Dispatchers
@@ -97,7 +96,7 @@ class MigrationProcessAdapter(
replace: Boolean
) {
if (controller.config == null) return
val flags = preferences.migrateFlags().getOrDefault()
val flags = preferences.migrateFlags().get()
// Update chapters read
if (MigrationFlags.hasChapters(flags)) {
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
@@ -48,12 +48,6 @@ class SettingsAdvancedController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
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 {
key = CLEAR_CACHE_KEY
titleRes = R.string.pref_clear_chapter_cache
@@ -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()