Add "Continue" FAB to navigation rail
This commit is contained in:
@@ -92,6 +92,7 @@ class MainActivity :
|
||||
|
||||
navBar.setOnItemSelectedListener(this)
|
||||
binding.fab.setOnClickListener(this)
|
||||
binding.navRail?.headerView?.setOnClickListener(this)
|
||||
binding.searchView.isVoiceSearchEnabled = voiceInputLauncher.resolve(this, null) != null
|
||||
|
||||
supportFragmentManager.findFragmentByTag(TAG_PRIMARY)?.let {
|
||||
@@ -150,6 +151,7 @@ class MainActivity :
|
||||
override fun onClick(v: View) {
|
||||
when (v.id) {
|
||||
R.id.fab -> viewModel.openLastReader()
|
||||
R.id.railFab -> viewModel.openLastReader()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,8 +260,8 @@ class MainActivity :
|
||||
}
|
||||
|
||||
private fun onOpenReader(manga: Manga) {
|
||||
val options = ActivityOptions.makeScaleUpAnimation(binding.fab, 0, 0, binding.fab.width, binding.fab.height)
|
||||
startActivity(ReaderActivity.newIntent(this, manga), options?.toBundle())
|
||||
// val options = ActivityOptions.makeScaleUpAnimation(binding.fab, 0, 0, binding.fab.width, binding.fab.height)
|
||||
startActivity(ReaderActivity.newIntent(this, manga))
|
||||
}
|
||||
|
||||
private fun onError(e: Throwable) {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.koitharu.kotatsu.main.ui
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.view.OnApplyWindowInsetsListener
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updatePadding
|
||||
import java.lang.ref.WeakReference
|
||||
import com.google.android.material.R as materialR
|
||||
|
||||
class NavigationViewInsetsListener : OnApplyWindowInsetsListener {
|
||||
|
||||
private var menuViewRef: WeakReference<View>? = null
|
||||
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
|
||||
val menuView = menuViewRef?.get() ?: v.findViewById<View>(materialR.id.design_navigation_view).also {
|
||||
menuViewRef = WeakReference(it)
|
||||
}
|
||||
val systemWindowInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.updatePadding(top = systemWindowInsets.top)
|
||||
// NavigationView doesn't dispatch insets to the menu view, so pad the bottom here.
|
||||
menuView.updatePadding(bottom = systemWindowInsets.bottom)
|
||||
return WindowInsetsCompat.CONSUMED
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,12 @@ class SearchSuggestionFragment :
|
||||
}
|
||||
|
||||
override fun onWindowInsetsChanged(insets: Insets) {
|
||||
val headerHeight = (activity as? AppBarOwner)?.appBar?.measureHeight() ?: insets.top
|
||||
val extraPadding = resources.getDimensionPixelOffset(R.dimen.list_spacing)
|
||||
binding.root.updatePadding(
|
||||
top = headerHeight + extraPadding,
|
||||
bottom = insets.bottom + extraPadding,
|
||||
top = extraPadding,
|
||||
right = insets.right,
|
||||
left = insets.left,
|
||||
bottom = insets.bottom
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
android:id="@+id/navRail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:elevation="1dp"
|
||||
app:headerLayout="@layout/navigation_rail_fab"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:menu="@menu/nav_bottom" />
|
||||
|
||||
|
||||
9
app/src/main/res/layout/navigation_rail_fab.xml
Normal file
9
app/src/main/res/layout/navigation_rail_fab.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/railFab"
|
||||
android:theme="@style/ThemeOverlay.Material3.FloatingActionButton.Tertiary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_read" />
|
||||
Reference in New Issue
Block a user