mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
shrink the monthly day view + make the background grid non clickable
This commit is contained in:
@ -9,7 +9,6 @@ import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
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.helpers.Config
|
||||
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
|
||||
|
@ -216,7 +216,12 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
||||
|
||||
private fun measureDaySize(canvas: Canvas) {
|
||||
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
|
||||
maxEventsPerDay = availableHeightForEvents / eventTitleHeight
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
onGlobalLayout {
|
||||
if (!wereViewsAdded && days.isNotEmpty()) {
|
||||
measureSizes()
|
||||
addViews()
|
||||
addClickableBackgrounds()
|
||||
monthView.updateDays(days, isMonthDayView)
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
dayClickCallback = callback
|
||||
days = newDays
|
||||
if (dayWidth != 0f && dayHeight != 0f) {
|
||||
addViews()
|
||||
addClickableBackgrounds()
|
||||
}
|
||||
|
||||
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()
|
||||
monthView = inflater.inflate(R.layout.month_view, this).month_view
|
||||
wereViewsAdded = true
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.simplemobiletools.calendar.pro.views.MonthView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.simplemobiletools.calendar.pro.views.MonthView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/month_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent" />
|
||||
|
Reference in New Issue
Block a user