From 776f6a9a16add41ec158be9da2a49fafc60b7987 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 27 Nov 2020 21:05:06 -0500 Subject: [PATCH] More bottom inset padding fixes --- .../ui/base/controller/ConductorExtensions.kt | 11 ++++------- .../ui/browse/extension/ExtensionController.kt | 2 -- .../details/ExtensionDetailsController.kt | 2 ++ .../sources/MigrationSourcesController.kt | 2 -- .../ui/browse/source/SourceController.kt | 2 -- .../globalsearch/GlobalSearchController.kt | 2 ++ .../tachiyomi/ui/category/CategoryController.kt | 2 -- .../tachiyomi/ui/download/DownloadController.kt | 2 -- .../kanade/tachiyomi/ui/manga/MangaController.kt | 2 -- .../kanade/tachiyomi/ui/more/MoreController.kt | 13 ------------- .../ui/recent/history/HistoryController.kt | 2 -- .../ui/recent/updates/UpdatesController.kt | 2 -- .../tachiyomi/ui/setting/SettingsController.kt | 16 +++++++++++++++- 13 files changed, 23 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt index ecf7a6ba0..f0677064c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt @@ -38,15 +38,12 @@ fun Controller.withFadeTransaction(): RouterTransaction { val Controller.insets: WindowInsets? get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - activity!!.window.decorView.rootWindowInsets + activity?.window?.decorView?.rootWindowInsets } else { null } -inline fun Controller.applyBottomInsetPadding(view: View, paddingBottom: Int = view.paddingBottom) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - view.updatePadding(bottom = paddingBottom + insets!!.systemWindowInsetBottom) - } else { - view.updatePadding(bottom = paddingBottom) - } +fun Controller.applyBottomInsetPadding(view: View, paddingBottom: Int = view.paddingBottom) { + val bottomInset = insets?.systemWindowInsetBottom ?: 0 + view.updatePadding(bottom = paddingBottom + bottomInset) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt index 69401f1a1..74ee8341c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt @@ -60,9 +60,7 @@ open class ExtensionController : override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = ExtensionControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt index a4232d347..b5972a2dd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt @@ -35,6 +35,7 @@ import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.getPreferenceKey import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.ToolbarLiftOnScrollController +import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.util.preference.DSL import eu.kanade.tachiyomi.util.preference.onChange @@ -66,6 +67,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) : override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { val themedInflater = inflater.cloneInContext(getPreferenceThemeContext()) binding = ExtensionDetailControllerBinding.inflate(themedInflater) + applyBottomInsetPadding(binding.extensionPrefsRecycler) return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt index dbb5e456a..61ce5ea64 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt @@ -32,9 +32,7 @@ class MigrationSourcesController : override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = MigrationSourcesControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt index 9865d0ab8..f0874d621 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt @@ -82,9 +82,7 @@ class SourceController : */ override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = SourceMainControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt index 08494dcfd..5d255bab8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt @@ -16,6 +16,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.ui.base.controller.NucleusController +import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController import eu.kanade.tachiyomi.ui.manga.MangaController @@ -59,6 +60,7 @@ open class GlobalSearchController( */ override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = GlobalSearchControllerBinding.inflate(inflater) + applyBottomInsetPadding(binding.recycler) return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt index fad67d09c..149460dc8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt @@ -79,9 +79,7 @@ class CategoryController : */ override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = CategoriesControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt index b9f3a4a39..ae57efbc5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt @@ -60,9 +60,7 @@ class DownloadController : override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = DownloadControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 03c5644a1..abc440688 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -195,9 +195,7 @@ class MangaController : override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = MangaControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt index 3d422ac86..8573a7922 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt @@ -1,11 +1,7 @@ package eu.kanade.tachiyomi.ui.more import android.content.Context -import android.os.Bundle import android.util.AttributeSet -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import androidx.preference.Preference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R @@ -13,7 +9,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadService import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController import eu.kanade.tachiyomi.ui.base.controller.RootController -import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.category.CategoryController import eu.kanade.tachiyomi.ui.download.DownloadController @@ -44,14 +39,6 @@ class MoreController : private var isDownloading: Boolean = false private var downloadQueueSize: Int = 0 - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View { - val view = super.onCreateView(inflater, container, savedInstanceState) - - applyBottomInsetPadding(view, view.context.resources.getDimensionPixelSize(R.dimen.action_toolbar_list_padding)) - - return view - } - override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { titleRes = R.string.label_more diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt index b4874230c..4825f9d49 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt @@ -69,9 +69,7 @@ class HistoryController : override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = HistoryControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index 40d79a256..196686544 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -75,9 +75,7 @@ class UpdatesController : override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { binding = UpdatesControllerBinding.inflate(inflater) - applyBottomInsetPadding(binding.recycler) - return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt index 62414f7ef..bc83df260 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt @@ -19,6 +19,8 @@ import com.bluelinelabs.conductor.ControllerChangeType import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.base.controller.BaseController +import eu.kanade.tachiyomi.ui.base.controller.RootController +import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding import eu.kanade.tachiyomi.util.system.getResourceColor import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -42,7 +44,19 @@ abstract class SettingsController : PreferenceController() { if (untilDestroySubscriptions.isUnsubscribed) { untilDestroySubscriptions = CompositeSubscription() } - return super.onCreateView(inflater, container, savedInstanceState) + + val view = super.onCreateView(inflater, container, savedInstanceState) + + if (this is RootController) { + applyBottomInsetPadding( + view, + view.context.resources.getDimensionPixelSize(R.dimen.action_toolbar_list_padding) + ) + } else { + applyBottomInsetPadding(view) + } + + return view } override fun onAttach(view: View) {