More bottom inset padding fixes

This commit is contained in:
arkon 2020-11-27 21:05:06 -05:00
parent 10163aab21
commit 776f6a9a16
13 changed files with 23 additions and 37 deletions

View File

@ -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)
}

View File

@ -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
}

View File

@ -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
}

View File

@ -32,9 +32,7 @@ class MigrationSourcesController :
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = MigrationSourcesControllerBinding.inflate(inflater)
applyBottomInsetPadding(binding.recycler)
return binding.root
}

View File

@ -82,9 +82,7 @@ class SourceController :
*/
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = SourceMainControllerBinding.inflate(inflater)
applyBottomInsetPadding(binding.recycler)
return binding.root
}

View File

@ -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
}

View File

@ -79,9 +79,7 @@ class CategoryController :
*/
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = CategoriesControllerBinding.inflate(inflater)
applyBottomInsetPadding(binding.recycler)
return binding.root
}

View File

@ -60,9 +60,7 @@ class DownloadController :
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = DownloadControllerBinding.inflate(inflater)
applyBottomInsetPadding(binding.recycler)
return binding.root
}

View File

@ -195,9 +195,7 @@ class MangaController :
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = MangaControllerBinding.inflate(inflater)
applyBottomInsetPadding(binding.recycler)
return binding.root
}

View File

@ -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

View File

@ -69,9 +69,7 @@ class HistoryController :
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = HistoryControllerBinding.inflate(inflater)
applyBottomInsetPadding(binding.recycler)
return binding.root
}

View File

@ -75,9 +75,7 @@ class UpdatesController :
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = UpdatesControllerBinding.inflate(inflater)
applyBottomInsetPadding(binding.recycler)
return binding.root
}

View File

@ -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) {