From 0885cf58e23cb006a772239464a7eea722874cee Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 23 Mar 2020 19:38:03 +0100 Subject: [PATCH] limit the zoom out level by the screens size --- .../calendar/pro/fragments/WeekFragment.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index eacd7bffc..f9e53f288 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -32,7 +32,7 @@ import java.util.* class WeekFragment : Fragment(), WeeklyCalendar { private val PLUS_FADEOUT_DELAY = 5000L - private val MIN_ZOOM_FACTOR = 0.4f + private val MIN_ZOOM_FACTOR = 0.3f private val MAX_ZOOM_FACTOR = 4f var listener: WeekFragmentListener? = null @@ -221,7 +221,12 @@ class WeekFragment : Fragment(), WeeklyCalendar { } override fun onScaleEnd(detector: ScaleGestureDetector) { - val newFactor = Math.max(Math.min(config.weeklyViewItemHeightMultiplier * detector.scaleFactor, MAX_ZOOM_FACTOR), MIN_ZOOM_FACTOR) + var newFactor = Math.max(Math.min(config.weeklyViewItemHeightMultiplier * detector.scaleFactor, MAX_ZOOM_FACTOR), MIN_ZOOM_FACTOR) + val defaultHeight = resources.getDimension(R.dimen.weekly_view_row_height) + if (mView.week_events_scrollview.height > defaultHeight * newFactor * 24) { + newFactor = mView.week_events_scrollview.height / 24f / defaultHeight + } + config.weeklyViewItemHeightMultiplier = newFactor updateViewScale()