diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5c0fd013..208d6c752 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- Fixed accidental rendering of pull-to-refresh indicator ([#27])
- Pull-to-refresh setting is now applied as expected ([#136])
## [1.0.1] - 2024-03-17
@@ -40,4 +41,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[1.0.1]: https://github.com/FossifyOrg/File-Manager/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/FossifyOrg/File-Manager/releases/tag/1.0.0
+[#27]: https://github.com/FossifyOrg/File-Manager/issues/27
[#136]: https://github.com/FossifyOrg/File-Manager/issues/136
diff --git a/app/src/main/kotlin/org/fossify/filemanager/views/MySwipeRefreshLayout.kt b/app/src/main/kotlin/org/fossify/filemanager/views/MySwipeRefreshLayout.kt
new file mode 100644
index 000000000..d701b2bed
--- /dev/null
+++ b/app/src/main/kotlin/org/fossify/filemanager/views/MySwipeRefreshLayout.kt
@@ -0,0 +1,46 @@
+package org.fossify.filemanager.views
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.MotionEvent
+import android.view.View
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
+
+class MySwipeRefreshLayout @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+) : SwipeRefreshLayout(context, attrs) {
+ override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
+ // Setting "isEnabled = false" is recommended for users of this ViewGroup
+ // who who are not interested in the pull to refresh functionality
+ // Setting this easily avoids executing code needlessly before the check for "canChildScrollUp".
+ if (!isEnabled) {
+ return false
+ }
+ return super.onInterceptTouchEvent(ev)
+ }
+
+ override fun onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int): Boolean {
+ // Ignoring nested scrolls from descendants.
+ // Allowing descendants to trigger nested scrolls would defeat the purpose of this class
+ // and result in pull to refresh to happen for all movements on the Y axis
+ // (even as part of scale/quick scale gestures) while also doubling the throbber with the overscroll shadow.
+ return if (isEnabled) {
+ return false
+ } else {
+ super.onStartNestedScroll(child, target, nestedScrollAxes)
+ }
+ }
+
+ override fun canChildScrollUp(): Boolean {
+ val directChild = getChildAt(0)
+ return when (directChild) {
+ is RecyclerViewFastScroller -> {
+ val innerRecyclerView = directChild.getChildAt(0)
+ innerRecyclerView?.canScrollVertically(-1) == true
+ }
+ else -> super.canChildScrollUp()
+ }
+ }
+}
diff --git a/app/src/main/res/layout/items_fragment.xml b/app/src/main/res/layout/items_fragment.xml
index 4299469e7..312d24ccf 100644
--- a/app/src/main/res/layout/items_fragment.xml
+++ b/app/src/main/res/layout/items_fragment.xml
@@ -68,7 +68,7 @@
android:textStyle="italic"
android:visibility="gone" />
-
-
+
-
@@ -37,5 +37,5 @@
android:scrollbars="none"
app:layoutManager="org.fossify.commons.views.MyGridLayoutManager" />
-
+