mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 07:39:10 +01:00
more insets work
This commit is contained in:
parent
b9e3e3de55
commit
3930345cbd
@ -22,6 +22,7 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController
|
import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
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.doOnApplyWindowInsets
|
||||||
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
@ -154,9 +155,10 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||||||
presenter.sourceFilters = newFilters
|
presenter.sourceFilters = newFilters
|
||||||
navView.setFilters(presenter.filterItems)
|
navView.setFilters(presenter.filterItems)
|
||||||
}
|
}
|
||||||
|
val statusScrim = navView.findViewById(R.id.status_bar_scrim) as View
|
||||||
|
statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener)
|
||||||
navView.doOnApplyWindowInsets { v, insets, padding ->
|
navView.doOnApplyWindowInsets { v, insets, padding ->
|
||||||
v.updatePaddingRelative(
|
navView.recycler.updatePaddingRelative(
|
||||||
bottom = padding.bottom + insets.systemWindowInsetBottom,
|
bottom = padding.bottom + insets.systemWindowInsetBottom,
|
||||||
top = padding.top + insets.systemWindowInsetTop
|
top = padding.top + insets.systemWindowInsetTop
|
||||||
)
|
)
|
||||||
|
@ -191,10 +191,16 @@ class LibraryController(
|
|||||||
is LibraryNavigationView.BadgeGroup -> onDownloadBadgeChanged()
|
is LibraryNavigationView.BadgeGroup -> onDownloadBadgeChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = view.findViewById(R.id.status_bar_scrim) as View
|
||||||
|
statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener)
|
||||||
view.doOnApplyWindowInsets { v, insets, padding ->
|
view.doOnApplyWindowInsets { v, insets, padding ->
|
||||||
v.updatePaddingRelative(
|
view.recycler.updatePaddingRelative(
|
||||||
bottom = padding.bottom + insets.systemWindowInsetBottom,
|
bottom = view.recycler.bottom + insets.systemWindowInsetBottom,
|
||||||
top = padding.top + insets.systemWindowInsetTop
|
top = view.recycler.top + insets.systemWindowInsetTop
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return view
|
return view
|
||||||
@ -530,3 +536,15 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object HeightTopWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||||
|
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||||
|
val topInset = insets.systemWindowInsetTop
|
||||||
|
v.setPadding(0,topInset,0,0)
|
||||||
|
if (v.layoutParams.height != topInset) {
|
||||||
|
v.layoutParams.height = topInset
|
||||||
|
v.requestLayout()
|
||||||
|
}
|
||||||
|
return insets
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,9 @@ import android.app.SearchManager
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.support.annotation.NonNull
|
||||||
import android.support.annotation.Px
|
import android.support.annotation.Px
|
||||||
import android.support.annotation.RequiresApi
|
import android.support.annotation.RequiresApi
|
||||||
import android.support.v4.view.GravityCompat
|
import android.support.v4.view.GravityCompat
|
||||||
@ -120,6 +122,12 @@ class MainActivity : BaseActivity() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav_view.doOnApplyWindowInsets { v, insets, padding ->
|
||||||
|
v.updatePaddingRelative(
|
||||||
|
start = padding.left + insets.systemWindowInsetLeft
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val container: ViewGroup = findViewById(R.id.controller_container)
|
val container: ViewGroup = findViewById(R.id.controller_container)
|
||||||
|
|
||||||
val content: LinearLayout = findViewById(R.id.main_content)
|
val content: LinearLayout = findViewById(R.id.main_content)
|
||||||
@ -130,6 +138,10 @@ class MainActivity : BaseActivity() {
|
|||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
content.setOnApplyWindowInsetsListener(NoopWindowInsetsListener)
|
content.setOnApplyWindowInsetsListener(NoopWindowInsetsListener)
|
||||||
|
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
|
if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) {
|
||||||
|
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
|
}
|
||||||
|
|
||||||
router = Conductor.attachRouter(this, container, savedInstanceState)
|
router = Conductor.attachRouter(this, container, savedInstanceState)
|
||||||
if (!router.hasRootController()) {
|
if (!router.hasRootController()) {
|
||||||
@ -319,16 +331,17 @@ object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
|||||||
|
|
||||||
object NoopWindowInsetsListener2 : View.OnApplyWindowInsetsListener {
|
object NoopWindowInsetsListener2 : View.OnApplyWindowInsetsListener {
|
||||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||||
v.setPadding(0,0,0,insets.systemWindowInsetBottom)
|
v.setPadding(0,0,0,insets
|
||||||
|
.systemWindowInsetBottom)
|
||||||
insets.consumeSystemWindowInsets()
|
insets.consumeSystemWindowInsets()
|
||||||
return insets
|
return insets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun View.doOnApplyWindowInsets(f: (View, WindowInsetsCompat, ViewPaddingState) -> Unit) {
|
fun View.doOnApplyWindowInsets(f: (View, WindowInsets, ViewPaddingState) -> Unit) {
|
||||||
// Create a snapshot of the view's padding state
|
// Create a snapshot of the view's padding state
|
||||||
val paddingState = createStateForView(this)
|
val paddingState = createStateForView(this)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
|
setOnApplyWindowInsetsListener { v, insets ->
|
||||||
f(v, insets, paddingState)
|
f(v, insets, paddingState)
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,6 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||||||
bottomMargin = insets.systemWindowInsetBottom
|
bottomMargin = insets.systemWindowInsetBottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fast_scroller.setOnApplyWindowInsetsListener(NoopWindowInsetsListener2)
|
|
||||||
swipe_refresh.refreshes().subscribeUntilDestroy { fetchChaptersFromSource() }
|
swipe_refresh.refreshes().subscribeUntilDestroy { fetchChaptersFromSource() }
|
||||||
|
|
||||||
fab.clicks().subscribeUntilDestroy {
|
fab.clicks().subscribeUntilDestroy {
|
||||||
|
@ -21,6 +21,9 @@ 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.ui.base.activity.BaseRxActivity
|
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.AddToLibraryFirst
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Error
|
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Error
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Success
|
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Success
|
||||||
@ -136,6 +139,16 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
|
|
||||||
config = ReaderConfig()
|
config = ReaderConfig()
|
||||||
initializeMenu()
|
initializeMenu()
|
||||||
|
val container: ViewGroup = findViewById(R.id.reader_container)
|
||||||
|
val readerBHeight = reader_menu_bottom.layoutParams.height
|
||||||
|
container.doOnApplyWindowInsets { _, insets, padding ->
|
||||||
|
val bottomInset = insets.mandatorySystemGestureInsets.bottom - insets
|
||||||
|
.systemWindowInsetBottom
|
||||||
|
reader_menu_bottom.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
|
height = readerBHeight + bottomInset
|
||||||
|
}
|
||||||
|
reader_menu_bottom.updatePaddingRelative(bottom = padding.bottom + bottomInset)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,14 +2,26 @@
|
|||||||
|
|
||||||
package eu.kanade.tachiyomi.util
|
package eu.kanade.tachiyomi.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.os.Build
|
||||||
import android.support.design.widget.Snackbar
|
import android.support.design.widget.Snackbar
|
||||||
|
import android.support.v4.view.ViewCompat
|
||||||
|
import android.support.v4.view.WindowInsetsCompat
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.Window
|
||||||
|
import android.view.WindowInsets
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.amulyakhare.textdrawable.TextDrawable
|
import com.amulyakhare.textdrawable.TextDrawable
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
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.
|
* Returns coordinates of view.
|
||||||
@ -30,11 +42,25 @@ inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Sn
|
|||||||
val snack = Snackbar.make(this, message, length)
|
val snack = Snackbar.make(this, message, length)
|
||||||
val textView: TextView = snack.view.findViewById(android.support.design.R.id.snackbar_text)
|
val textView: TextView = snack.view.findViewById(android.support.design.R.id.snackbar_text)
|
||||||
textView.setTextColor(Color.WHITE)
|
textView.setTextColor(Color.WHITE)
|
||||||
|
when {
|
||||||
|
Build.VERSION.SDK_INT >= 23 -> snack.config(context, rootWindowInsets.systemWindowInsetBottom)
|
||||||
|
else -> snack.config(context)
|
||||||
|
}
|
||||||
snack.f()
|
snack.f()
|
||||||
snack.show()
|
snack.show()
|
||||||
return snack
|
return snack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Snackbar.config(context: Context, bottomMargin: Int = 0) {
|
||||||
|
val params = this.view.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
|
params.setMargins(12, 12, 12, 12 + bottomMargin)
|
||||||
|
this.view.layoutParams = params
|
||||||
|
|
||||||
|
this.view.background = context.getDrawable(R.drawable.bg_snackbar)
|
||||||
|
|
||||||
|
ViewCompat.setElevation(this.view, 6f)
|
||||||
|
}
|
||||||
|
|
||||||
inline fun View.visible() {
|
inline fun View.visible() {
|
||||||
visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ open class SimpleNavigationView @JvmOverloads constructor(
|
|||||||
/**
|
/**
|
||||||
* Recycler view containing all the items.
|
* Recycler view containing all the items.
|
||||||
*/
|
*/
|
||||||
protected val recycler = RecyclerView(context)
|
val recycler = RecyclerView(context)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Custom attributes
|
// Custom attributes
|
||||||
@ -57,6 +57,7 @@ open class SimpleNavigationView @JvmOverloads constructor(
|
|||||||
a.recycle()
|
a.recycle()
|
||||||
|
|
||||||
recycler.layoutManager = LinearLayoutManager(context)
|
recycler.layoutManager = LinearLayoutManager(context)
|
||||||
|
recycler.clipToPadding = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
6
app/src/main/res/drawable/bg_snackbar.xml
Normal file
6
app/src/main/res/drawable/bg_snackbar.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#323232" />
|
||||||
|
<corners android:radius="4dp" />
|
||||||
|
</shape>
|
@ -5,5 +5,10 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:fitsSystemWindows="true"/>
|
android:fitsSystemWindows="true">
|
||||||
|
<View
|
||||||
|
android:id="@+id/status_bar_scrim"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="?attr/colorPrimary" />
|
||||||
|
</eu.kanade.tachiyomi.ui.catalogue.browse.CatalogueNavigationView>
|
||||||
|
@ -5,4 +5,11 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:fitsSystemWindows="true" />
|
android:fitsSystemWindows="true"
|
||||||
|
android:clipToPadding="true">
|
||||||
|
<View
|
||||||
|
android:id="@+id/status_bar_scrim"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="?attr/colorPrimary" />
|
||||||
|
</eu.kanade.tachiyomi.ui.library.LibraryNavigationView>
|
2
app/src/main/res/values-notnight-v29/themes.xml
Normal file
2
app/src/main/res/values-notnight-v29/themes.xml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources></resources>
|
Loading…
x
Reference in New Issue
Block a user