shrink the monthly day view + make the background grid non clickable

This commit is contained in:
tibbi
2021-02-21 23:29:04 +01:00
parent a0ae05260c
commit 01177ef0f9
4 changed files with 15 additions and 8 deletions

View File

@@ -9,7 +9,6 @@ import android.view.ViewGroup
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.Config import com.simplemobiletools.calendar.pro.helpers.Config
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE import com.simplemobiletools.calendar.pro.helpers.DAY_CODE

View File

@@ -216,7 +216,12 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
private fun measureDaySize(canvas: Canvas) { private fun measureDaySize(canvas: Canvas) {
dayWidth = (canvas.width - horizontalOffset) / 7f dayWidth = (canvas.width - horizontalOffset) / 7f
dayHeight = (canvas.height - weekDaysLetterHeight) / ROW_COUNT.toFloat() dayHeight = if (isMonthDayView) {
weekDaysLetterHeight * 1.2f
} else {
(canvas.height - weekDaysLetterHeight) / ROW_COUNT.toFloat()
}
val availableHeightForEvents = dayHeight.toInt() - weekDaysLetterHeight val availableHeightForEvents = dayHeight.toInt() - weekDaysLetterHeight
maxEventsPerDay = availableHeightForEvents / eventTitleHeight maxEventsPerDay = availableHeightForEvents / eventTitleHeight
} }

View File

@@ -36,7 +36,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
onGlobalLayout { onGlobalLayout {
if (!wereViewsAdded && days.isNotEmpty()) { if (!wereViewsAdded && days.isNotEmpty()) {
measureSizes() measureSizes()
addViews() addClickableBackgrounds()
monthView.updateDays(days, isMonthDayView) monthView.updateDays(days, isMonthDayView)
} }
} }
@@ -48,7 +48,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
dayClickCallback = callback dayClickCallback = callback
days = newDays days = newDays
if (dayWidth != 0f && dayHeight != 0f) { if (dayWidth != 0f && dayHeight != 0f) {
addViews() addClickableBackgrounds()
} }
isMonthDayView = !addEvents isMonthDayView = !addEvents
@@ -69,7 +69,11 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
} }
} }
private fun addViews() { private fun addClickableBackgrounds() {
if (isMonthDayView) {
return
}
removeAllViews() removeAllViews()
monthView = inflater.inflate(R.layout.month_view, this).month_view monthView = inflater.inflate(R.layout.month_view, this).month_view
wereViewsAdded = true wereViewsAdded = true

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.simplemobiletools.calendar.pro.views.MonthView <com.simplemobiletools.calendar.pro.views.MonthView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/month_view" android:id="@+id/month_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />