From becf936d4893d52f32ffbfd7ed0dac0d701660fc Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 1 Feb 2020 19:37:39 -0800 Subject: [PATCH] Fixes to insets and snackbars --- .../ui/library/LibraryCategoryView.kt | 5 +++-- .../kanade/tachiyomi/ui/main/MainActivity.kt | 3 +++ .../tachiyomi/util/view/ViewExtensions.kt | 19 +++++++++++----- app/src/main/res/layout/library_category.xml | 4 +++- .../main/res/layout/library_controller.xml | 4 ++-- app/src/main/res/layout/main_activity.xml | 22 +++++++++++++------ .../main/res/layout/reader_settings_sheet.xml | 10 ++++----- .../res/layout/recent_chapters_controller.xml | 8 ++++++- 8 files changed, 51 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt index 305e42addf..84024e4e22 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt @@ -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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 964b84a8f9..75b257ac43 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -226,6 +226,9 @@ open class MainActivity : BaseActivity() { }*/ v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop, insets.systemWindowInsetRight, 0) + view_offset.updateLayoutParams { + height = insets.systemWindowInsetBottom + } insets } val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 98645b0281..9a3c8bd4fa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -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) - textView.setTextColor(context.getResourceColor(R.attr.snackbar_text)) + val theme =Injekt.get().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 { bottomMargin = 12 + insets.systemWindowInsetBottom } - } + }*/ /*} else { snack.view.doOnApplyWindowInsets { _,_,_ -> } diff --git a/app/src/main/res/layout/library_category.xml b/app/src/main/res/layout/library_category.xml index 658fc28807..eb76505462 100644 --- a/app/src/main/res/layout/library_category.xml +++ b/app/src/main/res/layout/library_category.xml @@ -1,5 +1,7 @@ - - @@ -14,4 +14,4 @@ android:layout_width="wrap_content" android:layout_gravity="center" android:layout_height="wrap_content"/> - + diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 5e6270e9f0..5e4d91bcba 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -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"> + + + app:menu="@menu/bottom_navigation" + app:tabBackground="@color/rippleColor" + app:tabRippleColor="@color/rippleColor" + app:tabTextColor="?attr/tabBarIconColor" /> @@ -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" /> diff --git a/app/src/main/res/layout/recent_chapters_controller.xml b/app/src/main/res/layout/recent_chapters_controller.xml index 4976f585f1..57f5243b53 100644 --- a/app/src/main/res/layout/recent_chapters_controller.xml +++ b/app/src/main/res/layout/recent_chapters_controller.xml @@ -1,7 +1,12 @@ - + @@ -28,3 +33,4 @@ + \ No newline at end of file