Fix snackbar in feed screen for tablets
This commit is contained in:
@@ -245,8 +245,7 @@ class MainActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun onError(e: Throwable) {
|
private fun onError(e: Throwable) {
|
||||||
Snackbar.make(binding.container, e.getDisplayMessage(resources), Snackbar.LENGTH_SHORT).setAnchorView(bottomNav)
|
Snackbar.make(binding.container, e.getDisplayMessage(resources), Snackbar.LENGTH_SHORT).show()
|
||||||
.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onCountersChanged(counters: SparseIntArray) {
|
private fun onCountersChanged(counters: SparseIntArray) {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class FeedFragment :
|
|||||||
addMenuProvider(
|
addMenuProvider(
|
||||||
FeedMenuProvider(
|
FeedMenuProvider(
|
||||||
binding.recyclerView,
|
binding.recyclerView,
|
||||||
(activity as? BottomNavOwner)?.bottomNav ?: binding.recyclerView,
|
(activity as? BottomNavOwner)?.bottomNav,
|
||||||
viewModel,
|
viewModel,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.koitharu.kotatsu.tracker.work.TrackWorker
|
|||||||
|
|
||||||
class FeedMenuProvider(
|
class FeedMenuProvider(
|
||||||
private val snackbarHost: View,
|
private val snackbarHost: View,
|
||||||
private val anchorView: View,
|
private val anchorView: View?,
|
||||||
private val viewModel: FeedViewModel,
|
private val viewModel: FeedViewModel,
|
||||||
) : MenuProvider {
|
) : MenuProvider {
|
||||||
|
|
||||||
|
|||||||
@@ -129,14 +129,6 @@ fun Context.getAnimationDuration(@IntegerRes resId: Int): Long {
|
|||||||
return (resources.getInteger(resId) * animatorDurationScale).roundToLong()
|
return (resources.getInteger(resId) * animatorDurationScale).roundToLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T> ViewGroup.findChild(): T? {
|
|
||||||
return children.find { it is T } as? T
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <reified T> ViewGroup.findDescendant(): T? {
|
|
||||||
return descendants.find { it is T } as? T
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isLowRamDevice(context: Context): Boolean {
|
fun isLowRamDevice(context: Context): Boolean {
|
||||||
return context.activityManager?.isLowRamDevice ?: false
|
return context.activityManager?.isLowRamDevice ?: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<solid android:color="@color/toolbar_background_scrim" />
|
<solid android:color="@color/toolbar_background_scrim" />
|
||||||
<corners android:radius="100dp" />
|
<corners android:radius="100dp" />
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
69
app/src/main/res/layout-w600dp/activity_categories.xml
Normal file
69
app/src/main/res/layout-w600dp/activity_categories.xml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:id="@+id/collapsingToolbarLayout"
|
||||||
|
style="?attr/collapsingToolbarLayoutLargeStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/collapsingToolbarLayoutLargeSize"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
|
||||||
|
app:toolbarId="@id/toolbar">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:layout_collapseMode="pin">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_done"
|
||||||
|
style="@style/Widget.Material3.Button.UnelevatedButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_marginHorizontal="@dimen/toolbar_button_margin"
|
||||||
|
android:text="@string/done"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.MaterialToolbar>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
|
android:id="@+id/fab_add"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:contentDescription="@string/add_new_category"
|
||||||
|
android:src="@drawable/ic_add"
|
||||||
|
android:text="@string/create_category"
|
||||||
|
app:fabSize="normal"
|
||||||
|
app:icon="@drawable/ic_add"
|
||||||
|
app:layout_anchor="@id/recyclerView"
|
||||||
|
app:layout_anchorGravity="bottom|end"
|
||||||
|
app:layout_behavior="org.koitharu.kotatsu.base.ui.util.ShrinkOnScrollBehavior"
|
||||||
|
app:layout_dodgeInsetEdges="bottom" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/toolbar_card"
|
android:id="@+id/toolbar_card"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
android:layout_marginVertical="8dp"
|
android:layout_marginVertical="8dp"
|
||||||
android:background="@drawable/toolbar_background"
|
android:background="@drawable/toolbar_background"
|
||||||
android:theme="@style/ThemeOverlay.Kotatsu.MainToolbar"
|
android:theme="@style/ThemeOverlay.Kotatsu.MainToolbar"
|
||||||
|
|||||||
Reference in New Issue
Block a user