Skip to content

Commit 0b35af4

Browse files
authored
Fix weekly view pinch zoom getting stuck (#1097)
* 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). * add to fixed issue #621 * fix code for ci test
1 parent 5fc88ae commit 0b35af4

3 files changed

Lines changed: 113 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
@@ -24,79 +25,108 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2425
### Fixed
2526
- Fixed event text readability on colored backgrounds ([#1065])
2627

28+
### Fixed
29+
30+
- Zoom level in weekly view locks (#621)
31+
2732
## [1.10.3] - 2026-02-14
33+
2834
### Changed
35+
2936
- Updated translations
3037

3138
### Fixed
39+
3240
- Fixed crash when changing orientation ([#644])
3341

3442
## [1.10.2] - 2026-02-04
43+
3544
### Fixed
45+
3646
- Fixed crash in event editor when CalDAV sync is disabled ([#1024])
3747

3848
## [1.10.1] - 2026-02-03
49+
3950
### Changed
51+
4052
- Updated holiday data
4153
- Updated translations
4254

4355
### Fixed
56+
4457
- Fixed last used default calendar preference for new events ([#1019])
4558

4659
## [1.10.0] - 2026-01-30
60+
4761
### Added
62+
4863
- Added support for custom fonts
4964
- Location suggestions in event editor using recently used locations ([#393])
5065

5166
### Changed
67+
5268
- Unified the local and synchronized calendar pickers in event editor ([#629])
5369
- Updated holiday data ([#1003])
5470
- Updated translations
5571

5672
## [1.9.0] - 2025-12-16
73+
5774
### Changed
75+
5876
- Replaced "event types" concept with "calendars" ([#629])
5977
- Renamed built-in "Regular event" calendar to "Local calendar"
6078
- Weekday labels now use three-letter abbreviations instead of single letters ([#103])
6179
- Converting all-day events to timed events now respects the default start time and duration ([#917])
6280
- Updated translations
6381

6482
### Fixed
83+
6584
- Fixed crashes and freezing on some devices ([#889])
6685

6786
## [1.8.1] - 2025-11-09
87+
6888
### Changed
89+
6990
- Updated holiday data
7091
- Updated translations
7192

7293
### Fixed
94+
7395
- Fixed startup crash in weekly view ([#550])
7496
- Fixed incorrect weekly view start date in some cases ([#45])
7597
- Fixed issue with Up/Arrow button closing the app ([#870])
7698
- Fixed time drift when switching between views ([#590])
7799

78100
## [1.8.0] - 2025-10-29
101+
79102
### Changed
103+
80104
- Compatibility updates for Android 15 & 16
81105
- Removed permission to access network state (it was added accidentally) ([#826])
82106
- Updated holiday data
83107
- Updated translations
84108

85109
## [1.7.0] - 2025-10-16
110+
86111
### Changed
112+
87113
- Events shown in adjacent months are no longer dimmed ([#808])
88114
- Updated translations
89115

90116
### Fixed
117+
91118
- Fixed missing email notifications for attendees in some cases ([#135])
92119
- Fixed missing attendees list when using some specific providers ([#818])
93120

94121
## [1.6.2] - 2025-10-09
122+
95123
### Changed
124+
96125
- Synchronized events with unspecified status are now treated as confirmed ([#761])
97126
- Updated translations
98127

99128
### Fixed
129+
100130
- Fixed event duplication when editing instances of recurring events ([#138])
101131
- Fixed old reminders not being removed when moving events ([#486])
102132
- Fixed drag and drop copying events instead of moving them ([#706])
@@ -105,115 +135,150 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
105135
- Fixed synchronization issues when editing events in a recurring series ([#641])
106136

107137
## [1.6.1] - 2025-09-01
138+
108139
### Changed
140+
109141
- Declined events will no longer trigger notifications ([#732])
110142
- Updated translations
111143

112144
### Fixed
145+
113146
- Fixed incorrect widget font size on foldable devices ([#337])
114147
- Fixed missing or delayed reminders in some cases ([#217])
115148

116149
## [1.6.0] - 2025-08-21
150+
117151
### Added
152+
118153
- Holidays for Philippines ([#729])
119154

120155
### Changed
156+
121157
- Updated translations
122158

123159
## [1.5.0] - 2025-07-22
160+
124161
### Added
162+
125163
- Holidays for Guatemala ([#682])
126164

127165
### Changed
166+
128167
- Updated translations
129168

130169
### Fixed
170+
131171
- Audio stream preference now works correctly ([#394])
132172
- Fixed "today" highlight alignment in month view ([#603])
133173

134174
## [1.4.0] - 2025-07-05
175+
135176
### Added
177+
136178
- Holidays for Vietnam ([#613])
137179
- Holidays for Hong Kong ([#574])
138180

139181
### Changed
182+
140183
- Updated translations
141184

142185
## [1.3.0] - 2025-05-13
186+
143187
### Added
188+
144189
- Support for setting event visibility ([#148])
145190
- Option to hide date header in event list widget ([#484])
146191
- Holidays for Bangladesh
147192

148193
### Changed
194+
149195
- Updated some in-app icons for consistency ([#567])
150196
- Updated translations
151197
- Updated holiday data
152198

153199
### Fixed
200+
154201
- Addressed a glitch when long pressing in quick filter
155202
- Fixed age calculation for birthdays from private contacts ([#196])
156203
- Fixed incorrect time in some events imported via ICS files ([#262])
157204
- Fixed "Go to today" button in weekly view ([#551])
158205

159206
## [1.2.0] - 2025-01-26
207+
160208
### Added
209+
161210
- Added ability to export event colors in ICS files (#188)
162211
- Added ability to quickly filter calendars on long press (#309)
163212
- Added state-specific and optional holidays (#379, #413)
164213

165214
### Changed
215+
166216
- Other minor bug fixes and improvements
167217
- Added more translations
168218

169219
### Fixed
220+
170221
- Fixed issue with "Mark completed" notification button (#156)
171222
- Fixed cut-off text in month view on some devices (#265)
172223
- Fixed broken weekly repetition in some timezones (#408)
173224
- Fixed "Mark completed" button color in black & white theme (#357)
174225
- Fixed invisible attendee suggestions (#41)
175226

176227
## [1.1.0] - 2024-11-15
228+
177229
### Added
230+
178231
- Added support for event status
179232

180233
### Changed
234+
181235
- Replaced checkboxes with switches
182236
- Other minor bug fixes and improvements
183237
- Added more translations
184238

185239
### Removed
240+
186241
- Removed support for Android 7 and older versions
187242

188243
### Fixed
244+
189245
- Resolved issue with multi-day all-day events not displaying on the top bar
190246
- Fixed task opening functionality from widgets
191247
- Fixed resizing issue in date widget
192248
- Fixed opacity for incomplete tasks in widgets
193249
- Fixed spanish translation for saturday.
194250

195251
## [1.0.3] - 2024-03-12
252+
196253
### Changed
254+
197255
- Highlight weekends in print mode.
198256
- Updated holidays for some countries.
199257
- Added some translations.
200258

201259
### Fixed
260+
202261
- Fixed month view issue on Google Pixel 8 Pro.
203262
- Fixed event color dots on monthly and daily view.
204263
- Fixed incorrect timezone when import ICS files.
205264

206265
## [1.0.2] - 2024-01-02
266+
207267
### Fixed
268+
208269
- Fixed import compatibility with Simple Calendar.
209270
- Fixed foss flavor configuration.
210271

211272
## [1.0.1] - 2024-01-02
273+
212274
### Fixed
275+
213276
- Fixed import compatibility with Simple Calendar.
214277

215278
## [1.0.0] - 2024-01-01
279+
216280
### Added
281+
217282
- Initial release
218283

219284
[#34]: https://github.com/FossifyOrg/Calendar/issues/34

app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
112112
private var screenHeight = 0
113113
private var rowHeightsAtScale = 0f
114114
private var prevScaleFactor = 0f
115+
private var gestureScaleFactor = 0f
115116
private var mWasDestroyed = false
116117
private var isFragmentVisible = false
117118
private var wasFragmentInit = false
@@ -137,6 +138,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
137138
private lateinit var scrollView: MyScrollView
138139
private lateinit var res: Resources
139140
private lateinit var config: Config
141+
private lateinit var scaleDetector: ScaleGestureDetector
140142

141143
override fun onCreate(savedInstanceState: Bundle?) {
142144
super.onCreate(savedInstanceState)
@@ -165,16 +167,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
165167
weekHorizontalGridHolder.layoutParams.height = fullHeight
166168
weekEventsColumnsHolder.layoutParams.height = fullHeight
167169

168-
val scaleDetector = getViewScaleDetector()
170+
scaleDetector = getViewScaleDetector()
169171
scrollView.setOnTouchListener { _, motionEvent ->
170-
scaleDetector.onTouchEvent(motionEvent)
171-
if (motionEvent.action == MotionEvent.ACTION_UP && wasScaled) {
172-
scrollView.isScrollable = true
173-
wasScaled = false
174-
true
175-
} else {
176-
false
177-
}
172+
handleScaleTouch(motionEvent)
178173
}
179174
}
180175

@@ -328,8 +323,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
328323
val gestureDetector = getViewGestureDetector(layout, index)
329324

330325
layout.setOnTouchListener { _, motionEvent ->
331-
gestureDetector.onTouchEvent(motionEvent)
332-
true
326+
handleDayColumnTouch(gestureDetector, motionEvent)
333327
}
334328

335329
layout.setOnDragListener { _, dragEvent ->
@@ -439,6 +433,16 @@ class WeekFragment : Fragment(), WeeklyCalendar {
439433
}
440434
}
441435

436+
private fun handleDayColumnTouch(
437+
gestureDetector: GestureDetector,
438+
motionEvent: MotionEvent
439+
): Boolean {
440+
if (!handleScaleTouch(motionEvent)) {
441+
gestureDetector.onTouchEvent(motionEvent)
442+
}
443+
return true
444+
}
445+
442446
private fun revertDraggedEvent() {
443447
activity?.runOnUiThread {
444448
currentlyDraggedView?.beVisible()
@@ -499,6 +503,25 @@ class WeekFragment : Fragment(), WeeklyCalendar {
499503
}
500504
}
501505

506+
private fun handleScaleTouch(motionEvent: MotionEvent): Boolean {
507+
scaleDetector.onTouchEvent(motionEvent)
508+
val action = motionEvent.actionMasked
509+
if ((action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) && wasScaled) {
510+
scrollView.isScrollable = true
511+
wasScaled = false
512+
return true
513+
}
514+
515+
return scaleDetector.isInProgress || wasScaled || motionEvent.pointerCount > 1
516+
}
517+
518+
@SuppressLint("ClickableViewAccessibility")
519+
private fun attachEventScaleTouchListener(view: View) {
520+
view.setOnTouchListener { _, motionEvent ->
521+
handleScaleTouch(motionEvent)
522+
}
523+
}
524+
502525
private fun getViewScaleDetector(): ScaleGestureDetector {
503526
return ScaleGestureDetector(
504527
requireContext(),
@@ -508,12 +531,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
508531
prevScaleSpanY = detector.currentSpanY
509532

510533
val wantedFactor =
511-
config.weeklyViewItemHeightMultiplier - (SCALE_RANGE * percent)
534+
gestureScaleFactor - (SCALE_RANGE * percent)
512535
var newFactor = max(min(wantedFactor, MAX_SCALE_FACTOR), MIN_SCALE_FACTOR)
513536
if (scrollView.height > defaultRowHeight * newFactor * 24) {
514537
newFactor = scrollView.height / 24f / defaultRowHeight
515538
}
516539

540+
gestureScaleFactor = newFactor
541+
517542
if (Math.abs(newFactor - prevScaleFactor) > MIN_SCALE_DIFFERENCE) {
518543
prevScaleFactor = newFactor
519544
config.weeklyViewItemHeightMultiplier = newFactor
@@ -534,10 +559,17 @@ class WeekFragment : Fragment(), WeeklyCalendar {
534559
scrollView.isScrollable = false
535560
prevScaleSpanY = detector.currentSpanY
536561
prevScaleFactor = config.weeklyViewItemHeightMultiplier
562+
gestureScaleFactor = prevScaleFactor
537563
wasScaled = true
538564
screenHeight = context!!.realScreenSize.y
539565
return super.onScaleBegin(detector)
540566
}
567+
568+
override fun onScaleEnd(detector: ScaleGestureDetector) {
569+
scrollView.isScrollable = true
570+
wasScaled = false
571+
super.onScaleEnd(detector)
572+
}
541573
})
542574
}
543575

@@ -795,6 +827,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
795827
}
796828
}
797829

830+
attachEventScaleTouchListener(root)
831+
798832
root.setOnLongClickListener { view ->
799833
currentlyDraggedView = view
800834
val shadowBuilder = View.DragShadowBuilder(view)

0 commit comments

Comments
 (0)