mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 21:01:51 +01:00
Fixed weird changing size of the fab in browse source view
Co-Authored-By: Soitora <simon.mattila@protonmail.com>
This commit is contained in:
parent
a0859148e0
commit
af3fadd62a
@ -1,41 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.widget
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.View
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
import com.google.android.material.snackbar.Snackbar
|
|
||||||
import kotlin.math.min
|
|
||||||
|
|
||||||
class FABMoveBehaviour(context: Context, attrs: AttributeSet) :
|
|
||||||
CoordinatorLayout.Behavior<FloatingActionButton>(context, attrs) {
|
|
||||||
|
|
||||||
override fun layoutDependsOn(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
|
|
||||||
return dependency is Snackbar.SnackbarLayout
|
|
||||||
}
|
|
||||||
override fun onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
|
|
||||||
if (isTablet(child.context)) return true
|
|
||||||
val translationY = getFabTranslationYForSnackbar(parent, child)
|
|
||||||
child.translationY = translationY
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isTablet(context: Context): Boolean {
|
|
||||||
return (context.resources.configuration.screenLayout and Configuration
|
|
||||||
.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getFabTranslationYForSnackbar(parent: CoordinatorLayout, fab: FloatingActionButton): Float {
|
|
||||||
var minOffset = 0f
|
|
||||||
val dependencies = parent.getDependencies(fab)
|
|
||||||
for (i in 0 until dependencies.size) {
|
|
||||||
val view = dependencies[i]
|
|
||||||
if (view is Snackbar.SnackbarLayout && view.isShown) {
|
|
||||||
minOffset = min(minOffset, view.translationY - view.height)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return minOffset
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,16 +26,8 @@
|
|||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
android:layout_width="wrap_content"
|
style="@style/Theme.Widget.FAB"
|
||||||
app:backgroundTint="?colorAccent"
|
|
||||||
android:text="@string/filter"
|
android:text="@string/filter"
|
||||||
android:layout_gravity="bottom|end"
|
app:icon="@drawable/ic_filter_list_white_24dp"/>
|
||||||
app:icon="@drawable/ic_filter_list_white_24dp"
|
|
||||||
app:iconTint="@color/md_white_1000"
|
|
||||||
android:textColor="@color/md_white_1000"
|
|
||||||
android:textAllCaps="false"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
android:paddingStart="3dp"
|
android:paddingStart="3dp"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
@ -82,19 +83,6 @@
|
|||||||
<!-- Adding bottom sheet after main content -->
|
<!-- Adding bottom sheet after main content -->
|
||||||
<include layout="@layout/filter_bottom_sheet" />
|
<include layout="@layout/filter_bottom_sheet" />
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/fab"
|
|
||||||
style="@style/Theme.Widget.FABFixed"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"
|
|
||||||
android:scaleX="0"
|
|
||||||
android:scaleY="0"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_anchor="@id/bottom_sheet"
|
|
||||||
app:layout_anchorGravity="end|top"
|
|
||||||
app:srcCompat="@drawable/ic_file_download_white_24dp" />
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/shadow2"
|
android:id="@+id/shadow2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -22,14 +22,10 @@
|
|||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
style="@style/Theme.Widget.FABFixed"
|
style="@style/Theme.Widget.FAB"
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/ic_arrow_forward_white_24dp"
|
android:src="@drawable/ic_arrow_forward_white_24dp"
|
||||||
app:layout_anchor="@id/recycler"
|
app:layout_anchor="@id/recycler"
|
||||||
app:layout_anchorGravity="bottom|right|end"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
app:backgroundTint="?attr/colorAccent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -119,21 +119,12 @@
|
|||||||
<item name="android:scaleType">fitCenter</item>
|
<item name="android:scaleType">fitCenter</item>
|
||||||
<item name="layout_anchorGravity">bottom|right|end</item>
|
<item name="layout_anchorGravity">bottom|right|end</item>
|
||||||
<item name="tint">@color/md_white_1000</item>
|
<item name="tint">@color/md_white_1000</item>
|
||||||
|
<item name="android:minHeight">@dimen/fab_size</item>
|
||||||
<item name="backgroundTint">?attr/colorAccent</item>
|
<item name="backgroundTint">?attr/colorAccent</item>
|
||||||
<item name="android:tint">@color/md_white_1000</item>
|
<item name="android:tint">@color/md_white_1000</item>
|
||||||
</style>
|
<item name="iconTint">@android:color/white</item>
|
||||||
|
<item name="textAllCaps">false</item>
|
||||||
<style name="Theme.Widget.FABFixed">
|
<item name="android:textColor">@android:color/white</item>
|
||||||
<item name="android:layout_height">@dimen/fab_size</item>
|
|
||||||
<item name="android:layout_width">@dimen/fab_size</item>
|
|
||||||
<item name="android:layout_gravity">bottom|end</item>
|
|
||||||
<item name="android:layout_margin">@dimen/fab_margin</item>
|
|
||||||
<item name="android:scaleType">fitCenter</item>
|
|
||||||
<item name="layout_anchorGravity">bottom|right|end</item>
|
|
||||||
<item name="android:tint">@color/md_white_1000</item>
|
|
||||||
<item name="tint">@color/md_white_1000</item>
|
|
||||||
<item name="backgroundTint">?attr/colorAccent</item>
|
|
||||||
<item name="layout_behavior">eu.kanade.tachiyomi.widget.FABMoveBehaviour</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Widget.CardView" parent="Widget.MaterialComponents.CardView">
|
<style name="Theme.Widget.CardView" parent="Widget.MaterialComponents.CardView">
|
||||||
|
Loading…
Reference in New Issue
Block a user