diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt index e06d4db1e..bf275c552 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt @@ -80,6 +80,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private var mStoredMidnightSpan = true private var mStoredUse24HourFormat = false private var mStoredDimPastEvents = true + private var mStoredDimCompletedTasks = true private var mStoredHighlightWeekends = false private var mStoredStartWeekWithCurrentDay = false private var mStoredHighlightWeekendsColor = 0 @@ -156,8 +157,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { override fun onResume() { super.onResume() if (mStoredTextColor != getProperTextColor() || mStoredBackgroundColor != getProperBackgroundColor() || mStoredPrimaryColor != getProperPrimaryColor() - || mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredHighlightWeekends != config.highlightWeekends - || mStoredHighlightWeekendsColor != config.highlightWeekendsColor + || mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredDimCompletedTasks != config.dimCompletedTasks + || mStoredHighlightWeekends != config.highlightWeekends || mStoredHighlightWeekendsColor != config.highlightWeekendsColor ) { updateViewPager() } @@ -300,6 +301,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { mStoredIsSundayFirst = isSundayFirst mStoredUse24HourFormat = use24HourFormat mStoredDimPastEvents = dimPastEvents + mStoredDimCompletedTasks = dimCompletedTasks mStoredHighlightWeekends = highlightWeekends mStoredHighlightWeekendsColor = highlightWeekendsColor mStoredMidnightSpan = showMidnightSpanningEventsAtTop diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt index ec55c3284..72c6d70f2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt @@ -85,6 +85,7 @@ class SettingsActivity : SimpleActivity() { setupCustomizeWidgetColors() setupViewToOpenFromListWidget() setupDimEvents() + setupDimCompletedTasks() setupAllowChangingTimeZones() updateTextColors(settings_holder) checkPrimaryColor() @@ -319,12 +320,12 @@ class SettingsActivity : SimpleActivity() { ensureBackgroundThread { if (newCalendarIds.isNotEmpty()) { - val existingEventTypeNames = eventsHelper.getEventTypesSync().map { it.getDisplayTitle().toLowerCase() } as ArrayList + val existingEventTypeNames = eventsHelper.getEventTypesSync().map { it.getDisplayTitle().lowercase(Locale.getDefault()) } as ArrayList getSyncedCalDAVCalendars().forEach { val calendarTitle = it.getFullTitle() - if (!existingEventTypeNames.contains(calendarTitle.toLowerCase())) { + if (!existingEventTypeNames.contains(calendarTitle.lowercase(Locale.getDefault()))) { val eventType = EventType(null, it.displayName, it.color, it.id, it.displayName, it.accountName) - existingEventTypeNames.add(calendarTitle.toLowerCase()) + existingEventTypeNames.add(calendarTitle.lowercase(Locale.getDefault())) eventsHelper.insertOrUpdateEventType(this, eventType) } } @@ -732,6 +733,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupDimCompletedTasks() { + settings_dim_completed_tasks.isChecked = config.dimCompletedTasks + settings_dim_completed_tasks_holder.setOnClickListener { + settings_dim_completed_tasks.toggle() + config.dimCompletedTasks = settings_dim_completed_tasks.isChecked + } + } + private fun setupAllowChangingTimeZones() { settings_allow_changing_time_zones.isChecked = config.allowChangingTimeZones settings_allow_changing_time_zones_holder.setOnClickListener { @@ -870,6 +879,7 @@ class SettingsActivity : SimpleActivity() { put(SHOW_GRID, config.showGrid) put(LOOP_REMINDERS, config.loopReminders) put(DIM_PAST_EVENTS, config.dimPastEvents) + put(DIM_COMPLETED_TASKS, config.dimCompletedTasks) put(ALLOW_CHANGING_TIME_ZONES, config.allowChangingTimeZones) put(USE_PREVIOUS_EVENT_REMINDERS, config.usePreviousEventReminders) put(DEFAULT_REMINDER_1, config.defaultReminder1) @@ -975,6 +985,7 @@ class SettingsActivity : SimpleActivity() { SHOW_GRID -> config.showGrid = value.toBoolean() LOOP_REMINDERS -> config.loopReminders = value.toBoolean() DIM_PAST_EVENTS -> config.dimPastEvents = value.toBoolean() + DIM_COMPLETED_TASKS -> config.dimCompletedTasks = value.toBoolean() ALLOW_CHANGING_TIME_ZONES -> config.allowChangingTimeZones = value.toBoolean() USE_PREVIOUS_EVENT_REMINDERS -> config.usePreviousEventReminders = value.toBoolean() DEFAULT_REMINDER_1 -> config.defaultReminder1 = value.toInt() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt index 7a9ede381..236e2cd0b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt @@ -27,6 +27,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r private val displayDescription = activity.config.displayDescription private val replaceDescriptionWithLocation = activity.config.replaceDescription private val dimPastEvents = activity.config.dimPastEvents + private val dimCompletedTasks = activity.config.dimCompletedTasks private var isPrintVersion = false private val mediumMargin = activity.resources.getDimension(R.dimen.medium_margin).toInt() @@ -76,6 +77,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r } else { activity.getProperTextColor() } + notifyDataSetChanged() } @@ -95,7 +97,14 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r event_item_color_bar.background.applyColorFilter(event.color) var newTextColor = textColor - if (dimPastEvents && event.isPastEvent && !isPrintVersion) { + + val adjustAlpha = if (event.isTask()) { + dimCompletedTasks && event.isTaskCompleted() + } else { + dimPastEvents && event.isPastEvent && !isPrintVersion + } + + if (adjustAlpha) { newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA) } @@ -110,6 +119,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r } else { mediumMargin } + (event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt index 857864a77..4428846fc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt @@ -34,6 +34,7 @@ class EventListAdapter( private val displayDescription = activity.config.displayDescription private val replaceDescription = activity.config.replaceDescription private val dimPastEvents = activity.config.dimPastEvents + private val dimCompletedTasks = activity.config.dimCompletedTasks private val now = getNowSeconds() private var use24HourFormat = activity.config.use24HourFormat private var currentItemsHash = listItems.hashCode() @@ -156,7 +157,12 @@ class EventListAdapter( newTextColor = properPrimaryColor } - if (dimPastEvents && listEvent.isPastEvent && !isPrintVersion) { + val adjustAlpha = if (listEvent.isTask) { + dimCompletedTasks && listEvent.isTaskCompleted + } else { + dimPastEvents && listEvent.isPastEvent && !isPrintVersion + } + if (adjustAlpha) { newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA) } } else if (listEvent.startTS <= now && listEvent.endTS >= now && !isPrintVersion) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt index d1455f154..2b018d17c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt @@ -30,6 +30,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV private var displayDescription = context.config.displayDescription private var replaceDescription = context.config.replaceDescription private var dimPastEvents = context.config.dimPastEvents + private var dimCompletedTasks = context.config.dimCompletedTasks private var mediumFontSize = context.getWidgetFontSize() private var smallMargin = context.resources.getDimension(R.dimen.small_margin).toInt() private var normalMargin = context.resources.getDimension(R.dimen.normal_margin).toInt() @@ -44,6 +45,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV displayDescription = context.config.displayDescription replaceDescription = context.config.replaceDescription dimPastEvents = context.config.dimPastEvents + dimCompletedTasks = context.config.dimCompletedTasks mediumFontSize = context.getWidgetFontSize() } @@ -101,7 +103,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV setText(R.id.event_item_time, "$timeText\n$descriptionText") } - if (dimPastEvents && item.isPastEvent) { + if (item.isTask && item.isTaskCompleted && dimCompletedTasks || dimPastEvents && item.isPastEvent) { curTextColor = weakTextColor } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index af0263c6e..0434c9fff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -61,6 +61,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { private var wasFragmentInit = false private var wasExtraHeightAdded = false private var dimPastEvents = true + private var dimCompletedTasks = true private var highlightWeekends = false private var wasScaled = false private var isPrintVersion = false @@ -89,6 +90,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { defaultRowHeight = res.getDimension(R.dimen.weekly_view_row_height) weekTimestamp = requireArguments().getLong(WEEK_START_TIMESTAMP) dimPastEvents = config.dimPastEvents + dimCompletedTasks = config.dimCompletedTasks highlightWeekends = config.highlightWeekends primaryColor = requireContext().getProperPrimaryColor() allDayRows.add(HashSet()) @@ -550,7 +552,14 @@ class WeekFragment : Fragment(), WeeklyCalendar { var backgroundColor = eventTypeColors.get(event.eventType, primaryColor) var textColor = backgroundColor.getContrastColor() val currentEventWeeklyView = eventTimeRanges[currentDayCode]!!.get(event.id) - if (dimPastEvents && event.isPastEvent && !isPrintVersion) { + + val adjustAlpha = if (event.isTask()) { + dimCompletedTasks && event.isTaskCompleted() + } else { + dimPastEvents && event.isPastEvent && !isPrintVersion + } + + if (adjustAlpha) { backgroundColor = backgroundColor.adjustAlpha(MEDIUM_ALPHA) textColor = textColor.adjustAlpha(HIGHER_ALPHA) } @@ -684,10 +693,18 @@ class WeekFragment : Fragment(), WeeklyCalendar { (inflater.inflate(R.layout.week_all_day_event_marker, null, false) as ConstraintLayout).apply { var backgroundColor = eventTypeColors.get(event.eventType, primaryColor) var textColor = backgroundColor.getContrastColor() - if (dimPastEvents && event.isPastEvent && !isPrintVersion) { + + val adjustAlpha = if (event.isTask()) { + dimCompletedTasks && event.isTaskCompleted() + } else { + dimPastEvents && event.isPastEvent && !isPrintVersion + } + + if (adjustAlpha) { backgroundColor = backgroundColor.adjustAlpha(LOWER_ALPHA) textColor = textColor.adjustAlpha(HIGHER_ALPHA) } + background = ColorDrawable(backgroundColor) week_event_label.apply { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt index 5419de4d5..977aac1c7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt @@ -138,6 +138,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(DIM_PAST_EVENTS, true) set(dimPastEvents) = prefs.edit().putBoolean(DIM_PAST_EVENTS, dimPastEvents).apply() + var dimCompletedTasks: Boolean + get() = prefs.getBoolean(DIM_COMPLETED_TASKS, true) + set(dimCompletedTasks) = prefs.edit().putBoolean(DIM_COMPLETED_TASKS, dimCompletedTasks).apply() + fun getSyncedCalendarIdsAsList() = caldavSyncedCalendarIds.split(",").filter { it.trim().isNotEmpty() }.map { Integer.parseInt(it) }.toMutableList() as ArrayList diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index 1c5d0d2ee..23c13290c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -87,6 +87,7 @@ const val REPLACE_DESCRIPTION = "replace_description" const val SHOW_GRID = "show_grid" const val LOOP_REMINDERS = "loop_reminders" const val DIM_PAST_EVENTS = "dim_past_events" +const val DIM_COMPLETED_TASKS = "dim_completed_tasks" const val LAST_SOUND_URI = "last_sound_uri" const val LAST_REMINDER_CHANNEL_ID = "last_reminder_channel_ID" const val REMINDER_AUDIO_STREAM = "reminder_audio_stream" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt index 1554499ca..cde88b056 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt @@ -97,6 +97,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { val displayWeekNumbers = context.config.showWeekNumbers val textColor = context.config.widgetTextColor val dimPastEvents = context.config.dimPastEvents + val dimCompletedTasks = context.config.dimCompletedTasks val smallerFontSize = context.getWidgetFontSize() - 3f val res = context.resources val len = days.size @@ -140,7 +141,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { var backgroundColor = it.color var eventTextColor = backgroundColor.getContrastColor() - if (!day.isThisMonth || (dimPastEvents && it.isPastEvent)) { + if (it.isTask() && it.isTaskCompleted() && dimCompletedTasks || !day.isThisMonth || (dimPastEvents && it.isPastEvent)) { eventTextColor = eventTextColor.adjustAlpha(MEDIUM_ALPHA) backgroundColor = backgroundColor.adjustAlpha(MEDIUM_ALPHA) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/DayMonthly.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/DayMonthly.kt index 29b4f72bd..9054c6269 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/DayMonthly.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/DayMonthly.kt @@ -1,4 +1,12 @@ package com.simplemobiletools.calendar.pro.models -data class DayMonthly(val value: Int, val isThisMonth: Boolean, val isToday: Boolean, val code: String, val weekOfYear: Int, var dayEvents: ArrayList, - var indexOnMonthView: Int, var isWeekend: Boolean) +data class DayMonthly( + val value: Int, + val isThisMonth: Boolean, + val isToday: Boolean, + val code: String, + val weekOfYear: Int, + var dayEvents: ArrayList, + var indexOnMonthView: Int, + var isWeekend: Boolean +) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt index 8c3a44e8d..8ade73dd6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt @@ -46,6 +46,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private var horizontalOffset = 0 private var showWeekNumbers = false private var dimPastEvents = true + private var dimCompletedTasks = true private var highlightWeekends = false private var isPrintVersion = false private var isMonthDayView = false @@ -65,6 +66,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con weekendsTextColor = config.highlightWeekendsColor showWeekNumbers = config.showWeekNumbers dimPastEvents = config.dimPastEvents + dimCompletedTasks = config.dimCompletedTasks highlightWeekends = config.highlightWeekends smallPadding = resources.displayMetrics.density.toInt() @@ -334,7 +336,14 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private fun getEventBackgroundColor(event: MonthViewEvent, startDay: DayMonthly, endDay: DayMonthly): Paint { var paintColor = event.color - if ((!startDay.isThisMonth && !endDay.isThisMonth) || (dimPastEvents && event.isPastEvent && !isPrintVersion)) { + + val adjustAlpha = when { + event.isTask -> dimCompletedTasks && event.isTaskCompleted + !startDay.isThisMonth && !endDay.isThisMonth -> true + else -> dimPastEvents && event.isPastEvent && !isPrintVersion + } + + if (adjustAlpha) { paintColor = paintColor.adjustAlpha(MEDIUM_ALPHA) } @@ -343,7 +352,13 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private fun getEventTitlePaint(event: MonthViewEvent, startDay: DayMonthly, endDay: DayMonthly): Paint { var paintColor = event.color.getContrastColor() - if ((!startDay.isThisMonth && !endDay.isThisMonth) || (dimPastEvents && event.isPastEvent && !isPrintVersion)) { + val adjustAlpha = when { + event.isTask -> dimCompletedTasks && event.isTaskCompleted + !startDay.isThisMonth && !endDay.isThisMonth -> true + else -> dimPastEvents && event.isPastEvent && !isPrintVersion + } + + if (adjustAlpha) { paintColor = paintColor.adjustAlpha(HIGHER_ALPHA) } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index f2fbbdb76..00f36e038 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -946,7 +946,7 @@ style="@style/SettingsHolderCheckboxStyle" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/ripple_all_corners"> + android:background="@drawable/ripple_top_corners"> + + + + +