diff --git a/app/src/main/java/com/quillstudios/pokegoalshelper/ui/HistoryAdapter.kt b/app/src/main/java/com/quillstudios/pokegoalshelper/ui/HistoryAdapter.kt index ba052d4..589dee7 100644 --- a/app/src/main/java/com/quillstudios/pokegoalshelper/ui/HistoryAdapter.kt +++ b/app/src/main/java/com/quillstudios/pokegoalshelper/ui/HistoryAdapter.kt @@ -192,7 +192,45 @@ class HistoryAdapter( private fun createPopulatedExpandedContent(context: Context, result: DetectionResult): View { - return androidx.core.widget.NestedScrollView(context).apply { + return object : androidx.core.widget.NestedScrollView(context) { + private var initialTouchY = 0f + private var touchSlop = android.view.ViewConfiguration.get(context).scaledTouchSlop + + override fun onInterceptTouchEvent(ev: android.view.MotionEvent): Boolean { + when (ev.action) { + android.view.MotionEvent.ACTION_DOWN -> { + initialTouchY = ev.y + // Always request to handle touch events initially + parent?.requestDisallowInterceptTouchEvent(true) + } + android.view.MotionEvent.ACTION_MOVE -> { + val deltaY = kotlin.math.abs(ev.y - initialTouchY) + if (deltaY > touchSlop) { + // This is a scroll gesture - keep intercepting + parent?.requestDisallowInterceptTouchEvent(true) + } + } + android.view.MotionEvent.ACTION_UP, android.view.MotionEvent.ACTION_CANCEL -> { + // Allow parent to handle other gestures + parent?.requestDisallowInterceptTouchEvent(false) + } + } + return super.onInterceptTouchEvent(ev) + } + + override fun onTouchEvent(ev: android.view.MotionEvent): Boolean { + // Maintain control during active scrolling + when (ev.action) { + android.view.MotionEvent.ACTION_DOWN, android.view.MotionEvent.ACTION_MOVE -> { + parent?.requestDisallowInterceptTouchEvent(true) + } + android.view.MotionEvent.ACTION_UP, android.view.MotionEvent.ACTION_CANCEL -> { + parent?.requestDisallowInterceptTouchEvent(false) + } + } + return super.onTouchEvent(ev) + } + }.apply { // Set a reasonable fixed height for the scrollable area layoutParams = LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, @@ -202,6 +240,9 @@ class HistoryAdapter( // Configure scrolling behavior optimized for nested scrolling isFillViewport = false isNestedScrollingEnabled = true + isVerticalScrollBarEnabled = true // Show scrollbar for visual confirmation + scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY + isScrollbarFadingEnabled = false // Keep scrollbar visible tag = "expanded_content" val contentContainer = LinearLayout(context).apply {