From b85eb238e9b7fd800b1d18afa6cccb72d187b597 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sat, 21 Jun 2025 17:34:48 +0530 Subject: [PATCH 1/5] fix: add landscape layout for stopwatch --- .../res/layout-land/fragment_stopwatch.xml | 130 ++++++++++++++++++ .../main/res/layout/fragment_stopwatch.xml | 5 +- 2 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/layout-land/fragment_stopwatch.xml diff --git a/app/src/main/res/layout-land/fragment_stopwatch.xml b/app/src/main/res/layout-land/fragment_stopwatch.xml new file mode 100644 index 00000000..8b26d995 --- /dev/null +++ b/app/src/main/res/layout-land/fragment_stopwatch.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_stopwatch.xml b/app/src/main/res/layout/fragment_stopwatch.xml index e3d036fb..9416d4d6 100644 --- a/app/src/main/res/layout/fragment_stopwatch.xml +++ b/app/src/main/res/layout/fragment_stopwatch.xml @@ -22,6 +22,7 @@ android:maxLines="1" android:padding="@dimen/small_margin" android:textSize="@dimen/stopwatch_text_size" + app:layout_constraintBottom_toTopOf="@id/stopwatch_sorting_indicators_holder" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -33,6 +34,7 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/small_margin" android:visibility="invisible" + app:layout_constraintBottom_toTopOf="@id/stopwatch_list" app:layout_constraintTop_toBottomOf="@+id/stopwatch_time" tools:visibility="visible"> @@ -84,8 +86,6 @@ android:id="@+id/stopwatch_play_pause" android:layout_width="@dimen/stopwatch_button_size" android:layout_height="@dimen/stopwatch_button_size" - android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" android:layout_marginBottom="@dimen/big_margin" android:padding="@dimen/activity_margin" android:src="@drawable/ic_play_vector" @@ -98,7 +98,6 @@ android:id="@+id/stopwatch_reset" android:layout_width="@dimen/stopwatch_button_small_size" android:layout_height="@dimen/stopwatch_button_small_size" - android:layout_toStartOf="@+id/stopwatch_play_pause" android:background="?attr/selectableItemBackgroundBorderless" android:padding="@dimen/normal_margin" android:src="@drawable/ic_reset_vector" From 19a4322c4a68c4f57056cff7fbb6997289a85dcb Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sat, 21 Jun 2025 17:51:55 +0530 Subject: [PATCH 2/5] docs: add comment about optimization --- .../kotlin/org/fossify/clock/fragments/StopwatchFragment.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt b/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt index 1ab3bf2a..d7fe20d1 100644 --- a/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt +++ b/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt @@ -272,6 +272,8 @@ class StopwatchFragment : Fragment() { binding.stopwatchTime.text = totalTime.formatStopwatchTime(useLongerMSFormat) latestLapTime = lapTime latestTotalTime = totalTime + // We just update the list everytime for simplicity. + // dafa9e0ad88fdf77c19b91caec0683a3a87b8f50 would be more efficient. updateLaps() } From a47719fdc09455d7a79780ddaa3cca3fd2c9d067 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sat, 21 Jun 2025 18:15:11 +0530 Subject: [PATCH 3/5] docs: changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29ccb2d8..0e8c97a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed inaccuracy in stopwatch over long durations ([#207]) - Fixed text jitter in clock, stopwatch, and timer ([#11]) +- Fixed invisible stopwatch laps in landscape mode ([#107]) ## [1.2.1] - 2025-05-08 @@ -85,5 +86,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [1.0.0]: https://github.com/FossifyOrg/Clock/releases/tag/1.0.0 [#11]: https://github.com/FossifyOrg/Clock/issues/11 +[#107]: https://github.com/FossifyOrg/Clock/issues/107 [#158]: https://github.com/FossifyOrg/Clock/issues/158 [#207]: https://github.com/FossifyOrg/Clock/issues/207 From 4e66805520d86559aaefe4e6116a1a810e846a27 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sat, 21 Jun 2025 18:40:41 +0530 Subject: [PATCH 4/5] fix: add some padding between lap items --- app/src/main/res/layout/item_lap.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/layout/item_lap.xml b/app/src/main/res/layout/item_lap.xml index c9d02037..0a34352d 100644 --- a/app/src/main/res/layout/item_lap.xml +++ b/app/src/main/res/layout/item_lap.xml @@ -6,6 +6,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" + android:paddingVertical="@dimen/small_margin" android:paddingLeft="@dimen/activity_margin"> Date: Sat, 21 Jun 2025 18:45:17 +0530 Subject: [PATCH 5/5] fix: hide laps list when empty --- CHANGELOG.md | 1 + .../clock/fragments/StopwatchFragment.kt | 17 +++++++++++------ .../main/res/layout-land/fragment_stopwatch.xml | 7 +++++-- app/src/main/res/layout/fragment_stopwatch.xml | 10 +++++++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e8c97a4..4bcbca6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Replaced lap text button with an icon button +- Updated stopwatch layout animation - Updated translations ### Fixed diff --git a/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt b/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt index d7fe20d1..b1472ca0 100644 --- a/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt +++ b/app/src/main/kotlin/org/fossify/clock/fragments/StopwatchFragment.kt @@ -27,9 +27,7 @@ import org.fossify.clock.models.Lap import org.fossify.commons.dialogs.PermissionRequiredDialog import org.fossify.commons.extensions.applyColorFilter import org.fossify.commons.extensions.beGone -import org.fossify.commons.extensions.beInvisible import org.fossify.commons.extensions.beInvisibleIf -import org.fossify.commons.extensions.beVisible import org.fossify.commons.extensions.beVisibleIf import org.fossify.commons.extensions.flipBit import org.fossify.commons.extensions.getColoredBitmap @@ -82,7 +80,7 @@ class StopwatchFragment : Fragment() { } stopwatchLap.setOnClickListener { - stopwatchSortingIndicatorsHolder.beVisible() + setShowLaps(true) Stopwatch.lap() updateLaps() scrollToTop() @@ -108,9 +106,11 @@ class StopwatchFragment : Fragment() { setupViews() Stopwatch.addUpdateListener(updateListener) updateLaps() - binding.stopwatchSortingIndicatorsHolder.beVisibleIf(Stopwatch.laps.isNotEmpty()) if (Stopwatch.laps.isNotEmpty()) { updateSorting(Lap.sorting) + setShowLaps(true) + } else { + setShowLaps(false) } if (requireContext().config.toggleStopwatch) { @@ -191,7 +191,7 @@ class StopwatchFragment : Fragment() { stopwatchReset.beGone() stopwatchLap.beGone() stopwatchTime.text = 0L.formatStopwatchTime(false) - stopwatchSortingIndicatorsHolder.beInvisible() + setShowLaps(false) } } @@ -244,7 +244,7 @@ class StopwatchFragment : Fragment() { } } - private fun updateLaps() = lifecycleScope.launch { + private fun updateLaps() = viewLifecycleOwner.lifecycleScope.launch { stopwatchAdapter?.submitList( withContext(Dispatchers.Default) { val laps = ArrayList(Stopwatch.laps) @@ -267,6 +267,11 @@ class StopwatchFragment : Fragment() { } } + private fun setShowLaps(showLaps: Boolean) { + binding.stopwatchSortingIndicatorsHolder.beVisibleIf(showLaps) + binding.stopwatchList.beVisibleIf(showLaps) + } + private val updateListener = object : Stopwatch.UpdateListener { override fun onUpdate(totalTime: Long, lapTime: Long, useLongerMSFormat: Boolean) { binding.stopwatchTime.text = totalTime.formatStopwatchTime(useLongerMSFormat) diff --git a/app/src/main/res/layout-land/fragment_stopwatch.xml b/app/src/main/res/layout-land/fragment_stopwatch.xml index 8b26d995..ac8e23c5 100644 --- a/app/src/main/res/layout-land/fragment_stopwatch.xml +++ b/app/src/main/res/layout-land/fragment_stopwatch.xml @@ -4,7 +4,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/stopwatch_fragment" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:animateLayoutChanges="true"> + tools:listitem="@layout/item_lap" + tools:visibility="visible" /> + android:layout_height="match_parent" + android:animateLayoutChanges="true"> + tools:listitem="@layout/item_lap" + tools:visibility="visible" />