diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt index 008f1335a..7fb8743bd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -52,6 +52,7 @@ class SettingsActivity : SimpleActivity() { setupDeleteAllEvents() setupReplaceDescription() setupWeekNumbers() + setupShowGrid() setupWeeklyStart() setupWeeklyEnd() setupVibrate() @@ -274,6 +275,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupShowGrid() { + settings_show_grid.isChecked = config.showGrid + settings_show_grid_holder.setOnClickListener { + settings_show_grid.toggle() + config.showGrid = settings_show_grid.isChecked + } + } + private fun setupReminderSound() { settings_reminder_sound.text = config.reminderSoundTitle diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt index 0f9de4500..8fd699de6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt @@ -85,6 +85,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(REPLACE_DESCRIPTION, false) set(replaceDescription) = prefs.edit().putBoolean(REPLACE_DESCRIPTION, replaceDescription).apply() + var showGrid: Boolean + get() = prefs.getBoolean(SHOW_GRID, false) + set(showGrid) = prefs.edit().putBoolean(SHOW_GRID, showGrid).apply() + fun getSyncedCalendarIdsAsList() = caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList fun addDisplayEventType(type: String) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt index a8d998681..ab8956029 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -50,6 +50,7 @@ const val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids" const val LAST_USED_CALDAV_CALENDAR = "last_used_caldav_calendar" const val DISPLAY_PAST_EVENTS = "display_past_events" const val REPLACE_DESCRIPTION = "replace_description" +const val SHOW_GRID = "show_grid" // repeat_rule for monthly repetition const val REPEAT_MONTH_SAME_DAY = 1 // ie 25th every month diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt index 66c5f71f0..2bb39700f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt @@ -31,6 +31,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private var paint: Paint private var eventTitlePaint: TextPaint + private var gridPaint: Paint private var dayWidth = 0f private var dayHeight = 0f private var primaryColor = 0 @@ -65,6 +66,10 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con textAlign = Paint.Align.CENTER } + gridPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { + color = textColor.adjustAlpha(LOW_ALPHA) + } + val smallerTextSize = resources.getDimensionPixelSize(R.dimen.smaller_text_size) eventTitleHeight = smallerTextSize eventTitlePaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply { @@ -112,6 +117,10 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con dayVerticalOffsets.clear() measureDaySize(canvas) + if (context.config.showGrid) { + drawGrid(canvas) + } + addWeekDayLetters(canvas) if (showWeekNumbers) { addWeekNumbers(canvas) @@ -141,6 +150,17 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con drawEvents(canvas) } + private fun drawGrid(canvas: Canvas) { + for (i in 0..6) { + canvas.drawLine(i * dayWidth, 0f, i * dayWidth, canvas.height.toFloat(), gridPaint) + } + + canvas.drawLine(0f, 0f, canvas.width.toFloat(), 0f, gridPaint) + for (i in 0..5) { + canvas.drawLine(0f, i * dayHeight + weekDaysLetterHeight, canvas.width.toFloat(), i * dayHeight + weekDaysLetterHeight, gridPaint) + } + } + private fun addWeekDayLetters(canvas: Canvas) { for (i in 0..6) { val xPos = horizontalOffset + (i + 1) * dayWidth - dayWidth / 2 @@ -148,7 +168,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con if (i == currDayOfWeek) { weekDayLetterPaint = getColoredPaint(primaryColor) } - canvas.drawText(dayLetters[i], xPos, weekDaysLetterHeight / 2f, weekDayLetterPaint) + canvas.drawText(dayLetters[i], xPos, weekDaysLetterHeight * 0.7f, weekDayLetterPaint) } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 6fb597e5d..6df46ade7 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -494,6 +494,29 @@ + + + + + +