From c0f697a015051d1bd51fff2a578a51c7bce59ec2 Mon Sep 17 00:00:00 2001 From: Roman Bergman Date: Wed, 4 Mar 2026 16:31:49 +0100 Subject: [PATCH 1/3] Fix weekly view pinch zoom getting stuck This code fixes an issue #621 in Week view where pinch zoom could stop responding after zooming out, especially when an event/task is placed in the first or last time slot (around 00:00 or 23:00). --- .../calendar/fragments/WeekFragment.kt | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt index 67fe929d0..516b60258 100644 --- a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt @@ -112,6 +112,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { private var screenHeight = 0 private var rowHeightsAtScale = 0f private var prevScaleFactor = 0f + private var gestureScaleFactor = 0f private var mWasDestroyed = false private var isFragmentVisible = false private var wasFragmentInit = false @@ -137,6 +138,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { private lateinit var scrollView: MyScrollView private lateinit var res: Resources private lateinit var config: Config + private lateinit var scaleDetector: ScaleGestureDetector override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -165,16 +167,9 @@ class WeekFragment : Fragment(), WeeklyCalendar { weekHorizontalGridHolder.layoutParams.height = fullHeight weekEventsColumnsHolder.layoutParams.height = fullHeight - val scaleDetector = getViewScaleDetector() + scaleDetector = getViewScaleDetector() scrollView.setOnTouchListener { _, motionEvent -> - scaleDetector.onTouchEvent(motionEvent) - if (motionEvent.action == MotionEvent.ACTION_UP && wasScaled) { - scrollView.isScrollable = true - wasScaled = false - true - } else { - false - } + handleScaleTouch(motionEvent) } } @@ -328,7 +323,10 @@ class WeekFragment : Fragment(), WeeklyCalendar { val gestureDetector = getViewGestureDetector(layout, index) layout.setOnTouchListener { _, motionEvent -> - gestureDetector.onTouchEvent(motionEvent) + val isScaling = handleScaleTouch(motionEvent) + if (!isScaling) { + gestureDetector.onTouchEvent(motionEvent) + } true } @@ -499,6 +497,18 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + private fun handleScaleTouch(motionEvent: MotionEvent): Boolean { + scaleDetector.onTouchEvent(motionEvent) + val action = motionEvent.actionMasked + if ((action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) && wasScaled) { + scrollView.isScrollable = true + wasScaled = false + return true + } + + return scaleDetector.isInProgress || wasScaled || motionEvent.pointerCount > 1 + } + private fun getViewScaleDetector(): ScaleGestureDetector { return ScaleGestureDetector( requireContext(), @@ -508,12 +518,14 @@ class WeekFragment : Fragment(), WeeklyCalendar { prevScaleSpanY = detector.currentSpanY val wantedFactor = - config.weeklyViewItemHeightMultiplier - (SCALE_RANGE * percent) + gestureScaleFactor - (SCALE_RANGE * percent) var newFactor = max(min(wantedFactor, MAX_SCALE_FACTOR), MIN_SCALE_FACTOR) if (scrollView.height > defaultRowHeight * newFactor * 24) { newFactor = scrollView.height / 24f / defaultRowHeight } + gestureScaleFactor = newFactor + if (Math.abs(newFactor - prevScaleFactor) > MIN_SCALE_DIFFERENCE) { prevScaleFactor = newFactor config.weeklyViewItemHeightMultiplier = newFactor @@ -534,10 +546,17 @@ class WeekFragment : Fragment(), WeeklyCalendar { scrollView.isScrollable = false prevScaleSpanY = detector.currentSpanY prevScaleFactor = config.weeklyViewItemHeightMultiplier + gestureScaleFactor = prevScaleFactor wasScaled = true screenHeight = context!!.realScreenSize.y return super.onScaleBegin(detector) } + + override fun onScaleEnd(detector: ScaleGestureDetector) { + scrollView.isScrollable = true + wasScaled = false + super.onScaleEnd(detector) + } }) } @@ -795,6 +814,10 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + root.setOnTouchListener { _, motionEvent -> + handleScaleTouch(motionEvent) + } + root.setOnLongClickListener { view -> currentlyDraggedView = view val shadowBuilder = View.DragShadowBuilder(view) From 1cb433d5e34a23206fbbd424d85ee2c7bc2290bb Mon Sep 17 00:00:00 2001 From: Roman Bergman Date: Wed, 4 Mar 2026 16:40:56 +0100 Subject: [PATCH 2/3] add to fixed issue #621 --- CHANGELOG.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5f0c34b..c3e41e6f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), @@ -6,37 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Zoom level in weekly view locks (#621) + ## [1.10.3] - 2026-02-14 + ### Changed + - Updated translations ### Fixed + - Fixed crash when changing orientation ([#644]) ## [1.10.2] - 2026-02-04 + ### Fixed + - Fixed crash in event editor when CalDAV sync is disabled ([#1024]) ## [1.10.1] - 2026-02-03 + ### Changed + - Updated holiday data - Updated translations ### Fixed + - Fixed last used default calendar preference for new events ([#1019]) ## [1.10.0] - 2026-01-30 + ### Added + - Added support for custom fonts - Location suggestions in event editor using recently used locations ([#393]) ### Changed + - Unified the local and synchronized calendar pickers in event editor ([#629]) - Updated holiday data ([#1003]) - Updated translations ## [1.9.0] - 2025-12-16 + ### Changed + - Replaced "event types" concept with "calendars" ([#629]) - Renamed built-in "Regular event" calendar to "Local calendar" - Weekday labels now use three-letter abbreviations instead of single letters ([#103]) @@ -44,41 +62,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated translations ### Fixed + - Fixed crashes and freezing on some devices ([#889]) ## [1.8.1] - 2025-11-09 + ### Changed + - Updated holiday data - Updated translations ### Fixed + - Fixed startup crash in weekly view ([#550]) - Fixed incorrect weekly view start date in some cases ([#45]) - Fixed issue with Up/Arrow button closing the app ([#870]) - Fixed time drift when switching between views ([#590]) ## [1.8.0] - 2025-10-29 + ### Changed + - Compatibility updates for Android 15 & 16 - Removed permission to access network state (it was added accidentally) ([#826]) - Updated holiday data - Updated translations ## [1.7.0] - 2025-10-16 + ### Changed + - Events shown in adjacent months are no longer dimmed ([#808]) - Updated translations ### Fixed + - Fixed missing email notifications for attendees in some cases ([#135]) - Fixed missing attendees list when using some specific providers ([#818]) ## [1.6.2] - 2025-10-09 + ### Changed + - Synchronized events with unspecified status are now treated as confirmed ([#761]) - Updated translations ### Fixed + - Fixed event duplication when editing instances of recurring events ([#138]) - Fixed old reminders not being removed when moving events ([#486]) - Fixed drag and drop copying events instead of moving them ([#706]) @@ -87,68 +117,89 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed synchronization issues when editing events in a recurring series ([#641]) ## [1.6.1] - 2025-09-01 + ### Changed + - Declined events will no longer trigger notifications ([#732]) - Updated translations ### Fixed + - Fixed incorrect widget font size on foldable devices ([#337]) - Fixed missing or delayed reminders in some cases ([#217]) ## [1.6.0] - 2025-08-21 + ### Added + - Holidays for Philippines ([#729]) ### Changed + - Updated translations ## [1.5.0] - 2025-07-22 + ### Added + - Holidays for Guatemala ([#682]) ### Changed + - Updated translations ### Fixed + - Audio stream preference now works correctly ([#394]) - Fixed "today" highlight alignment in month view ([#603]) ## [1.4.0] - 2025-07-05 + ### Added + - Holidays for Vietnam ([#613]) - Holidays for Hong Kong ([#574]) ### Changed + - Updated translations ## [1.3.0] - 2025-05-13 + ### Added + - Support for setting event visibility ([#148]) - Option to hide date header in event list widget ([#484]) - Holidays for Bangladesh ### Changed + - Updated some in-app icons for consistency ([#567]) - Updated translations - Updated holiday data ### Fixed + - Addressed a glitch when long pressing in quick filter - Fixed age calculation for birthdays from private contacts ([#196]) - Fixed incorrect time in some events imported via ICS files ([#262]) - Fixed "Go to today" button in weekly view ([#551]) ## [1.2.0] - 2025-01-26 + ### Added + - Added ability to export event colors in ICS files (#188) - Added ability to quickly filter calendars on long press (#309) - Added state-specific and optional holidays (#379, #413) ### Changed + - Other minor bug fixes and improvements - Added more translations ### Fixed + - Fixed issue with "Mark completed" notification button (#156) - Fixed cut-off text in month view on some devices (#265) - Fixed broken weekly repetition in some timezones (#408) @@ -156,18 +207,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed invisible attendee suggestions (#41) ## [1.1.0] - 2024-11-15 + ### Added + - Added support for event status ### Changed + - Replaced checkboxes with switches - Other minor bug fixes and improvements - Added more translations ### Removed + - Removed support for Android 7 and older versions ### Fixed + - Resolved issue with multi-day all-day events not displaying on the top bar - Fixed task opening functionality from widgets - Fixed resizing issue in date widget @@ -175,27 +231,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed spanish translation for saturday. ## [1.0.3] - 2024-03-12 + ### Changed + - Highlight weekends in print mode. - Updated holidays for some countries. - Added some translations. ### Fixed + - Fixed month view issue on Google Pixel 8 Pro. - Fixed event color dots on monthly and daily view. - Fixed incorrect timezone when import ICS files. ## [1.0.2] - 2024-01-02 + ### Fixed + - Fixed import compatibility with Simple Calendar. - Fixed foss flavor configuration. ## [1.0.1] - 2024-01-02 + ### Fixed + - Fixed import compatibility with Simple Calendar. ## [1.0.0] - 2024-01-01 + ### Added + - Initial release [#34]: https://github.com/FossifyOrg/Calendar/issues/34 From 316d4e23ad7cdf4bf55ce4dacc901b6c86090866 Mon Sep 17 00:00:00 2001 From: Roman Bergman Date: Wed, 4 Mar 2026 16:57:08 +0100 Subject: [PATCH 3/3] fix code for ci test --- .../calendar/fragments/WeekFragment.kt | 27 +++++++++++++------ .../fossify/calendar/views/WeeklyViewGrid.kt | 3 ++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt index 516b60258..d251c0904 100644 --- a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt @@ -323,11 +323,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val gestureDetector = getViewGestureDetector(layout, index) layout.setOnTouchListener { _, motionEvent -> - val isScaling = handleScaleTouch(motionEvent) - if (!isScaling) { - gestureDetector.onTouchEvent(motionEvent) - } - true + handleDayColumnTouch(gestureDetector, motionEvent) } layout.setOnDragListener { _, dragEvent -> @@ -437,6 +433,16 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + private fun handleDayColumnTouch( + gestureDetector: GestureDetector, + motionEvent: MotionEvent + ): Boolean { + if (!handleScaleTouch(motionEvent)) { + gestureDetector.onTouchEvent(motionEvent) + } + return true + } + private fun revertDraggedEvent() { activity?.runOnUiThread { currentlyDraggedView?.beVisible() @@ -509,6 +515,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { return scaleDetector.isInProgress || wasScaled || motionEvent.pointerCount > 1 } + @SuppressLint("ClickableViewAccessibility") + private fun attachEventScaleTouchListener(view: View) { + view.setOnTouchListener { _, motionEvent -> + handleScaleTouch(motionEvent) + } + } + private fun getViewScaleDetector(): ScaleGestureDetector { return ScaleGestureDetector( requireContext(), @@ -814,9 +827,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } - root.setOnTouchListener { _, motionEvent -> - handleScaleTouch(motionEvent) - } + attachEventScaleTouchListener(root) root.setOnLongClickListener { view -> currentlyDraggedView = view diff --git a/app/src/main/kotlin/org/fossify/calendar/views/WeeklyViewGrid.kt b/app/src/main/kotlin/org/fossify/calendar/views/WeeklyViewGrid.kt index fa153a9d1..3b506faf7 100644 --- a/app/src/main/kotlin/org/fossify/calendar/views/WeeklyViewGrid.kt +++ b/app/src/main/kotlin/org/fossify/calendar/views/WeeklyViewGrid.kt @@ -5,6 +5,7 @@ import android.graphics.Canvas import android.graphics.Paint import android.util.AttributeSet import android.view.View +import androidx.core.content.ContextCompat import org.fossify.calendar.extensions.config import org.fossify.calendar.extensions.getWeeklyViewItemHeight @@ -16,7 +17,7 @@ class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) init { - paint.color = context.resources.getColor(org.fossify.commons.R.color.divider_grey) + paint.color = ContextCompat.getColor(context, org.fossify.commons.R.color.divider_grey) } override fun onDraw(canvas: Canvas) {