Merge 388a140212
into 1e6b3ec67f
This commit is contained in:
commit
97d2f7bdb9
|
@ -176,7 +176,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
dayVerticalOffsets.put(day.indexOnMonthView, dayVerticalOffsets[day.indexOnMonthView] + weekDaysLetterHeight)
|
||||
val verticalOffset = dayVerticalOffsets[day.indexOnMonthView]
|
||||
val xPos = x * dayWidth + horizontalOffset
|
||||
val yPos = y * dayHeight + verticalOffset
|
||||
val yPos = y * dayHeight + verticalOffset*1.055f
|
||||
val xPosCenter = xPos + dayWidth / 2
|
||||
val dayNumber = day.value.toString()
|
||||
|
||||
|
@ -276,7 +276,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
verticalOffset = max(verticalOffset, dayVerticalOffsets[event.startDayIndex + i])
|
||||
}
|
||||
val xPos = event.startDayIndex % 7 * dayWidth + horizontalOffset
|
||||
val yPos = (event.startDayIndex / 7) * dayHeight
|
||||
val yPos = (event.startDayIndex / 10) * dayHeight
|
||||
val xPosCenter = xPos + dayWidth / 2
|
||||
|
||||
if (verticalOffset - eventTitleHeight * 2 > dayHeight) {
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Context
|
|||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import com.simplemobiletools.calendar.pro.BuildConfig
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.databinding.MonthViewBackgroundBinding
|
||||
import com.simplemobiletools.calendar.pro.databinding.MonthViewBinding
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
|
@ -67,7 +69,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
|||
val childLeft = x * dayWidth + horizontalOffset - child.translationX
|
||||
val childTop = y * dayHeight + weekDaysLetterHeight - child.translationY
|
||||
val childWidth = child.measuredWidth
|
||||
val childHeight = child.measuredHeight
|
||||
val childHeight = child.measuredHeight/1.05F
|
||||
val childRight = childLeft + childWidth
|
||||
val childBottom = childTop + childHeight
|
||||
|
||||
|
@ -106,10 +108,15 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
|||
}
|
||||
|
||||
private fun measureSizes() {
|
||||
dayWidth = (width - horizontalOffset) / 7f
|
||||
dayHeight = (height - weekDaysLetterHeight) / 6f
|
||||
// Supposons que vous avez 7 colonnes et 6 lignes
|
||||
val columns = 7
|
||||
val rows = 6
|
||||
|
||||
dayWidth = ((width - horizontalOffset) / columns).toFloat()
|
||||
dayHeight = ((height - weekDaysLetterHeight) / rows).toFloat()
|
||||
}
|
||||
|
||||
|
||||
private fun addClickableBackgrounds() {
|
||||
removeAllViews()
|
||||
binding = MonthViewBinding.inflate(inflater, this, true)
|
||||
|
@ -119,7 +126,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
|||
for (x in 0 until COLUMN_COUNT) {
|
||||
val day = days.getOrNull(curId)
|
||||
if (day != null) {
|
||||
addViewBackground(x, y, day)
|
||||
addViewBackground(x, y/2, day)
|
||||
}
|
||||
curId++
|
||||
}
|
||||
|
@ -127,30 +134,46 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
|||
}
|
||||
|
||||
private fun addViewBackground(viewX: Int, viewY: Int, day: DayMonthly) {
|
||||
val xPos = viewX * dayWidth + horizontalOffset
|
||||
val yPos = viewY * dayHeight + weekDaysLetterHeight
|
||||
// utilisation de dayWidth et dayHeight pour définir la taille visuelle totale du jour
|
||||
val totalDayWidth = dayWidth
|
||||
val totalDayHeight = dayHeight
|
||||
|
||||
MonthViewBackgroundBinding.inflate(inflater, this, false).root.apply {
|
||||
if (isMonthDayView) {
|
||||
background = null
|
||||
// la zone cliquable à un pourcentage de la taille totale du jour
|
||||
val clickableWidth = (totalDayWidth * 0.7).toInt() // 70% de la largeur totale
|
||||
val clickableHeight = (totalDayHeight * 0.7).toInt() // 70% de la hauteur totale
|
||||
|
||||
// Calcule les positions x et y pour centrer la zone cliquable dans la cellule du jour
|
||||
val xPos = viewX * totalDayWidth + (totalDayWidth - clickableWidth) / 2 + horizontalOffset
|
||||
val yPos = viewY * totalDayHeight + (totalDayHeight - clickableHeight) / 2 + weekDaysLetterHeight
|
||||
|
||||
// Création des paramètres de disposition pour la vue cliquable
|
||||
val clickableLayoutParams = FrameLayout.LayoutParams(clickableWidth, clickableHeight)
|
||||
clickableLayoutParams.setMargins(xPos.toInt(), yPos.toInt(), 0, 0)
|
||||
|
||||
val dayView = MonthViewBackgroundBinding.inflate(inflater, this, false).root.apply {
|
||||
this.layoutParams = clickableLayoutParams
|
||||
if (BuildConfig.DEBUG) {
|
||||
setBackgroundResource(R.drawable.debug_day_border) // Appliquez la bordure rouge si en mode débogage
|
||||
}
|
||||
|
||||
layoutParams.width = dayWidth.toInt()
|
||||
layoutParams.height = dayHeight.toInt()
|
||||
x = xPos
|
||||
y = yPos
|
||||
setOnClickListener {
|
||||
// gestion de clic sur la zone cliquable
|
||||
dayClickCallback?.invoke(day)
|
||||
|
||||
if (isMonthDayView) {
|
||||
binding.monthView.updateCurrentlySelectedDay(viewX, viewY)
|
||||
}
|
||||
}
|
||||
|
||||
addView(this)
|
||||
}
|
||||
|
||||
addView(dayView) // ajout de la vue cliquable à la hiérarchie de la vue parente
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fun togglePrintMode() {
|
||||
binding.monthView.togglePrintMode()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string name="app_name">Agenda simple</string>
|
||||
<string name="app_launcher_name">Agenda</string>
|
||||
<string name="change_view">Changer de vue</string>
|
||||
|
@ -252,17 +252,17 @@
|
|||
<string name="today_only">Aujourd\'hui seulement</string>
|
||||
<string name="within_the_next">Au cours du prochain…</string>
|
||||
<plurals name="within_the_next_days">
|
||||
<item quantity="one">Au cours de la prochaine journée</item>
|
||||
<item quantity="one" tools:ignore="ImpliedQuantity">Au cours de la prochaine journée</item>
|
||||
<item quantity="many">Au cours des %d prochains jours</item>
|
||||
<item quantity="other">Au cours des %d prochains jours</item>
|
||||
</plurals>
|
||||
<plurals name="within_the_next_weeks">
|
||||
<item quantity="one">Au cours de la prochaine semaine</item>
|
||||
<item quantity="one" tools:ignore="ImpliedQuantity">Au cours de la prochaine semaine</item>
|
||||
<item quantity="many">Au cours des %d prochaines semaines</item>
|
||||
<item quantity="other">Au cours des %d prochaines semaines</item>
|
||||
</plurals>
|
||||
<plurals name="within_the_next_months">
|
||||
<item quantity="one">Au cours du prochain mois</item>
|
||||
<item quantity="one" tools:ignore="ImpliedQuantity">Au cours du prochain mois</item>
|
||||
<item quantity="many">Au cours des %d prochains mois</item>
|
||||
<item quantity="other">Au cours des %d prochains mois</item>
|
||||
</plurals>
|
||||
|
|
Loading…
Reference in New Issue