Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ 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

- 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

Expand Down Expand Up @@ -85,5 +87,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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -82,7 +80,7 @@ class StopwatchFragment : Fragment() {
}

stopwatchLap.setOnClickListener {
stopwatchSortingIndicatorsHolder.beVisible()
setShowLaps(true)
Stopwatch.lap()
updateLaps()
scrollToTop()
Expand All @@ -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) {
Expand Down Expand Up @@ -191,7 +191,7 @@ class StopwatchFragment : Fragment() {
stopwatchReset.beGone()
stopwatchLap.beGone()
stopwatchTime.text = 0L.formatStopwatchTime(false)
stopwatchSortingIndicatorsHolder.beInvisible()
setShowLaps(false)
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -267,11 +267,18 @@ 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)
latestLapTime = lapTime
latestTotalTime = totalTime
// We just update the list everytime for simplicity.
// dafa9e0ad88fdf77c19b91caec0683a3a87b8f50 would be more efficient.
updateLaps()
}

Expand Down
133 changes: 133 additions & 0 deletions app/src/main/res/layout-land/fragment_stopwatch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/stopwatch_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">

<org.fossify.clock.views.AutoFitTextView
android:id="@+id/stopwatch_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:autoSizeMaxTextSize="@dimen/stopwatch_text_size"
android:autoSizeMinTextSize="@dimen/extra_big_text_size"
android:autoSizeStepGranularity="2sp"
android:autoSizeTextType="uniform"
android:background="?attr/selectableItemBackground"
android:fontFeatureSettings="tnum"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:maxLines="1"
android:padding="@dimen/small_margin"
android:textSize="@dimen/stopwatch_text_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/stopwatch_list"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="01:30:00" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/stopwatch_sorting_indicators_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/small_margin"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@id/stopwatch_list"
app:layout_constraintEnd_toEndOf="@id/stopwatch_list"
app:layout_constraintStart_toStartOf="@id/stopwatch_list"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">

<ImageView
android:id="@+id/stopwatch_sorting_indicator_1"
android:layout_width="@dimen/lap_time_size"
android:layout_height="wrap_content"
android:visibility="invisible"
app:layout_constraintEnd_toStartOf="@+id/stopwatch_sorting_indicator_2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" />

<ImageView
android:id="@+id/stopwatch_sorting_indicator_2"
android:layout_width="@dimen/lap_time_size"
android:layout_height="wrap_content"
android:visibility="invisible"
app:layout_constraintEnd_toStartOf="@+id/stopwatch_sorting_indicator_3"
app:layout_constraintStart_toEndOf="@+id/stopwatch_sorting_indicator_1"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/stopwatch_sorting_indicator_3"
android:layout_width="@dimen/lap_time_size"
android:layout_height="wrap_content"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/stopwatch_sorting_indicator_2"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

<org.fossify.commons.views.MyRecyclerView
android:id="@+id/stopwatch_list"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="@dimen/section_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:clipToPadding="false"
android:overScrollMode="ifContentScrolls"
android:scrollbars="vertical"
android:visibility="gone"
app:layoutManager="org.fossify.commons.views.MyLinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/stopwatch_play_pause"
app:layout_constraintStart_toEndOf="@id/stopwatch_time"
app:layout_constraintTop_toBottomOf="@+id/stopwatch_sorting_indicators_holder"
tools:itemCount="18"
tools:listitem="@layout/item_lap"
tools:visibility="visible" />

<ImageView
android:id="@+id/stopwatch_play_pause"
android:layout_width="@dimen/stopwatch_button_size"
android:layout_height="@dimen/stopwatch_button_size"
android:layout_marginEnd="@dimen/section_margin"
android:padding="@dimen/activity_margin"
android:src="@drawable/ic_play_vector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/stopwatch_list"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/stopwatch_reset"
android:layout_width="@dimen/stopwatch_button_small_size"
android:layout_height="@dimen/stopwatch_button_small_size"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_reset_vector"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/stopwatch_play_pause"
app:layout_constraintStart_toStartOf="@id/stopwatch_play_pause"
app:layout_constraintTop_toBottomOf="@id/stopwatch_play_pause"
tools:visibility="visible" />

<ImageView
android:id="@+id/stopwatch_lap"
android:layout_width="@dimen/stopwatch_button_small_size"
android:layout_height="@dimen/stopwatch_button_small_size"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/lap"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_stopwatch_vector"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/stopwatch_play_pause"
app:layout_constraintEnd_toEndOf="@id/stopwatch_play_pause"
app:layout_constraintStart_toStartOf="@id/stopwatch_play_pause"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>

15 changes: 9 additions & 6 deletions app/src/main/res/layout/fragment_stopwatch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
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">

<org.fossify.clock.views.AutoFitTextView
android:id="@+id/stopwatch_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/normal_margin"
android:layout_marginBottom="@dimen/small_margin"
android:autoSizeMaxTextSize="@dimen/stopwatch_text_size"
android:autoSizeMinTextSize="@dimen/extra_big_text_size"
android:autoSizeStepGranularity="2sp"
Expand All @@ -22,17 +24,19 @@
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"
app:layout_goneMarginBottom="@dimen/stopwatch_button_size"
tools:text="01:30:00" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/stopwatch_sorting_indicators_holder"
android:layout_width="match_parent"
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">

Expand Down Expand Up @@ -73,19 +77,19 @@
android:clipToPadding="false"
android:overScrollMode="ifContentScrolls"
android:scrollbars="vertical"
android:visibility="gone"
app:layoutManager="org.fossify.commons.views.MyLinearLayoutManager"
app:layout_constraintBottom_toTopOf="@+id/stopwatch_play_pause"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/stopwatch_sorting_indicators_holder"
tools:listitem="@layout/item_lap" />
tools:listitem="@layout/item_lap"
tools:visibility="visible" />

<ImageView
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"
Expand All @@ -98,7 +102,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"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_lap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<org.fossify.commons.views.MyTextView
Expand Down
Loading