From 00006f67e51b9c07f734d6bd7b723fd30e281bb8 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 8 May 2019 11:45:36 +0200 Subject: [PATCH] Added fast scroll to message list --- .../java/eu/faircode/email/FixedRecyclerView.java | 1 - .../java/eu/faircode/email/FragmentMessages.java | 8 ++++++++ app/src/main/res/drawable/fast_scroll_thumb.xml | 13 +++++++++++++ app/src/main/res/drawable/fast_scroll_track.xml | 5 +++++ app/src/main/res/layout/fragment_messages.xml | 7 +++++++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/fast_scroll_thumb.xml create mode 100644 app/src/main/res/drawable/fast_scroll_track.xml diff --git a/app/src/main/java/eu/faircode/email/FixedRecyclerView.java b/app/src/main/java/eu/faircode/email/FixedRecyclerView.java index 04700914f3..38d4114fb9 100644 --- a/app/src/main/java/eu/faircode/email/FixedRecyclerView.java +++ b/app/src/main/java/eu/faircode/email/FixedRecyclerView.java @@ -75,5 +75,4 @@ public class FixedRecyclerView extends RecyclerView { return false; } } - } diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index a9b72db45e..f28d91a20e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -446,6 +446,14 @@ public class FragmentMessages extends FragmentBase { rvMessage.setAdapter(adapter); + rvMessage.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(@NonNull RecyclerView rv, int dx, int dy) { + int pos = (rv.getChildCount() == 0 ? 0 : rv.getChildAt(0).getTop()); + swipeRefresh.setEnabled(pull && pos >= 0); + } + }); + seekBar.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { diff --git a/app/src/main/res/drawable/fast_scroll_thumb.xml b/app/src/main/res/drawable/fast_scroll_thumb.xml new file mode 100644 index 0000000000..bfaec33123 --- /dev/null +++ b/app/src/main/res/drawable/fast_scroll_thumb.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/fast_scroll_track.xml b/app/src/main/res/drawable/fast_scroll_track.xml new file mode 100644 index 0000000000..45fb96ff69 --- /dev/null +++ b/app/src/main/res/drawable/fast_scroll_track.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_messages.xml b/app/src/main/res/layout/fragment_messages.xml index 43f273b386..aae51fec68 100644 --- a/app/src/main/res/layout/fragment_messages.xml +++ b/app/src/main/res/layout/fragment_messages.xml @@ -150,7 +150,14 @@ android:clipToPadding="false" android:paddingBottom="90dp" android:scrollbarStyle="outsideOverlay" + android:scrollbarThumbVertical="@drawable/fast_scroll_thumb" + android:scrollbarTrackVertical="@drawable/fast_scroll_track" android:scrollbars="vertical" + app:fastScrollEnabled="true" + app:fastScrollHorizontalThumbDrawable="@drawable/fast_scroll_thumb" + app:fastScrollHorizontalTrackDrawable="@drawable/fast_scroll_track" + app:fastScrollVerticalThumbDrawable="@drawable/fast_scroll_thumb" + app:fastScrollVerticalTrackDrawable="@drawable/fast_scroll_track" app:layout_constraintBottom_toTopOf="@+id/bottom_navigation" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"