diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/MainActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/MainActivity.kt index 17d767410..ce441d679 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/MainActivity.kt @@ -159,9 +159,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private var mStoredUse24HourFormat = false private var mStoredDimPastEvents = true private var mStoredDimCompletedTasks = true - private var mStoredHighlightWeekends = false + private var mStoredHighlightSaturdays = false + private var mStoredHighlightSundays = false private var mStoredStartWeekWithCurrentDay = false - private var mStoredHighlightWeekendsColor = 0 + private var mStoredHighlightSaturdaysColor = 0 + private var mStoredHighlightSundaysColor = 0 // search results have endless scrolling, so reaching the top/bottom fetches further results private var minFetchedSearchTS = 0L @@ -252,7 +254,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { super.onResume() if (mStoredTextColor != getProperTextColor() || mStoredBackgroundColor != getProperBackgroundColor() || mStoredPrimaryColor != getProperPrimaryColor() || mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredDimCompletedTasks != config.dimCompletedTasks - || mStoredHighlightWeekends != config.highlightWeekends || mStoredHighlightWeekendsColor != config.highlightWeekendsColor + || mStoredHighlightSaturdays != config.highlightSaturdays || mStoredHighlightSundays != config.highlightSundays || mStoredHighlightSaturdaysColor != config.highlightSaturdaysColor || mStoredHighlightSundaysColor != config.highlightSundaysColor ) { updateViewPager() } @@ -407,8 +409,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { mStoredUse24HourFormat = use24HourFormat mStoredDimPastEvents = dimPastEvents mStoredDimCompletedTasks = dimCompletedTasks - mStoredHighlightWeekends = highlightWeekends - mStoredHighlightWeekendsColor = highlightWeekendsColor + mStoredHighlightSaturdays = highlightSaturdays + mStoredHighlightSaturdaysColor = highlightSaturdaysColor + mStoredHighlightSundays = highlightSundays + mStoredHighlightSundaysColor = highlightSundaysColor mStoredMidnightSpan = showMidnightSpanningEventsAtTop mStoredStartWeekWithCurrentDay = startWeekWithCurrentDay } diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/SettingsActivity.kt index ebb569eb0..b6f318630 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/SettingsActivity.kt @@ -43,8 +43,10 @@ import org.fossify.calendar.helpers.DISPLAY_DESCRIPTION import org.fossify.calendar.helpers.DISPLAY_PAST_EVENTS import org.fossify.calendar.helpers.EVENTS_LIST_VIEW import org.fossify.calendar.helpers.Formatter -import org.fossify.calendar.helpers.HIGHLIGHT_WEEKENDS -import org.fossify.calendar.helpers.HIGHLIGHT_WEEKENDS_COLOR +import org.fossify.calendar.helpers.HIGHLIGHT_SATURDAYS +import org.fossify.calendar.helpers.HIGHLIGHT_SATURDAYS_COLOR +import org.fossify.calendar.helpers.HIGHLIGHT_SUNDAYS +import org.fossify.calendar.helpers.HIGHLIGHT_SUNDAYS_COLOR import org.fossify.calendar.helpers.IcsExporter import org.fossify.calendar.helpers.LAST_EVENT_REMINDER_MINUTES import org.fossify.calendar.helpers.LAST_EVENT_REMINDER_MINUTES_2 @@ -187,8 +189,10 @@ class SettingsActivity : SimpleActivity() { setupHourFormat() setupAllowCreatingTasks() setupStartWeekOn() - setupHighlightWeekends() - setupHighlightWeekendsColor() + setupHighlightSaturdays() + setupHighlightSaturdaysColor() + setupHighlightSundays() + setupHighlightSundaysColor() setupDeleteAllEvents() setupDisplayDescription() setupReplaceDescription() @@ -508,29 +512,60 @@ class SettingsActivity : SimpleActivity() { } } - private fun setupHighlightWeekends() = binding.apply { - settingsHighlightWeekends.isChecked = config.highlightWeekends - settingsHighlightWeekendsColorHolder.beVisibleIf(config.highlightWeekends) - settingsHighlightWeekendsHolder.setOnClickListener { - settingsHighlightWeekends.toggle() - config.highlightWeekends = settingsHighlightWeekends.isChecked - settingsHighlightWeekendsColorHolder.beVisibleIf(config.highlightWeekends) + private fun setupHighlightSaturdays() = binding.apply { + settingsHighlightSaturdays.isChecked = config.highlightSaturdays + settingsHighlightSaturdaysColorHolder.beVisibleIf(config.highlightSaturdays) + settingsHighlightSaturdaysHolder.setOnClickListener { + settingsHighlightSaturdays.toggle() + config.highlightSaturdays = settingsHighlightSaturdays.isChecked + settingsHighlightSaturdaysColorHolder.beVisibleIf(config.highlightSaturdays) } } - private fun setupHighlightWeekendsColor() = binding.apply { - settingsHighlightWeekendsColor.setFillWithStroke( - config.highlightWeekendsColor, + private fun setupHighlightSaturdaysColor() = binding.apply { + settingsHighlightSaturdaysColor.setFillWithStroke( + config.highlightSaturdaysColor, getProperBackgroundColor() ) - settingsHighlightWeekendsColorHolder.setOnClickListener { + settingsHighlightSaturdaysColorHolder.setOnClickListener { ColorPickerDialog( activity = this@SettingsActivity, - color = config.highlightWeekendsColor + color = config.highlightSaturdaysColor ) { wasPositivePressed, color -> if (wasPositivePressed) { - config.highlightWeekendsColor = color - settingsHighlightWeekendsColor.setFillWithStroke( + config.highlightSaturdaysColor = color + settingsHighlightSaturdaysColor.setFillWithStroke( + color, + getProperBackgroundColor() + ) + } + } + } + } + + private fun setupHighlightSundays() = binding.apply { + settingsHighlightSundays.isChecked = config.highlightSundays + settingsHighlightSundaysColorHolder.beVisibleIf(config.highlightSundays) + settingsHighlightSundaysHolder.setOnClickListener { + settingsHighlightSundays.toggle() + config.highlightSundays = settingsHighlightSundays.isChecked + settingsHighlightSundaysColorHolder.beVisibleIf(config.highlightSundays) + } + } + + private fun setupHighlightSundaysColor() = binding.apply { + settingsHighlightSundaysColor.setFillWithStroke( + config.highlightSundaysColor, + getProperBackgroundColor() + ) + settingsHighlightSundaysColorHolder.setOnClickListener { + ColorPickerDialog( + activity = this@SettingsActivity, + color = config.highlightSundaysColor + ) { wasPositivePressed, color -> + if (wasPositivePressed) { + config.highlightSundaysColor = color + settingsHighlightSundaysColor.setFillWithStroke( color, getProperBackgroundColor() ) @@ -1154,8 +1189,10 @@ class SettingsActivity : SimpleActivity() { put(SNOOZE_TIME, config.snoozeTime) put(USE_24_HOUR_FORMAT, config.use24HourFormat) put(FIRST_DAY_OF_WEEK, config.firstDayOfWeek) - put(HIGHLIGHT_WEEKENDS, config.highlightWeekends) - put(HIGHLIGHT_WEEKENDS_COLOR, config.highlightWeekendsColor) + put(HIGHLIGHT_SATURDAYS, config.highlightSaturdays) + put(HIGHLIGHT_SATURDAYS_COLOR, config.highlightSaturdaysColor) + put(HIGHLIGHT_SUNDAYS, config.highlightSundays) + put(HIGHLIGHT_SUNDAYS_COLOR, config.highlightSundaysColor) put(ALLOW_CREATING_TASKS, config.allowCreatingTasks) } @@ -1270,8 +1307,10 @@ class SettingsActivity : SimpleActivity() { USE_24_HOUR_FORMAT -> config.use24HourFormat = value.toBoolean() SUNDAY_FIRST -> config.firstDayOfWeek = DateTimeConstants.SUNDAY FIRST_DAY_OF_WEEK -> config.firstDayOfWeek = value.toInt() - HIGHLIGHT_WEEKENDS -> config.highlightWeekends = value.toBoolean() - HIGHLIGHT_WEEKENDS_COLOR -> config.highlightWeekendsColor = value.toInt() + HIGHLIGHT_SATURDAYS -> config.highlightSaturdays = value.toBoolean() + HIGHLIGHT_SATURDAYS_COLOR -> config.highlightSaturdaysColor = value.toInt() + HIGHLIGHT_SUNDAYS -> config.highlightSundays = value.toBoolean() + HIGHLIGHT_SUNDAYS_COLOR -> config.highlightSundaysColor = value.toInt() ALLOW_CREATING_TASKS -> config.allowCreatingTasks = value.toBoolean() } } diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/WidgetMonthlyConfigureActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/WidgetMonthlyConfigureActivity.kt index 704e11150..d54bea5a4 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/WidgetMonthlyConfigureActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/WidgetMonthlyConfigureActivity.kt @@ -16,7 +16,8 @@ import org.fossify.calendar.databinding.TopNavigationBinding import org.fossify.calendar.databinding.WidgetConfigMonthlyBinding import org.fossify.calendar.extensions.addDayEvents import org.fossify.calendar.extensions.config -import org.fossify.calendar.extensions.isWeekendIndex +import org.fossify.calendar.extensions.isSaturdayIndex +import org.fossify.calendar.extensions.isSundayIndex import org.fossify.calendar.helpers.MonthlyCalendarImpl import org.fossify.calendar.helpers.MyWidgetMonthlyProvider import org.fossify.calendar.interfaces.MonthlyCalendar @@ -174,8 +175,10 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { for (i in 0 until daysLength) { val day = mDays!![i] - val dayTextColor = if (config.highlightWeekends && day.isWeekend) { - config.highlightWeekendsColor + val dayTextColor = if (config.highlightSaturdays && day.isSaturday) { + config.highlightSaturdaysColor + } else if (config.highlightSundays && day.isSunday) { + config.highlightSundaysColor } else { mTextColor } @@ -222,11 +225,14 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { } private fun updateLabels() { - val weekendsTextColor = config.highlightWeekendsColor + val saturdaysTextColor = config.highlightSaturdaysColor + val sundaysTextColor = config.highlightSundaysColor binding.configCalendar.firstRow.apply { arrayOf(label0, label1, label2, label3, label4, label5, label6).forEachIndexed { index, textView -> - val textColor = if (config.highlightWeekends && isWeekendIndex(index)) { - weekendsTextColor + val textColor = if (config.highlightSaturdays && isSaturdayIndex(index)) { + saturdaysTextColor + } else if (config.highlightSundays && isSundayIndex(index)) { + sundaysTextColor } else { mTextColor } diff --git a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt index f9dd6af1e..f6498fa8c 100644 --- a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt @@ -68,7 +68,8 @@ import org.fossify.calendar.helpers.getActivityToOpen import org.fossify.calendar.helpers.getNextAutoBackupTime import org.fossify.calendar.helpers.getNowSeconds import org.fossify.calendar.helpers.getPreviousAutoBackupTime -import org.fossify.calendar.helpers.isWeekend +import org.fossify.calendar.helpers.isSaturday +import org.fossify.calendar.helpers.isSunday import org.fossify.calendar.interfaces.CalendarsDao import org.fossify.calendar.interfaces.EventsDao import org.fossify.calendar.interfaces.TasksDao @@ -1057,7 +1058,7 @@ fun Context.getProperDayIndexInWeek(date: DateTime): Int { return dayIndex } -fun Context.isWeekendIndex(dayIndex: Int): Boolean { +fun Context.isSaturdayIndex(dayIndex: Int): Boolean { val firstDayOfWeek = config.firstDayOfWeek val shiftedIndex = (dayIndex + firstDayOfWeek) % 7 val dayOfWeek = if (shiftedIndex == 0) { @@ -1066,7 +1067,19 @@ fun Context.isWeekendIndex(dayIndex: Int): Boolean { shiftedIndex } - return isWeekend(dayOfWeek) + return isSaturday(dayOfWeek) +} + +fun Context.isSundayIndex(dayIndex: Int): Boolean { + val firstDayOfWeek = config.firstDayOfWeek + val shiftedIndex = (dayIndex + firstDayOfWeek) % 7 + val dayOfWeek = if (shiftedIndex == 0) { + DateTimeConstants.SUNDAY + } else { + shiftedIndex + } + + return isSunday(dayOfWeek) } fun Context.isTaskCompleted(event: Event): Boolean { diff --git a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt index 67fe929d0..ebb404112 100644 --- a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt @@ -56,7 +56,8 @@ import org.fossify.calendar.helpers.TYPE_TASK import org.fossify.calendar.helpers.WEEK_START_TIMESTAMP import org.fossify.calendar.helpers.WeeklyCalendarImpl import org.fossify.calendar.helpers.getActivityToOpen -import org.fossify.calendar.helpers.isWeekend +import org.fossify.calendar.helpers.isSaturday +import org.fossify.calendar.helpers.isSunday import org.fossify.calendar.interfaces.WeekFragmentListener import org.fossify.calendar.interfaces.WeeklyCalendar import org.fossify.calendar.models.Event @@ -118,7 +119,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { private var wasExtraHeightAdded = false private var dimPastEvents = true private var dimCompletedTasks = true - private var highlightWeekends = false + private var highlightSaturdays = false + private var highlightSundays = false private var wasScaled = false private var isPrintVersion = false private var selectedGrid: View? = null @@ -148,7 +150,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { weekDateTime = Formatter.getDateTimeFromTS(weekTimestamp) dimPastEvents = config.dimPastEvents dimCompletedTasks = config.dimCompletedTasks - highlightWeekends = config.highlightWeekends + highlightSaturdays = config.highlightSaturdays + highlightSundays = config.highlightSundays primaryColor = requireContext().getProperPrimaryColor() allDayRows.add(HashSet()) } @@ -291,7 +294,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { val textColor = when { !isPrintVersion && todayCode == dayCode -> primaryColor - highlightWeekends && isWeekend(curDay.dayOfWeek) -> config.highlightWeekendsColor + highlightSaturdays && isSaturday(curDay.dayOfWeek) -> config.highlightSaturdaysColor + highlightSundays && isSunday(curDay.dayOfWeek) -> config.highlightSundaysColor isPrintVersion -> resources.getColor(org.fossify.commons.R.color.theme_light_text_color) else -> requireContext().getProperTextColor() } diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt index 1f70a900d..6ef4981d5 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt @@ -284,15 +284,25 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getInt(WEEKLY_VIEW_DAYS, 7) set(weeklyViewDays) = prefs.edit().putInt(WEEKLY_VIEW_DAYS, weeklyViewDays).apply() - var highlightWeekends: Boolean - get() = prefs.getBoolean(HIGHLIGHT_WEEKENDS, false) - set(highlightWeekends) = prefs.edit().putBoolean(HIGHLIGHT_WEEKENDS, highlightWeekends) + var highlightSaturdays: Boolean + get() = prefs.getBoolean(HIGHLIGHT_SATURDAYS, false) + set(highlightSaturdays) = prefs.edit().putBoolean(HIGHLIGHT_SATURDAYS, highlightSaturdays) .apply() - var highlightWeekendsColor: Int - get() = prefs.getInt(HIGHLIGHT_WEEKENDS_COLOR, context.resources.getColor(R.color.red_text)) - set(highlightWeekendsColor) = prefs.edit() - .putInt(HIGHLIGHT_WEEKENDS_COLOR, highlightWeekendsColor).apply() + var highlightSaturdaysColor: Int + get() = prefs.getInt(HIGHLIGHT_SATURDAYS_COLOR, context.resources.getColor(R.color.red_text)) + set(highlightSaturdaysColor) = prefs.edit() + .putInt(HIGHLIGHT_SATURDAYS_COLOR, highlightSaturdaysColor).apply() + + var highlightSundays: Boolean + get() = prefs.getBoolean(HIGHLIGHT_SUNDAYS, false) + set(highlightSundays) = prefs.edit().putBoolean(HIGHLIGHT_SUNDAYS, highlightSundays) + .apply() + + var highlightSundaysColor: Int + get() = prefs.getInt(HIGHLIGHT_SUNDAYS_COLOR, context.resources.getColor(R.color.red_text)) + set(highlightSundaysColor) = prefs.edit() + .putInt(HIGHLIGHT_SUNDAYS_COLOR, highlightSundaysColor).apply() var lastUsedEventSpan: Int get() = prefs.getInt(LAST_USED_EVENT_SPAN, YEAR_SECONDS) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt index 661c2486f..a4c607ec6 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt @@ -135,8 +135,10 @@ const val EXPORT_TASKS = "export_tasks" const val EXPORT_PAST_EVENTS = "export_past_events" const val WEEKLY_VIEW_ITEM_HEIGHT_MULTIPLIER = "weekly_view_item_height_multiplier" const val WEEKLY_VIEW_DAYS = "weekly_view_days" -const val HIGHLIGHT_WEEKENDS = "highlight_weekends" -const val HIGHLIGHT_WEEKENDS_COLOR = "highlight_weekends_color" +const val HIGHLIGHT_SATURDAYS = "highlight_saturdays" +const val HIGHLIGHT_SUNDAYS = "highlight_sundays" +const val HIGHLIGHT_SATURDAYS_COLOR = "highlight_saturdays_color" +const val HIGHLIGHT_SUNDAYS_COLOR = "highlight_sundays_color" const val LAST_USED_EVENT_SPAN = "last_used_event_span" const val ALLOW_CREATING_TASKS = "allow_creating_tasks" const val WAS_FILTERED_OUT_WARNING_SHOWN = "was_filtered_out_warning_shown" @@ -295,9 +297,14 @@ const val ACTION_MARK_COMPLETED = "ACTION_MARK_COMPLETED" fun getNowSeconds() = System.currentTimeMillis() / 1000L -fun isWeekend(dayOfWeek: Int): Boolean { - val weekendDays = listOf(DateTimeConstants.SATURDAY, DateTimeConstants.SUNDAY) - return dayOfWeek in weekendDays +fun isSaturday(dayOfWeek: Int): Boolean { + val saturDays = listOf(DateTimeConstants.SATURDAY) + return dayOfWeek in saturDays +} + +fun isSunday(dayOfWeek: Int): Boolean { + val sunDays = listOf(DateTimeConstants.SUNDAY) + return dayOfWeek in sunDays } fun getActivityToOpen(isTask: Boolean) = if (isTask) { diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/MonthlyCalendarImpl.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/MonthlyCalendarImpl.kt index 7cd7b0e48..3a1cf15b7 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/MonthlyCalendarImpl.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/MonthlyCalendarImpl.kt @@ -3,7 +3,8 @@ package org.fossify.calendar.helpers import android.content.Context import org.fossify.calendar.extensions.eventsHelper import org.fossify.calendar.extensions.getProperDayIndexInWeek -import org.fossify.calendar.extensions.isWeekendIndex +import org.fossify.calendar.extensions.isSaturdayIndex +import org.fossify.calendar.extensions.isSundayIndex import org.fossify.calendar.extensions.seconds import org.fossify.calendar.interfaces.MonthlyCalendar import org.fossify.calendar.models.DayMonthly @@ -70,7 +71,7 @@ class MonthlyCalendarImpl(val callback: MonthlyCalendar, val context: Context) { val newDay = curDay.withDayOfMonth(value) val dayCode = Formatter.getDayCodeFromDateTime(newDay) - val day = DayMonthly(value, isThisMonth, isToday, dayCode, newDay.weekOfWeekyear, ArrayList(), i, context.isWeekendIndex(i)) + val day = DayMonthly(value, isThisMonth, isToday, dayCode, newDay.weekOfWeekyear, ArrayList(), i, context.isSaturdayIndex(i), context.isSundayIndex(i)) days.add(day) value++ } diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/MyWidgetMonthlyProvider.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/MyWidgetMonthlyProvider.kt index aee73402f..f3c89d54c 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/MyWidgetMonthlyProvider.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/MyWidgetMonthlyProvider.kt @@ -120,8 +120,10 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { for (i in 0 until len) { val day = days[i] - val dayTextColor = if (context.config.highlightWeekends && day.isWeekend) { - context.config.highlightWeekendsColor + val dayTextColor = if (context.config.highlightSaturdays && day.isSaturday) { + context.config.highlightSaturdaysColor + } else if (context.config.highlightSundays && day.isSunday) { + context.config.highlightSundaysColor } else { textColor } @@ -240,8 +242,10 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { for (i in 0..6) { val id = resources.getIdentifier("label_$i", "id", packageName) - val dayTextColor = if (context.config.highlightWeekends && context.isWeekendIndex(i)) { - context.config.highlightWeekendsColor + val dayTextColor = if (context.config.highlightSaturdays && context.isSaturdayIndex(i)) { + context.config.highlightSaturdaysColor + } else if (context.config.highlightSundays && context.isSundayIndex(i)) { + context.config.highlightSundaysColor } else { textColor } diff --git a/app/src/main/kotlin/org/fossify/calendar/models/DayMonthly.kt b/app/src/main/kotlin/org/fossify/calendar/models/DayMonthly.kt index 2e25aac6e..3f051bf30 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/DayMonthly.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/DayMonthly.kt @@ -8,5 +8,6 @@ data class DayMonthly( val weekOfYear: Int, var dayEvents: ArrayList, var indexOnMonthView: Int, - var isWeekend: Boolean + var isSaturday: Boolean, + var isSunday: Boolean ) diff --git a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt index 6fbe3f8ef..72a71ab1d 100644 --- a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt +++ b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt @@ -43,7 +43,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private var dayHeight = 0f private var primaryColor = 0 private var textColor = 0 - private var weekendsTextColor = 0 + private var saturdaysTextColor = 0 + private var sundaysTextColor = 0 private var weekDaysLetterHeight = 0 private var eventTitleHeight = 0 private var currDayOfWeek = 0 @@ -53,7 +54,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private var showWeekNumbers = false private var dimPastEvents = true private var dimCompletedTasks = true - private var highlightWeekends = false + private var highlightSaturdays = false + private var highlightSundays = false private var isPrintVersion = false private var isMonthDayView = false private var allEvents = ArrayList() @@ -69,11 +71,13 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con init { primaryColor = context.getProperPrimaryColor() textColor = context.getProperTextColor() - weekendsTextColor = config.highlightWeekendsColor + saturdaysTextColor = config.highlightSaturdaysColor + sundaysTextColor = config.highlightSundaysColor showWeekNumbers = config.showWeekNumbers dimPastEvents = config.dimPastEvents dimCompletedTasks = config.dimCompletedTasks - highlightWeekends = config.highlightWeekends + highlightSaturdays = config.highlightSaturdays + highlightSundays = config.highlightSundays smallPadding = resources.displayMetrics.density.toInt() val normalTextSize = resources.getDimensionPixelSize(org.fossify.commons.R.dimen.normal_text_size) @@ -299,8 +303,10 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con var weekDayLetterPaint = textPaint if (i == currDayOfWeek && !isPrintVersion) { weekDayLetterPaint = getColoredPaint(primaryColor) - } else if (highlightWeekends && context.isWeekendIndex(i)) { - weekDayLetterPaint = getColoredPaint(weekendsTextColor) + } else if (highlightSaturdays && context.isSaturdayIndex(i)) { + weekDayLetterPaint = getColoredPaint(saturdaysTextColor) + } else if (highlightSundays && context.isSundayIndex(i)) { + weekDayLetterPaint = getColoredPaint(sundaysTextColor) } canvas.drawText(dayLetters[i], xPos, weekDaysLetterHeight * 0.7f, weekDayLetterPaint) } @@ -389,7 +395,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private fun getTextPaint(startDay: DayMonthly): Paint { var paintColor = when { !isPrintVersion && startDay.isToday -> primaryColor.getContrastColor() - highlightWeekends && startDay.isWeekend -> weekendsTextColor + highlightSaturdays && startDay.isSaturday -> saturdaysTextColor + highlightSundays && startDay.isSunday -> sundaysTextColor else -> textColor } diff --git a/app/src/main/kotlin/org/fossify/calendar/views/SmallMonthView.kt b/app/src/main/kotlin/org/fossify/calendar/views/SmallMonthView.kt index 7d0021f53..7d4db7e71 100644 --- a/app/src/main/kotlin/org/fossify/calendar/views/SmallMonthView.kt +++ b/app/src/main/kotlin/org/fossify/calendar/views/SmallMonthView.kt @@ -8,7 +8,8 @@ import android.util.AttributeSet import android.view.View import org.fossify.calendar.R import org.fossify.calendar.extensions.config -import org.fossify.calendar.extensions.isWeekendIndex +import org.fossify.calendar.extensions.isSaturdayIndex +import org.fossify.calendar.extensions.isSundayIndex import org.fossify.calendar.models.DayYearly import org.fossify.commons.extensions.adjustAlpha import org.fossify.commons.extensions.getProperPrimaryColor @@ -21,10 +22,12 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie private var todayCirclePaint: Paint private var dayWidth = 0f private var textColor = 0 - private var weekendsTextColor = 0 + private var saturdaysTextColor = 0 + private var sundaysTextColor = 0 private var days = 31 private var isLandscape = false - private var highlightWeekends = false + private var highlightSaturdays = false + private var highlightSundays = false private var isPrintVersion = false private var mEvents: ArrayList? = null @@ -58,8 +61,10 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie val baseColor = context.getProperTextColor() textColor = baseColor.adjustAlpha(MEDIUM_ALPHA) - weekendsTextColor = context.config.highlightWeekendsColor.adjustAlpha(MEDIUM_ALPHA) - highlightWeekends = context.config.highlightWeekends + saturdaysTextColor = context.config.highlightSaturdaysColor.adjustAlpha(MEDIUM_ALPHA) + sundaysTextColor = context.config.highlightSundaysColor.adjustAlpha(MEDIUM_ALPHA) + highlightSaturdays = context.config.highlightSaturdays + highlightSundays = context.config.highlightSundays paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { color = textColor @@ -90,7 +95,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie for (y in 1..6) { for (x in 1..7) { if (curId in 1..days) { - val textPaint = getPaint(curId, x, highlightWeekends) + val textPaint = getPaint(curId, x, highlightSaturdays, highlightSundays) val centerX = x * dayWidth - dayWidth / 2 val centerY = y * dayWidth - dayWidth / 2 val baselineY = centerY - (fm.ascent + fm.descent) / 2 @@ -105,15 +110,19 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie } } - private fun getPaint(curId: Int, weekDay: Int, highlightWeekends: Boolean): Paint { + private fun getPaint(curId: Int, weekDay: Int, highlightSaturdays: Boolean, highlightSundays: Boolean): Paint { val colors = mEvents?.get(curId)?.eventColors ?: HashSet() if (colors.isNotEmpty()) { val curPaint = Paint(paint) curPaint.color = colors.first() return curPaint - } else if (highlightWeekends && context.isWeekendIndex(weekDay - 1)) { + } else if (highlightSaturdays && context.isSaturdayIndex(weekDay - 1)) { val curPaint = Paint(paint) - curPaint.color = weekendsTextColor + curPaint.color = saturdaysTextColor + return curPaint + } else if (highlightSundays && context.isSundayIndex(weekDay - 1)) { + val curPaint = Paint(paint) + curPaint.color = sundaysTextColor return curPaint } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 803696de0..daaa6843a 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -199,39 +199,80 @@ + android:text="@string/highlight_saturdays" /> + android:text="@string/highlight_saturdays_color" /> + + + + + + + + + + + + + + Default duration Last used one Other time - Highlight weekends on some views - Color of highlighted weekends + Highlight Saturdays on some views + Color of highlighted Saturdays + Highlight Sundays on some views + Color of highlighted Sundays Allow changing event time zones Manage quick filter calendars Allow creating tasks