From 931ff5830fcf8d42f50ab8706a183e39daa12850 Mon Sep 17 00:00:00 2001 From: ajp_anton Date: Mon, 27 Jul 2026 01:17:40 +0000 Subject: [PATCH] Add scroll-to-top control for logs --- .../notificationlog/ViewLogsFragment.kt | 7 +++ .../main/res/layout/fragment_view_logs.xml | 54 ++++++++++++------- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/se/ajpanton/notificationlog/ViewLogsFragment.kt b/app/src/main/java/se/ajpanton/notificationlog/ViewLogsFragment.kt index bed327c..b62f691 100644 --- a/app/src/main/java/se/ajpanton/notificationlog/ViewLogsFragment.kt +++ b/app/src/main/java/se/ajpanton/notificationlog/ViewLogsFragment.kt @@ -29,6 +29,12 @@ class ViewLogsFragment : Fragment(R.layout.fragment_view_logs) { super.onViewCreated(view, savedInstanceState) binding = FragmentViewLogsBinding.bind(view) binding!!.logsRefresh.setOnRefreshListener(::loadLogs) + binding!!.logScroll.setOnScrollChangeListener { _, _, scrollY, _, _ -> + binding?.scrollToTop?.visibility = if (scrollY > dp(SCROLL_TO_TOP_THRESHOLD_DP)) View.VISIBLE else View.GONE + } + binding!!.scrollToTop.setOnClickListener { + binding?.logScroll?.smoothScrollTo(0, 0) + } loadLogs() } @@ -236,5 +242,6 @@ class ViewLogsFragment : Fragment(R.layout.fragment_view_logs) { private companion object { const val LEFT_PILL_WEIGHT = 0.42f const val RIGHT_PILL_WEIGHT = 0.58f + const val SCROLL_TO_TOP_THRESHOLD_DP = 120 } } diff --git a/app/src/main/res/layout/fragment_view_logs.xml b/app/src/main/res/layout/fragment_view_logs.xml index ba61d25..f0a3640 100644 --- a/app/src/main/res/layout/fragment_view_logs.xml +++ b/app/src/main/res/layout/fragment_view_logs.xml @@ -1,31 +1,47 @@ - - - - - + android:layout_height="match_parent"> - - - + android:orientation="vertical" + android:padding="@dimen/page_padding"> + + + + + + + + + +