Fixes to insets and snackbars

This commit is contained in:
Jay 2020-02-01 19:37:39 -08:00
parent a1d0d113b9
commit becf936d48
8 changed files with 51 additions and 24 deletions

View File

@ -6,6 +6,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import eu.davidea.flexibleadapter.FlexibleAdapter
@ -35,7 +36,7 @@ import uy.kohesive.injekt.injectLazy
* Fragment containing the library manga for a certain category.
*/
class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
FrameLayout(context, attrs),
CoordinatorLayout(context, attrs),
FlexibleAdapter.OnItemClickListener,
FlexibleAdapter.OnItemLongClickListener,
FlexibleAdapter.OnItemMoveListener,
@ -113,7 +114,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
swipe_refresh.setOnRefreshListener {
val inQueue = LibraryUpdateService.categoryInQueue(category.id)
controller.snack?.dismiss()
controller.snack = swipe_refresh.snack(
controller.snack = snack(
resources.getString(
when {
inQueue -> R.string.category_already_in_queue

View File

@ -226,6 +226,9 @@ open class MainActivity : BaseActivity() {
}*/
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
insets.systemWindowInsetRight, 0)
view_offset.updateLayoutParams<ViewGroup.MarginLayoutParams> {
height = insets.systemWindowInsetBottom
}
insets
}
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK

View File

@ -16,11 +16,14 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.appcompat.widget.SearchView
import androidx.core.view.ViewCompat
import com.amulyakhare.textdrawable.TextDrawable
import eu.kanade.tachiyomi.R
import com.amulyakhare.textdrawable.util.ColorGenerator
import com.bluelinelabs.conductor.Controller
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 uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
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.() ->
Unit)? = null): Snackbar {
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()
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 {
Build.VERSION.SDK_INT >= 23 -> {
val leftM = if (this is CoordinatorLayout) 0 else rootWindowInsets.systemWindowInsetLeft
@ -53,17 +61,16 @@ Unit)? = null): Snackbar {
}
else -> snack.config(context)
}*/
snack.config(context)
if (f != null) {
snack.f()
}
// 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, _ ->
snack.view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = 12 + insets.systemWindowInsetBottom
}
}
}*/
/*}
else {
snack.view.doOnApplyWindowInsets { _,_,_ -> }

View File

@ -1,5 +1,7 @@
<?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_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"

View File

@ -1,5 +1,5 @@
<?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_height="match_parent">
@ -14,4 +14,4 @@
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -56,28 +56,36 @@
android:id="@+id/controller_container"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/navigationView"
app:layout_constraintBottom_toBottomOf="@+id/view_offset"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appbar">
</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
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabBackground="@color/rippleColor"
app:itemIconTint="@drawable/bottom_nav_item_selector"
app:tabRippleColor="@color/rippleColor"
app:itemTextColor="?attr/tabBarIconColor"
app:tabTextColor="?attr/tabBarIconColor"
app:itemRippleColor="@color/rippleColor"
app:itemTextColor="?attr/tabBarIconColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="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>
<com.google.android.material.navigation.NavigationView

View File

@ -107,7 +107,7 @@
android:id="@+id/true_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="0dp"
android:text="@string/pref_true_color"
android:textColor="?android:attr/textColorSecondary"
android:visibility="gone"
@ -118,7 +118,7 @@
android:id="@+id/fullscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="0dp"
android:text="@string/pref_fullscreen"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/true_color" />
@ -127,7 +127,7 @@
android:id="@+id/keepscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="0dp"
android:text="@string/pref_keep_screen_on"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/fullscreen" />
@ -136,7 +136,7 @@
android:id="@+id/long_tap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="0dp"
android:text="@string/pref_read_with_long_tap"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/keepscreen" />
@ -209,7 +209,7 @@
android:id="@+id/page_transitions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="0dp"
android:text="@string/pref_page_transitions"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/crop_borders" />

View File

@ -1,7 +1,12 @@
<?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: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:layout_width="match_parent"
android:layout_height="match_parent">
@ -28,3 +33,4 @@
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>