mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 14:49:08 +01:00
Fixes to insets and snackbars
This commit is contained in:
parent
a1d0d113b9
commit
becf936d48
@ -6,6 +6,7 @@ import android.view.MotionEvent
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
@ -35,7 +36,7 @@ import uy.kohesive.injekt.injectLazy
|
|||||||
* Fragment containing the library manga for a certain category.
|
* Fragment containing the library manga for a certain category.
|
||||||
*/
|
*/
|
||||||
class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
FrameLayout(context, attrs),
|
CoordinatorLayout(context, attrs),
|
||||||
FlexibleAdapter.OnItemClickListener,
|
FlexibleAdapter.OnItemClickListener,
|
||||||
FlexibleAdapter.OnItemLongClickListener,
|
FlexibleAdapter.OnItemLongClickListener,
|
||||||
FlexibleAdapter.OnItemMoveListener,
|
FlexibleAdapter.OnItemMoveListener,
|
||||||
@ -113,7 +114,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
swipe_refresh.setOnRefreshListener {
|
swipe_refresh.setOnRefreshListener {
|
||||||
val inQueue = LibraryUpdateService.categoryInQueue(category.id)
|
val inQueue = LibraryUpdateService.categoryInQueue(category.id)
|
||||||
controller.snack?.dismiss()
|
controller.snack?.dismiss()
|
||||||
controller.snack = swipe_refresh.snack(
|
controller.snack = snack(
|
||||||
resources.getString(
|
resources.getString(
|
||||||
when {
|
when {
|
||||||
inQueue -> R.string.category_already_in_queue
|
inQueue -> R.string.category_already_in_queue
|
||||||
|
@ -226,6 +226,9 @@ open class MainActivity : BaseActivity() {
|
|||||||
}*/
|
}*/
|
||||||
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
|
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
|
||||||
insets.systemWindowInsetRight, 0)
|
insets.systemWindowInsetRight, 0)
|
||||||
|
view_offset.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
|
height = insets.systemWindowInsetBottom
|
||||||
|
}
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
|
@ -16,11 +16,14 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import com.amulyakhare.textdrawable.TextDrawable
|
import com.amulyakhare.textdrawable.TextDrawable
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,8 +44,13 @@ fun View.getCoordinates() = Point((left + right) / 2, (top + bottom) / 2)
|
|||||||
fun View.snack(message: String, length: Int = Snackbar.LENGTH_SHORT, f: (Snackbar.() ->
|
fun View.snack(message: String, length: Int = Snackbar.LENGTH_SHORT, f: (Snackbar.() ->
|
||||||
Unit)? = null): Snackbar {
|
Unit)? = null): Snackbar {
|
||||||
val snack = Snackbar.make(this, message, length)
|
val snack = Snackbar.make(this, message, length)
|
||||||
val textView: TextView = snack.view.findViewById(com.google.android.material.R.id.snackbar_text)
|
val theme =Injekt.get<PreferencesHelper>().theme()
|
||||||
textView.setTextColor(context.getResourceColor(R.attr.snackbar_text))
|
if (theme == 3 || theme == 6) {
|
||||||
|
val textView: TextView =
|
||||||
|
snack.view.findViewById(com.google.android.material.R.id.snackbar_text)
|
||||||
|
textView.setTextColor(context.getResourceColor(R.attr.snackbar_text))
|
||||||
|
snack.config(context)
|
||||||
|
}
|
||||||
/* when {
|
/* when {
|
||||||
Build.VERSION.SDK_INT >= 23 -> {
|
Build.VERSION.SDK_INT >= 23 -> {
|
||||||
val leftM = if (this is CoordinatorLayout) 0 else rootWindowInsets.systemWindowInsetLeft
|
val leftM = if (this is CoordinatorLayout) 0 else rootWindowInsets.systemWindowInsetLeft
|
||||||
@ -53,17 +61,16 @@ Unit)? = null): Snackbar {
|
|||||||
}
|
}
|
||||||
else -> snack.config(context)
|
else -> snack.config(context)
|
||||||
}*/
|
}*/
|
||||||
snack.config(context)
|
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
snack.f()
|
snack.f()
|
||||||
}
|
}
|
||||||
// if (Build.VERSION.SDK_INT < 23) {
|
// if (Build.VERSION.SDK_INT < 23) {
|
||||||
val view = if (this !is CoordinatorLayout) this else snack.view
|
/* val view = if (this !is CoordinatorLayout) this else snack.view
|
||||||
view.doOnApplyWindowInsets { _, insets, _ ->
|
view.doOnApplyWindowInsets { _, insets, _ ->
|
||||||
snack.view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
snack.view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = 12 + insets.systemWindowInsetBottom
|
bottomMargin = 12 + insets.systemWindowInsetBottom
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
/*}
|
/*}
|
||||||
else {
|
else {
|
||||||
snack.view.doOnApplyWindowInsets { _,_,_ -> }
|
snack.view.doOnApplyWindowInsets { _,_,_ -> }
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<eu.kanade.tachiyomi.ui.library.LibraryCategoryView xmlns:android="http://schemas.android.com/apk/res/android"
|
<eu.kanade.tachiyomi.ui.library.LibraryCategoryView
|
||||||
|
android:id="@+id/layout"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@ -14,4 +14,4 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
</FrameLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -56,28 +56,36 @@
|
|||||||
android:id="@+id/controller_container"
|
android:id="@+id/controller_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/navigationView"
|
app:layout_constraintBottom_toBottomOf="@+id/view_offset"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/appbar">
|
app:layout_constraintTop_toBottomOf="@+id/appbar">
|
||||||
|
|
||||||
</com.bluelinelabs.conductor.ChangeHandlerFrameLayout>
|
</com.bluelinelabs.conductor.ChangeHandlerFrameLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/view_offset"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/navigationView" />
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/navigationView"
|
android:id="@+id/navigationView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
app:tabBackground="@color/rippleColor"
|
|
||||||
app:itemIconTint="@drawable/bottom_nav_item_selector"
|
app:itemIconTint="@drawable/bottom_nav_item_selector"
|
||||||
app:tabRippleColor="@color/rippleColor"
|
|
||||||
app:itemTextColor="?attr/tabBarIconColor"
|
|
||||||
app:tabTextColor="?attr/tabBarIconColor"
|
|
||||||
app:itemRippleColor="@color/rippleColor"
|
app:itemRippleColor="@color/rippleColor"
|
||||||
|
app:itemTextColor="?attr/tabBarIconColor"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:menu="@menu/bottom_navigation"
|
||||||
app:menu="@menu/bottom_navigation" />
|
app:tabBackground="@color/rippleColor"
|
||||||
|
app:tabRippleColor="@color/rippleColor"
|
||||||
|
app:tabTextColor="?attr/tabBarIconColor" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<com.google.android.material.navigation.NavigationView
|
<com.google.android.material.navigation.NavigationView
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
android:id="@+id/true_color"
|
android:id="@+id/true_color"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="0dp"
|
||||||
android:text="@string/pref_true_color"
|
android:text="@string/pref_true_color"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
@ -118,7 +118,7 @@
|
|||||||
android:id="@+id/fullscreen"
|
android:id="@+id/fullscreen"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="0dp"
|
||||||
android:text="@string/pref_fullscreen"
|
android:text="@string/pref_fullscreen"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintTop_toBottomOf="@id/true_color" />
|
app:layout_constraintTop_toBottomOf="@id/true_color" />
|
||||||
@ -127,7 +127,7 @@
|
|||||||
android:id="@+id/keepscreen"
|
android:id="@+id/keepscreen"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="0dp"
|
||||||
android:text="@string/pref_keep_screen_on"
|
android:text="@string/pref_keep_screen_on"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintTop_toBottomOf="@id/fullscreen" />
|
app:layout_constraintTop_toBottomOf="@id/fullscreen" />
|
||||||
@ -136,7 +136,7 @@
|
|||||||
android:id="@+id/long_tap"
|
android:id="@+id/long_tap"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="0dp"
|
||||||
android:text="@string/pref_read_with_long_tap"
|
android:text="@string/pref_read_with_long_tap"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintTop_toBottomOf="@id/keepscreen" />
|
app:layout_constraintTop_toBottomOf="@id/keepscreen" />
|
||||||
@ -209,7 +209,7 @@
|
|||||||
android:id="@+id/page_transitions"
|
android:id="@+id/page_transitions"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="0dp"
|
||||||
android:text="@string/pref_page_transitions"
|
android:text="@string/pref_page_transitions"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintTop_toBottomOf="@id/crop_borders" />
|
app:layout_constraintTop_toBottomOf="@id/crop_borders" />
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/swipe_refresh"
|
android:id="@+id/swipe_refresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -28,3 +33,4 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
x
Reference in New Issue
Block a user