mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
Define weekends highlight color in config
This commit is contained in:
@@ -82,6 +82,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
private var mStoredDimPastEvents = true
|
private var mStoredDimPastEvents = true
|
||||||
private var mStoredHighlightWeekends = false
|
private var mStoredHighlightWeekends = false
|
||||||
private var mStoredStartWeekWithCurrentDay = false
|
private var mStoredStartWeekWithCurrentDay = false
|
||||||
|
private var mStoredHighlightWeekendsColor = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -134,7 +135,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredAdjustedPrimaryColor != getAdjustedPrimaryColor()
|
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredAdjustedPrimaryColor != getAdjustedPrimaryColor()
|
||||||
|| mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredHighlightWeekends != config.highlightWeekends
|
|| mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredHighlightWeekends != config.highlightWeekends
|
||||||
) {
|
|| mStoredHighlightWeekendsColor != config.highlightWeekendsColor) {
|
||||||
updateViewPager()
|
updateViewPager()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,6 +263,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
mStoredUse24HourFormat = use24HourFormat
|
mStoredUse24HourFormat = use24HourFormat
|
||||||
mStoredDimPastEvents = dimPastEvents
|
mStoredDimPastEvents = dimPastEvents
|
||||||
mStoredHighlightWeekends = highlightWeekends
|
mStoredHighlightWeekends = highlightWeekends
|
||||||
|
mStoredHighlightWeekendsColor = highlightWeekendsColor
|
||||||
mStoredMidnightSpan = showMidnightSpanningEventsAtTop
|
mStoredMidnightSpan = showMidnightSpanningEventsAtTop
|
||||||
mStoredStartWeekWithCurrentDay = startWeekWithCurrentDay
|
mStoredStartWeekWithCurrentDay = startWeekWithCurrentDay
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,8 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
|
|||||||
private var mTextColor = 0
|
private var mTextColor = 0
|
||||||
private var mWeakTextColor = 0
|
private var mWeakTextColor = 0
|
||||||
private var mPrimaryColor = 0
|
private var mPrimaryColor = 0
|
||||||
private var mRedTextColor = 0
|
private var mWeekendsTextColor = 0
|
||||||
|
private var mHighlightWeekends = false
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
@@ -131,7 +132,8 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
|
|||||||
mTextColor = mTextColorWithoutTransparency
|
mTextColor = mTextColorWithoutTransparency
|
||||||
mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOWER_ALPHA)
|
mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOWER_ALPHA)
|
||||||
mPrimaryColor = config.primaryColor
|
mPrimaryColor = config.primaryColor
|
||||||
mRedTextColor = resources.getColor(R.color.red_text)
|
mWeekendsTextColor = config.highlightWeekendsColor
|
||||||
|
mHighlightWeekends = config.highlightWeekends
|
||||||
|
|
||||||
top_left_arrow.applyColorFilter(mTextColor)
|
top_left_arrow.applyColorFilter(mTextColor)
|
||||||
top_right_arrow.applyColorFilter(mTextColor)
|
top_right_arrow.applyColorFilter(mTextColor)
|
||||||
@@ -171,7 +173,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
|
|||||||
removeAllViews()
|
removeAllViews()
|
||||||
|
|
||||||
val dayTextColor = if (config.highlightWeekends && day.isWeekend) {
|
val dayTextColor = if (config.highlightWeekends && day.isWeekend) {
|
||||||
mRedTextColor
|
config.highlightWeekendsColor
|
||||||
} else {
|
} else {
|
||||||
mTextColor
|
mTextColor
|
||||||
}
|
}
|
||||||
@@ -205,7 +207,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
|
|||||||
for (i in 0..6) {
|
for (i in 0..6) {
|
||||||
findViewById<TextView>(resources.getIdentifier("label_$i", "id", packageName)).apply {
|
findViewById<TextView>(resources.getIdentifier("label_$i", "id", packageName)).apply {
|
||||||
val textColor = if (config.highlightWeekends && isWeekend(i, config.isSundayFirst)) {
|
val textColor = if (config.highlightWeekends && isWeekend(i, config.isSundayFirst)) {
|
||||||
mRedTextColor
|
mWeekendsTextColor
|
||||||
} else {
|
} else {
|
||||||
mTextColor
|
mTextColor
|
||||||
}
|
}
|
||||||
|
@@ -218,7 +218,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
} else if (todayCode == dayCode) {
|
} else if (todayCode == dayCode) {
|
||||||
primaryColor
|
primaryColor
|
||||||
} else if (highlightWeekends && isWeekend(i, config.isSundayFirst)) {
|
} else if (highlightWeekends && isWeekend(i, config.isSundayFirst)) {
|
||||||
resources.getColor(R.color.red_text)
|
config.highlightWeekendsColor
|
||||||
} else {
|
} else {
|
||||||
config.textColor
|
config.textColor
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.helpers
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.media.RingtoneManager
|
import android.media.RingtoneManager
|
||||||
|
import com.simplemobiletools.calendar.pro.R
|
||||||
import com.simplemobiletools.calendar.pro.extensions.config
|
import com.simplemobiletools.calendar.pro.extensions.config
|
||||||
import com.simplemobiletools.calendar.pro.extensions.scheduleCalDAVSync
|
import com.simplemobiletools.calendar.pro.extensions.scheduleCalDAVSync
|
||||||
import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle
|
import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle
|
||||||
@@ -228,4 +229,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var highlightWeekends: Boolean
|
var highlightWeekends: Boolean
|
||||||
get() = prefs.getBoolean(HIGHLIGHT_WEEKENDS, false)
|
get() = prefs.getBoolean(HIGHLIGHT_WEEKENDS, false)
|
||||||
set(highlightWeekends) = prefs.edit().putBoolean(HIGHLIGHT_WEEKENDS, highlightWeekends).apply()
|
set(highlightWeekends) = prefs.edit().putBoolean(HIGHLIGHT_WEEKENDS, highlightWeekends).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()
|
||||||
}
|
}
|
||||||
|
@@ -94,6 +94,7 @@ const val EXPORT_PAST_EVENTS = "export_past_events"
|
|||||||
const val WEEKLY_VIEW_ITEM_HEIGHT_MULTIPLIER = "weekly_view_item_height_multiplier"
|
const val WEEKLY_VIEW_ITEM_HEIGHT_MULTIPLIER = "weekly_view_item_height_multiplier"
|
||||||
const val WEEKLY_VIEW_DAYS = "weekly_view_days"
|
const val WEEKLY_VIEW_DAYS = "weekly_view_days"
|
||||||
const val HIGHLIGHT_WEEKENDS = "highlight_weekends"
|
const val HIGHLIGHT_WEEKENDS = "highlight_weekends"
|
||||||
|
const val HIGHLIGHT_WEEKENDS_COLOR = "highlight_weekends_color"
|
||||||
|
|
||||||
// repeat_rule for monthly and yearly repetition
|
// repeat_rule for monthly and yearly repetition
|
||||||
const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition)
|
const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition)
|
||||||
|
@@ -119,9 +119,8 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
|
|||||||
for (i in 0 until len) {
|
for (i in 0 until len) {
|
||||||
val day = days[i]
|
val day = days[i]
|
||||||
|
|
||||||
val redTextColor = context.resources.getColor(R.color.red_text)
|
|
||||||
val dayTextColor = if (context.config.highlightWeekends && day.isWeekend) {
|
val dayTextColor = if (context.config.highlightWeekends && day.isWeekend) {
|
||||||
redTextColor
|
context.config.highlightWeekendsColor
|
||||||
} else {
|
} else {
|
||||||
textColor
|
textColor
|
||||||
}
|
}
|
||||||
@@ -227,12 +226,11 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
|
|||||||
val smallerFontSize = context.getWidgetFontSize()
|
val smallerFontSize = context.getWidgetFontSize()
|
||||||
val packageName = context.packageName
|
val packageName = context.packageName
|
||||||
val letters = context.resources.getStringArray(R.array.week_day_letters)
|
val letters = context.resources.getStringArray(R.array.week_day_letters)
|
||||||
val redTextColor = resources.getColor(R.color.red_text)
|
|
||||||
|
|
||||||
for (i in 0..6) {
|
for (i in 0..6) {
|
||||||
val id = resources.getIdentifier("label_$i", "id", packageName)
|
val id = resources.getIdentifier("label_$i", "id", packageName)
|
||||||
val dayTextColor = if (config.highlightWeekends && isWeekend(i, sundayFirst)) {
|
val dayTextColor = if (context.config.highlightWeekends && isWeekend(i, sundayFirst)) {
|
||||||
redTextColor
|
context.config.highlightWeekendsColor
|
||||||
} else {
|
} else {
|
||||||
textColor
|
textColor
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||||||
private var dayHeight = 0f
|
private var dayHeight = 0f
|
||||||
private var primaryColor = 0
|
private var primaryColor = 0
|
||||||
private var textColor = 0
|
private var textColor = 0
|
||||||
private var redTextColor = 0
|
private var weekendsTextColor = 0
|
||||||
private var weekDaysLetterHeight = 0
|
private var weekDaysLetterHeight = 0
|
||||||
private var eventTitleHeight = 0
|
private var eventTitleHeight = 0
|
||||||
private var currDayOfWeek = 0
|
private var currDayOfWeek = 0
|
||||||
@@ -62,7 +62,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||||||
init {
|
init {
|
||||||
primaryColor = context.getAdjustedPrimaryColor()
|
primaryColor = context.getAdjustedPrimaryColor()
|
||||||
textColor = config.textColor
|
textColor = config.textColor
|
||||||
redTextColor = context.resources.getColor(R.color.red_text)
|
weekendsTextColor = config.highlightWeekendsColor
|
||||||
showWeekNumbers = config.showWeekNumbers
|
showWeekNumbers = config.showWeekNumbers
|
||||||
dimPastEvents = config.dimPastEvents
|
dimPastEvents = config.dimPastEvents
|
||||||
highlightWeekends = config.highlightWeekends
|
highlightWeekends = config.highlightWeekends
|
||||||
@@ -214,7 +214,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||||||
if (i == currDayOfWeek && !isPrintVersion) {
|
if (i == currDayOfWeek && !isPrintVersion) {
|
||||||
weekDayLetterPaint = getColoredPaint(primaryColor)
|
weekDayLetterPaint = getColoredPaint(primaryColor)
|
||||||
} else if (highlightWeekends && isWeekend(i, config.isSundayFirst)) {
|
} else if (highlightWeekends && isWeekend(i, config.isSundayFirst)) {
|
||||||
weekDayLetterPaint = getColoredPaint(redTextColor)
|
weekDayLetterPaint = getColoredPaint(weekendsTextColor)
|
||||||
}
|
}
|
||||||
canvas.drawText(dayLetters[i], xPos, weekDaysLetterHeight * 0.7f, weekDayLetterPaint)
|
canvas.drawText(dayLetters[i], xPos, weekDaysLetterHeight * 0.7f, weekDayLetterPaint)
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||||||
if (startDay.isToday) {
|
if (startDay.isToday) {
|
||||||
paintColor = primaryColor.getContrastColor()
|
paintColor = primaryColor.getContrastColor()
|
||||||
} else if (highlightWeekends && startDay.isWeekend) {
|
} else if (highlightWeekends && startDay.isWeekend) {
|
||||||
paintColor = redTextColor
|
paintColor = weekendsTextColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||||||
private var todayCirclePaint: Paint
|
private var todayCirclePaint: Paint
|
||||||
private var dayWidth = 0f
|
private var dayWidth = 0f
|
||||||
private var textColor = 0
|
private var textColor = 0
|
||||||
private var redTextColor = 0
|
private var weekendsTextColor = 0
|
||||||
private var days = 31
|
private var days = 31
|
||||||
private var isLandscape = false
|
private var isLandscape = false
|
||||||
private var highlightWeekends = false
|
private var highlightWeekends = false
|
||||||
@@ -58,7 +58,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||||||
|
|
||||||
val baseColor = context.config.textColor
|
val baseColor = context.config.textColor
|
||||||
textColor = baseColor.adjustAlpha(MEDIUM_ALPHA)
|
textColor = baseColor.adjustAlpha(MEDIUM_ALPHA)
|
||||||
redTextColor = context.resources.getColor(R.color.red_text).adjustAlpha(MEDIUM_ALPHA)
|
weekendsTextColor = context.config.highlightWeekendsColor.adjustAlpha(MEDIUM_ALPHA)
|
||||||
highlightWeekends = context.config.highlightWeekends
|
highlightWeekends = context.config.highlightWeekends
|
||||||
isSundayFirst = context.config.isSundayFirst
|
isSundayFirst = context.config.isSundayFirst
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||||||
return curPaint
|
return curPaint
|
||||||
} else if (highlightWeekends && isWeekend(weekDay - 1, isSundayFirst)) {
|
} else if (highlightWeekends && isWeekend(weekDay - 1, isSundayFirst)) {
|
||||||
val curPaint = Paint(paint)
|
val curPaint = Paint(paint)
|
||||||
curPaint.color = redTextColor
|
curPaint.color = weekendsTextColor
|
||||||
return curPaint
|
return curPaint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user