mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-04 08:55:06 +01:00
More stuff
Cleartext (http sites) support Moved view extensions to view extensions Even more insets support
This commit is contained in:
parent
b94da6b3ed
commit
8b69813f34
@ -22,7 +22,8 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:theme="@style/Theme.Tachiyomi">
|
||||
android:theme="@style/Theme.Tachiyomi"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
<activity
|
||||
android:name=".ui.main.MainActivity"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -23,13 +23,12 @@ import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
||||
import eu.kanade.tachiyomi.ui.library.HeightTopWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.manga.info.MangaWebViewController
|
||||
import eu.kanade.tachiyomi.util.*
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import kotlinx.android.synthetic.main.catalogue_controller.*
|
||||
import kotlinx.android.synthetic.main.categories_item.view.*
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
@ -155,13 +154,22 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
presenter.sourceFilters = newFilters
|
||||
navView.setFilters(presenter.filterItems)
|
||||
}
|
||||
drawer.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
|
||||
val statusScrim = navView.findViewById(R.id.status_bar_scrim) as View
|
||||
statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener)
|
||||
val titleView = navView.findViewById(R.id.title_background) as View
|
||||
val titleMarginTop = titleView.marginTop
|
||||
navView.doOnApplyWindowInsets { v, insets, padding ->
|
||||
navView.recycler.updatePaddingRelative(
|
||||
bottom = padding.bottom + insets.systemWindowInsetBottom,
|
||||
top = padding.top + insets.systemWindowInsetTop
|
||||
v.updatePaddingRelative(
|
||||
bottom = padding.bottom + insets.systemWindowInsetBottom,
|
||||
end = padding.right + insets.systemWindowInsetRight
|
||||
)
|
||||
titleView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
topMargin = titleMarginTop + insets.systemWindowInsetTop
|
||||
}
|
||||
}
|
||||
return navView
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller.*
|
||||
|
||||
/**
|
||||
@ -133,6 +134,7 @@ open class CatalogueSearchController(
|
||||
// Create recycler and set adapter.
|
||||
recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
recycler.adapter = adapter
|
||||
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
|
@ -13,7 +13,11 @@ import eu.davidea.flexibleadapter.helpers.UndoHelper
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.util.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.util.marginBottom
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import eu.kanade.tachiyomi.util.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.updatePaddingRelative
|
||||
import kotlinx.android.synthetic.main.categories_controller.*
|
||||
|
||||
/**
|
||||
@ -83,6 +87,14 @@ class CategoryController : NucleusController<CategoryPresenter>(),
|
||||
fab.clicks().subscribeUntilDestroy {
|
||||
CategoryCreateDialog(this@CategoryController).showDialog(router, null)
|
||||
}
|
||||
|
||||
val fabBaseMarginBottom = fab?.marginBottom ?: 0
|
||||
recycler.doOnApplyWindowInsets { v, insets, padding ->
|
||||
v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom)
|
||||
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.data.download.DownloadService
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
||||
import kotlinx.android.synthetic.main.download_controller.*
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
@ -64,6 +65,7 @@ class DownloadController : NucleusController<DownloadPresenter>() {
|
||||
// Set the layout manager for the recycler and fixed size.
|
||||
recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
recycler.setHasFixedSize(true)
|
||||
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
|
||||
// Suscribe to changes
|
||||
DownloadService.runningRelay
|
||||
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
||||
import kotlinx.android.synthetic.main.extension_controller.*
|
||||
|
||||
|
||||
@ -58,6 +59,7 @@ open class ExtensionController : NucleusController<ExtensionPresenter>(),
|
||||
ext_recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
ext_recycler.adapter = adapter
|
||||
ext_recycler.addItemDecoration(ExtensionDividerItemDecoration(view.context))
|
||||
ext_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
|
@ -13,11 +13,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.util.inflate
|
||||
import eu.kanade.tachiyomi.util.plusAssign
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import eu.kanade.tachiyomi.util.*
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import kotlinx.android.synthetic.main.library_category.view.*
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
|
@ -32,16 +32,9 @@ import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.category.CategoryController
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.ui.main.marginBottom
|
||||
import eu.kanade.tachiyomi.ui.main.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||
import eu.kanade.tachiyomi.util.inflate
|
||||
import eu.kanade.tachiyomi.util.marginTop
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import kotlinx.android.synthetic.main.chapters_controller.*
|
||||
import eu.kanade.tachiyomi.util.*
|
||||
import kotlinx.android.synthetic.main.library_controller.*
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import rx.Subscription
|
||||
@ -202,8 +195,9 @@ class LibraryController(
|
||||
statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener)
|
||||
view.doOnApplyWindowInsets { v, insets, padding ->
|
||||
view.recycler.updatePaddingRelative(
|
||||
bottom = view.recycler.marginBottom + insets.systemWindowInsetBottom,
|
||||
top = view.recycler.marginTop + insets.systemWindowInsetTop
|
||||
bottom = view.recycler.marginBottom + insets.systemWindowInsetBottom,
|
||||
top = view.recycler.marginTop + insets.systemWindowInsetTop,
|
||||
end = view.recycler.marginRight + insets.systemWindowInsetRight
|
||||
)
|
||||
}
|
||||
return view
|
||||
|
@ -36,7 +36,10 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
||||
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||
import eu.kanade.tachiyomi.util.NoopWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.util.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.updatePaddingRelative
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@ -320,84 +323,3 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||
v.setPadding(insets.systemWindowInsetLeft,insets.systemWindowInsetTop,insets.systemWindowInsetRight,0)
|
||||
//insets.consumeSystemWindowInsets()
|
||||
return insets
|
||||
}
|
||||
}
|
||||
|
||||
object NoopWindowInsetsListener2 : View.OnApplyWindowInsetsListener {
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||
v.setPadding(0,0,0,insets
|
||||
.systemWindowInsetBottom)
|
||||
insets.consumeSystemWindowInsets()
|
||||
return insets
|
||||
}
|
||||
}
|
||||
|
||||
fun View.doOnApplyWindowInsets(f: (View, WindowInsets, ViewPaddingState) -> Unit) {
|
||||
// Create a snapshot of the view's padding state
|
||||
val paddingState = createStateForView(this)
|
||||
setOnApplyWindowInsetsListener { v, insets ->
|
||||
f(v, insets, paddingState)
|
||||
insets
|
||||
}
|
||||
requestApplyInsetsWhenAttached()
|
||||
}
|
||||
|
||||
fun View.requestApplyInsetsWhenAttached() {
|
||||
if (isAttachedToWindow) {
|
||||
requestApplyInsets()
|
||||
} else {
|
||||
addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
v.requestApplyInsets()
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(v: View) = Unit
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : ViewGroup.LayoutParams> View.updateLayoutParams(block: T.() -> Unit) {
|
||||
val params = layoutParams as T
|
||||
block(params)
|
||||
layoutParams = params
|
||||
}
|
||||
|
||||
inline val View.marginBottom: Int
|
||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.bottomMargin ?: 0
|
||||
|
||||
inline fun View.updatePadding(
|
||||
@Px left: Int = paddingLeft,
|
||||
@Px top: Int = paddingTop,
|
||||
@Px right: Int = paddingRight,
|
||||
@Px bottom: Int = paddingBottom
|
||||
) {
|
||||
setPadding(left, top, right, bottom)
|
||||
}
|
||||
|
||||
private fun createStateForView(view: View) = ViewPaddingState(view.paddingLeft,
|
||||
view.paddingTop, view.paddingRight, view.paddingBottom, view.paddingStart, view.paddingEnd)
|
||||
|
||||
data class ViewPaddingState(
|
||||
val left: Int,
|
||||
val top: Int,
|
||||
val right: Int,
|
||||
val bottom: Int,
|
||||
val start: Int,
|
||||
val end: Int
|
||||
)
|
||||
|
||||
@RequiresApi(17)
|
||||
inline fun View.updatePaddingRelative(
|
||||
@Px start: Int = paddingStart,
|
||||
@Px top: Int = paddingTop,
|
||||
@Px end: Int = paddingEnd,
|
||||
@Px bottom: Int = paddingBottom
|
||||
) {
|
||||
setPaddingRelative(start, top, end, bottom)
|
||||
}
|
@ -21,17 +21,9 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
||||
import eu.kanade.tachiyomi.ui.main.NoopWindowInsetsListener2
|
||||
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.ui.main.marginBottom
|
||||
import eu.kanade.tachiyomi.ui.main.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.ui.main.updatePadding
|
||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.getCoordinates
|
||||
import eu.kanade.tachiyomi.util.snack
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import eu.kanade.tachiyomi.util.*
|
||||
import kotlinx.android.synthetic.main.chapters_controller.*
|
||||
import timber.log.Timber
|
||||
|
||||
|
@ -40,14 +40,8 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
|
||||
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.snack
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import eu.kanade.tachiyomi.util.truncateCenter
|
||||
import eu.kanade.tachiyomi.util.*
|
||||
import jp.wasabeef.glide.transformations.CropSquareTransformation
|
||||
import jp.wasabeef.glide.transformations.MaskTransformation
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.*
|
||||
|
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
||||
import kotlinx.android.synthetic.main.migration_controller.*
|
||||
|
||||
class MigrationController : NucleusController<MigrationPresenter>(),
|
||||
@ -43,6 +44,7 @@ class MigrationController : NucleusController<MigrationPresenter>(),
|
||||
adapter = FlexibleAdapter(null, this)
|
||||
migration_recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
migration_recycler.adapter = adapter
|
||||
migration_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
|
@ -21,9 +21,6 @@ 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.ui.base.activity.BaseRxActivity
|
||||
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.ui.main.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.AddToLibraryFirst
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Error
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Success
|
||||
|
@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import kotlinx.android.synthetic.main.recent_chapters_controller.*
|
||||
import timber.log.Timber
|
||||
@ -90,6 +91,7 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
// It can be a very long operation, so we disable swipe refresh and show a toast.
|
||||
swipe_refresh.isRefreshing = false
|
||||
}
|
||||
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
|
@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import kotlinx.android.synthetic.main.recently_read_controller.*
|
||||
|
||||
@ -58,6 +59,7 @@ class RecentlyReadController : NucleusController<RecentlyReadPresenter>(),
|
||||
adapter = RecentlyReadAdapter(this@RecentlyReadController)
|
||||
recycler.setHasFixedSize(true)
|
||||
recycler.adapter = adapter
|
||||
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
|
@ -15,6 +15,9 @@ 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.util.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.util.updatePaddingRelative
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
@ -32,7 +35,9 @@ abstract class SettingsController : PreferenceController() {
|
||||
if (untilDestroySubscriptions.isUnsubscribed) {
|
||||
untilDestroySubscriptions = CompositeSubscription()
|
||||
}
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
val view = super.onCreateView(inflater, container, savedInstanceState)
|
||||
listView.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
|
@ -7,6 +7,8 @@ import android.graphics.Color
|
||||
import android.graphics.Point
|
||||
import android.graphics.Typeface
|
||||
import android.os.Build
|
||||
import android.support.annotation.Px
|
||||
import android.support.annotation.RequiresApi
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v4.view.ViewCompat
|
||||
import android.support.v4.view.WindowInsetsCompat
|
||||
@ -18,10 +20,6 @@ import android.widget.TextView
|
||||
import com.amulyakhare.textdrawable.TextDrawable
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.ui.main.marginBottom
|
||||
import eu.kanade.tachiyomi.ui.main.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||
|
||||
/**
|
||||
* Returns coordinates of view.
|
||||
@ -97,3 +95,89 @@ fun View.getRound(text: String, random : Boolean = true): TextDrawable {
|
||||
|
||||
inline val View.marginTop: Int
|
||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin ?: 0
|
||||
|
||||
inline val View.marginBottom: Int
|
||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.bottomMargin ?: 0
|
||||
|
||||
inline val View.marginRight: Int
|
||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.rightMargin ?: 0
|
||||
|
||||
inline val View.marginLeft: Int
|
||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.leftMargin ?: 0
|
||||
|
||||
object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||
v.setPadding(insets.systemWindowInsetLeft,insets.systemWindowInsetTop,insets.systemWindowInsetRight,0)
|
||||
//insets.consumeSystemWindowInsets()
|
||||
return insets
|
||||
}
|
||||
}
|
||||
|
||||
object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||
v.setPadding(0,0,0,insets.systemWindowInsetBottom)
|
||||
//v.updatePaddingRelative(bottom = v.paddingBottom + insets.systemWindowInsetBottom)
|
||||
return insets
|
||||
}
|
||||
}
|
||||
|
||||
fun View.doOnApplyWindowInsets(f: (View, WindowInsets, ViewPaddingState) -> Unit) {
|
||||
// Create a snapshot of the view's padding state
|
||||
val paddingState = createStateForView(this)
|
||||
setOnApplyWindowInsetsListener { v, insets ->
|
||||
f(v, insets, paddingState)
|
||||
insets
|
||||
}
|
||||
requestApplyInsetsWhenAttached()
|
||||
}
|
||||
|
||||
fun View.requestApplyInsetsWhenAttached() {
|
||||
if (isAttachedToWindow) {
|
||||
requestApplyInsets()
|
||||
} else {
|
||||
addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
v.requestApplyInsets()
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(v: View) = Unit
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : ViewGroup.LayoutParams> View.updateLayoutParams(block: T.() -> Unit) {
|
||||
val params = layoutParams as T
|
||||
block(params)
|
||||
layoutParams = params
|
||||
}
|
||||
|
||||
inline fun View.updatePadding(
|
||||
@Px left: Int = paddingLeft,
|
||||
@Px top: Int = paddingTop,
|
||||
@Px right: Int = paddingRight,
|
||||
@Px bottom: Int = paddingBottom
|
||||
) {
|
||||
setPadding(left, top, right, bottom)
|
||||
}
|
||||
|
||||
private fun createStateForView(view: View) = ViewPaddingState(view.paddingLeft,
|
||||
view.paddingTop, view.paddingRight, view.paddingBottom, view.paddingStart, view.paddingEnd)
|
||||
|
||||
data class ViewPaddingState(
|
||||
val left: Int,
|
||||
val top: Int,
|
||||
val right: Int,
|
||||
val bottom: Int,
|
||||
val start: Int,
|
||||
val end: Int
|
||||
)
|
||||
|
||||
@RequiresApi(17)
|
||||
inline fun View.updatePaddingRelative(
|
||||
@Px start: Int = paddingStart,
|
||||
@Px top: Int = paddingTop,
|
||||
@Px end: Int = paddingEnd,
|
||||
@Px bottom: Int = paddingBottom
|
||||
) {
|
||||
setPaddingRelative(start, top, end, bottom)
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/recycler"
|
||||
android:choiceMode="multipleChoice"
|
||||
android:clipToPadding="false"
|
||||
tools:listitem="@layout/categories_item"
|
||||
/>
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/recycler"
|
||||
android:clipToPadding="false"
|
||||
tools:listitem="@layout/download_item"/>
|
||||
|
||||
<eu.kanade.tachiyomi.widget.EmptyView
|
||||
|
@ -10,6 +10,7 @@
|
||||
android:id="@+id/ext_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
tools:listitem="@layout/extension_card_header"/>
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
@ -3,4 +3,5 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/migration_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"/>
|
||||
|
@ -15,6 +15,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:clipToPadding="false"
|
||||
tools:listitem="@layout/recent_chapters_item"/>
|
||||
|
||||
<eu.kanade.tachiyomi.widget.EmptyView
|
||||
|
8
app/src/main/res/xml/network_security_config.xml
Normal file
8
app/src/main/res/xml/network_security_config.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true">
|
||||
<trust-anchors>
|
||||
<certificates src="system" />
|
||||
</trust-anchors>
|
||||
</base-config>
|
||||
</network-security-config>
|
Loading…
Reference in New Issue
Block a user