Add 'Dim completed tasks' preference
Set to `true` by default
This commit is contained in:
parent
d10dd72681
commit
06955ef65d
11 changed files with 90 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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<String>
|
||||
val existingEventTypeNames = eventsHelper.getEventTypesSync().map { it.getDisplayTitle().lowercase(Locale.getDefault()) } as ArrayList<String>
|
||||
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()
|
||||
|
|
|
@ -27,6 +27,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, 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()
|
||||
|
||||
|
@ -95,7 +96,13 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, 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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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,13 @@ 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,7 +692,13 @@ 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)
|
||||
}
|
||||
|
|
|
@ -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<Int>
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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,13 @@ 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 +351,12 @@ 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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/settings_allow_creating_tasks"
|
||||
|
@ -957,6 +957,21 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_dim_completed_tasks_holder"
|
||||
style="@style/SettingsHolderCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple_bottom_corners">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/settings_dim_completed_tasks"
|
||||
style="@style/SettingsCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dim_completed_tasks" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in a new issue