Refactoring fast scroll and its text view

using the new textview in the manga details fast scroll
This commit is contained in:
Jay 2020-05-07 15:05:09 -04:00
parent 9468caeb1e
commit 8c394a4a7b
5 changed files with 34 additions and 42 deletions

View File

@ -14,6 +14,8 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
setViewsToUse(
R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle
)
autoHideEnabled = true
ignoreTouchesOutsideHandle = true
}
override fun onTouchEvent(event: MotionEvent): Boolean {
@ -23,7 +25,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
override fun setBubbleAndHandlePosition(y: Float) {
super.setBubbleAndHandlePosition(y)
bubble.y = handle.y - bubble.height / 2f + handle.height / 2f
bubble.translationX = (-45f).dpToPxEnd
if (bubbleEnabled) {
bubble.y = handle.y - bubble.height / 2f + handle.height / 2f
bubble.translationX = (-45f).dpToPxEnd
}
}
}

View File

@ -54,11 +54,8 @@
<eu.kanade.tachiyomi.ui.library.MaterialFastScroll
android:id="@+id/fast_scroller"
android:layout_width="match_parent"
app:fastScrollerAutoHideEnabled="true"
app:fastScrollerAutoHideDelayInMillis="1000"
app:fastScrollerBubbleEnabled="true"
app:fastScrollerIgnoreTouchesOutsideHandle="true"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
app:fastScrollerBubbleEnabled="true" />
<View
android:id="@+id/recycler_cover"
@ -88,25 +85,16 @@
app:layout_anchorGravity="top" />
<com.google.android.material.textview.MaterialTextView
android:elevation="5dp"
style="@style/FloatingTextView"
android:id="@+id/jumper_category_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/category_hopper_frame"
android:background="@drawable/bubble_drawable"
android:gravity="center"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:layout_marginBottom="8dp"
android:layout_gravity="start|center"
app:layout_anchorGravity="start|center"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:layout_marginBottom="8dp"
android:alpha="0.0"
android:textColor="?actionBarTintColor"
android:textSize="15sp"
tools:alpha="1"
tools:text="Category and a long one"/>
android:gravity="center"
app:layout_anchor="@id/category_hopper_frame"
app:layout_anchorGravity="start|center"
tools:text="Category and a long one"
tools:alpha="1" />
<FrameLayout
android:id="@+id/category_hopper_frame"

View File

@ -24,8 +24,8 @@
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layout_weight="0.25"
android:clipToPadding="false"
tools:listitem="@layout/chapters_item" />
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@ -45,9 +45,9 @@
android:paddingTop="8dp"
android:paddingEnd="0dp"
android:paddingBottom="8dp"
app:layout_constrainedHeight="true"
android:textColor="?android:attr/textColorPrimary"
app:iconColor="?android:attr/textColorPrimary"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
@ -55,17 +55,13 @@
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text_view_m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/FloatingTextView"
android:layout_marginEnd="50dp"
android:alpha="0"
android:background="@drawable/round_textview_background"
android:padding="8dp"
android:textColor="@android:color/white"
app:layout_constraintEnd_toStartOf="@id/fast_scroller"
app:layout_constraintTop_toTopOf="@id/fast_scroller"
tools:alpha="1"
tools:text="sdfsdf" />
tools:text="Volume 12"
tools:alpha="1" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View

View File

@ -18,20 +18,11 @@
<!-- No margin, use padding at the handle -->
<com.google.android.material.textview.MaterialTextView
android:elevation="5dp"
style="@style/FloatingTextView"
android:id="@+id/fast_scroller_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_toStartOf="@+id/fast_scroller_handle"
android:background="@drawable/bubble_drawable"
android:gravity="center"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:textColor="?actionBarTintColor"
android:textSize="15sp"
android:visibility="gone"
tools:text="A"
tools:visibility="visible"/>

View File

@ -172,6 +172,19 @@
<item name="android:background">@drawable/list_item_selector</item>
</style>
<style name="FloatingTextView" parent="TextAppearance.AppCompat">
<item name="android:paddingStart">12dp</item>
<item name="android:paddingEnd">12dp</item>
<item name="android:paddingTop">8dp</item>
<item name="android:paddingBottom">8dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:background">@drawable/bubble_drawable</item>
<item name="android:textColor">?actionBarTintColor</item>
<item name="android:textSize">15sp</item>
<item name="android:elevation">5dp</item>
</style>
<!-- set the rounded drawable as background to your bottom sheet -->
<style name="BottomSheetDialogTheme" parent="@style/Theme.MaterialComponents.BottomSheetDialog">