mirror of
https://github.com/FossifyOrg/Calendar.git
synced 2026-04-29 10:25:29 -04:00
Format code
This commit is contained in:
@@ -10,7 +10,11 @@ import org.fossify.calendar.databinding.MonthViewBinding
|
||||
import org.fossify.calendar.extensions.config
|
||||
import org.fossify.calendar.extensions.launchNewEventIntent
|
||||
import org.fossify.calendar.extensions.launchNewTaskIntent
|
||||
import org.fossify.calendar.helpers.*
|
||||
import org.fossify.calendar.helpers.COLUMN_COUNT
|
||||
import org.fossify.calendar.helpers.Formatter
|
||||
import org.fossify.calendar.helpers.ROW_COUNT
|
||||
import org.fossify.calendar.helpers.TYPE_EVENT
|
||||
import org.fossify.calendar.helpers.TYPE_TASK
|
||||
import org.fossify.calendar.models.DayMonthly
|
||||
import org.fossify.commons.compose.extensions.getActivity
|
||||
import org.fossify.commons.dialogs.RadioGroupDialog
|
||||
@@ -18,7 +22,11 @@ import org.fossify.commons.extensions.onGlobalLayout
|
||||
import org.fossify.commons.models.RadioItem
|
||||
|
||||
// used in the Monthly view fragment, 1 view per screen
|
||||
class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : FrameLayout(context, attrs, defStyle) {
|
||||
class MonthViewWrapper(
|
||||
context: Context,
|
||||
attrs: AttributeSet,
|
||||
defStyle: Int
|
||||
) : FrameLayout(context, attrs, defStyle) {
|
||||
private var dayWidth = 0f
|
||||
private var dayHeight = 0f
|
||||
private var weekDaysLetterHeight = 0
|
||||
@@ -33,7 +41,8 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
|
||||
|
||||
init {
|
||||
val normalTextSize = resources.getDimensionPixelSize(org.fossify.commons.R.dimen.normal_text_size).toFloat()
|
||||
val normalTextSize =
|
||||
resources.getDimensionPixelSize(org.fossify.commons.R.dimen.normal_text_size).toFloat()
|
||||
weekDaysLetterHeight = 2 * normalTextSize.toInt()
|
||||
|
||||
inflater = LayoutInflater.from(context)
|
||||
@@ -76,7 +85,12 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
val childRight = childLeft + childWidth
|
||||
val childBottom = childTop + childHeight
|
||||
|
||||
child.layout(childLeft.toInt(), childTop.toInt(), childRight.toInt(), childBottom.toInt())
|
||||
child.layout(
|
||||
childLeft.toInt(),
|
||||
childTop.toInt(),
|
||||
childRight.toInt(),
|
||||
childBottom.toInt()
|
||||
)
|
||||
|
||||
if (curLeft + childWidth <= end) {
|
||||
curLeft += childWidth
|
||||
@@ -89,7 +103,11 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
}
|
||||
}
|
||||
|
||||
fun updateDays(newDays: ArrayList<DayMonthly>, addEvents: Boolean, callback: ((DayMonthly) -> Unit)? = null) {
|
||||
fun updateDays(
|
||||
newDays: ArrayList<DayMonthly>,
|
||||
addEvents: Boolean,
|
||||
callback: ((DayMonthly) -> Unit)? = null
|
||||
) {
|
||||
setupHorizontalOffset()
|
||||
measureSizes()
|
||||
dayClickCallback = callback
|
||||
@@ -132,7 +150,12 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
background = null
|
||||
}
|
||||
//Accessible label composed by day and month
|
||||
contentDescription = "${day.value} ${Formatter.getMonthName(context, Formatter.getDateTimeFromCode(day.code).monthOfYear)}"
|
||||
contentDescription = "${day.value} ${
|
||||
Formatter.getMonthName(
|
||||
context,
|
||||
Formatter.getDateTimeFromCode(day.code).monthOfYear
|
||||
)
|
||||
}"
|
||||
|
||||
setOnClickListener {
|
||||
dayClickCallback?.invoke(day)
|
||||
@@ -142,7 +165,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
}
|
||||
}
|
||||
|
||||
setOnLongClickListener{
|
||||
setOnLongClickListener {
|
||||
if (context.config.allowCreatingTasks) {
|
||||
val items = arrayListOf(
|
||||
RadioItem(TYPE_EVENT, context.getString(R.string.event)),
|
||||
@@ -156,8 +179,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
|
||||
context.launchNewTaskIntent(day.code)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
context.launchNewEventIntent(day.code)
|
||||
}
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user