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

View File

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

View File

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

View File

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

View File

@ -172,6 +172,19 @@
<item name="android:background">@drawable/list_item_selector</item> <item name="android:background">@drawable/list_item_selector</item>
</style> </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 --> <!-- set the rounded drawable as background to your bottom sheet -->
<style name="BottomSheetDialogTheme" parent="@style/Theme.MaterialComponents.BottomSheetDialog"> <style name="BottomSheetDialogTheme" parent="@style/Theme.MaterialComponents.BottomSheetDialog">