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 c31afaf7f..96f803bd4 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 @@ -82,6 +82,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private var mStoredDimPastEvents = true private var mStoredHighlightWeekends = false private var mStoredStartWeekWithCurrentDay = false + private var mStoredHighlightWeekendsColor = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -134,7 +135,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { super.onResume() if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredAdjustedPrimaryColor != getAdjustedPrimaryColor() || mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredHighlightWeekends != config.highlightWeekends - ) { + || mStoredHighlightWeekendsColor != config.highlightWeekendsColor) { updateViewPager() } @@ -262,6 +263,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { mStoredUse24HourFormat = use24HourFormat mStoredDimPastEvents = dimPastEvents mStoredHighlightWeekends = highlightWeekends + mStoredHighlightWeekendsColor = highlightWeekendsColor mStoredMidnightSpan = showMidnightSpanningEventsAtTop mStoredStartWeekWithCurrentDay = startWeekWithCurrentDay } 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 9a860a8a2..4fd086e6c 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 @@ -20,6 +20,7 @@ import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.AlarmSound import com.simplemobiletools.commons.models.RadioItem import kotlinx.android.synthetic.main.activity_settings.* +import kotlinx.android.synthetic.main.dialog_event_type.view.* import org.joda.time.DateTime import java.io.File import java.io.InputStream @@ -51,6 +52,7 @@ class SettingsActivity : SimpleActivity() { setupHourFormat() setupSundayFirst() setupHighlightWeekends() + setupHighlightWeekendsColor() setupDeleteAllEvents() setupReplaceDescription() setupWeekNumbers() @@ -342,9 +344,33 @@ class SettingsActivity : SimpleActivity() { private fun setupHighlightWeekends() { settings_highlight_weekends.isChecked = config.highlightWeekends + settings_highlight_weekends_color_holder.beVisibleIf(config.highlightWeekends) + setupHighlightWeekendColorBackground() settings_highlight_weekends_holder.setOnClickListener { settings_highlight_weekends.toggle() config.highlightWeekends = settings_highlight_weekends.isChecked + settings_highlight_weekends_color_holder.beVisibleIf(config.highlightWeekends) + setupHighlightWeekendColorBackground() + } + } + + private fun setupHighlightWeekendsColor() { + settings_highlight_weekends_color.setFillWithStroke(config.highlightWeekendsColor, config.backgroundColor) + settings_highlight_weekends_color_holder.setOnClickListener { + ColorPickerDialog(this, config.highlightWeekendsColor) { wasPositivePressed, color -> + if (wasPositivePressed) { + config.highlightWeekendsColor = color + settings_highlight_weekends_color.setFillWithStroke(color, config.backgroundColor) + } + } + } + } + + private fun setupHighlightWeekendColorBackground() { + if (settings_highlight_weekends_color_holder.isVisible()) { + settings_highlight_weekends_holder.background = resources.getDrawable(R.drawable.ripple_background, theme) + } else { + settings_highlight_weekends_holder.background = resources.getDrawable(R.drawable.ripple_bottom_corners, theme) } } @@ -813,6 +839,7 @@ class SettingsActivity : SimpleActivity() { put(USE_24_HOUR_FORMAT, config.use24HourFormat) put(SUNDAY_FIRST, config.isSundayFirst) put(HIGHLIGHT_WEEKENDS, config.highlightWeekends) + put(HIGHLIGHT_WEEKENDS_COLOR, config.highlightWeekendsColor) } exportSettings(configItems) @@ -908,6 +935,7 @@ class SettingsActivity : SimpleActivity() { USE_24_HOUR_FORMAT -> config.use24HourFormat = value.toBoolean() SUNDAY_FIRST -> config.isSundayFirst = value.toBoolean() HIGHLIGHT_WEEKENDS -> config.highlightWeekends = value.toBoolean() + HIGHLIGHT_WEEKENDS_COLOR -> config.highlightWeekendsColor = value.toInt() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetMonthlyConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetMonthlyConfigureActivity.kt index 184d20e06..cce83390d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetMonthlyConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetMonthlyConfigureActivity.kt @@ -41,7 +41,8 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { private var mTextColor = 0 private var mWeakTextColor = 0 private var mPrimaryColor = 0 - private var mRedTextColor = 0 + private var mWeekendsTextColor = 0 + private var mHighlightWeekends = false public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false @@ -131,7 +132,8 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { mTextColor = mTextColorWithoutTransparency mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOWER_ALPHA) mPrimaryColor = config.primaryColor - mRedTextColor = resources.getColor(R.color.red_text) + mWeekendsTextColor = config.highlightWeekendsColor + mHighlightWeekends = config.highlightWeekends top_left_arrow.applyColorFilter(mTextColor) top_right_arrow.applyColorFilter(mTextColor) @@ -171,7 +173,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { removeAllViews() val dayTextColor = if (config.highlightWeekends && day.isWeekend) { - mRedTextColor + config.highlightWeekendsColor } else { mTextColor } @@ -205,7 +207,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { for (i in 0..6) { findViewById(resources.getIdentifier("label_$i", "id", packageName)).apply { val textColor = if (config.highlightWeekends && isWeekend(i, config.isSundayFirst)) { - mRedTextColor + mWeekendsTextColor } else { mTextColor } 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 ab5f47bfa..f1a11190f 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 @@ -218,7 +218,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { } else if (todayCode == dayCode) { primaryColor } else if (highlightWeekends && isWeekend(i, config.isSundayFirst)) { - resources.getColor(R.color.red_text) + config.highlightWeekendsColor } else { config.textColor } 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 3c306110f..1f9e90a2b 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 @@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.helpers import android.content.Context import android.media.AudioManager import android.media.RingtoneManager +import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.scheduleCalDAVSync import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle @@ -228,4 +229,8 @@ class Config(context: Context) : BaseConfig(context) { var highlightWeekends: Boolean get() = prefs.getBoolean(HIGHLIGHT_WEEKENDS, false) 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() } 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 314a2ce66..6ed9ca72a 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 @@ -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_DAYS = "weekly_view_days" const val HIGHLIGHT_WEEKENDS = "highlight_weekends" +const val HIGHLIGHT_WEEKENDS_COLOR = "highlight_weekends_color" // repeat_rule for monthly and yearly repetition const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) 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 60c40eeef..c0ba309e7 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 @@ -119,9 +119,8 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { for (i in 0 until len) { val day = days[i] - val redTextColor = context.resources.getColor(R.color.red_text) val dayTextColor = if (context.config.highlightWeekends && day.isWeekend) { - redTextColor + context.config.highlightWeekendsColor } else { textColor } @@ -227,12 +226,11 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { val smallerFontSize = context.getWidgetFontSize() val packageName = context.packageName val letters = context.resources.getStringArray(R.array.week_day_letters) - val redTextColor = resources.getColor(R.color.red_text) for (i in 0..6) { val id = resources.getIdentifier("label_$i", "id", packageName) - val dayTextColor = if (config.highlightWeekends && isWeekend(i, sundayFirst)) { - redTextColor + val dayTextColor = if (context.config.highlightWeekends && isWeekend(i, sundayFirst)) { + context.config.highlightWeekendsColor } else { textColor } 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 b4473cdbf..40d0f7119 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 @@ -37,7 +37,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private var dayHeight = 0f private var primaryColor = 0 private var textColor = 0 - private var redTextColor = 0 + private var weekendsTextColor = 0 private var weekDaysLetterHeight = 0 private var eventTitleHeight = 0 private var currDayOfWeek = 0 @@ -62,7 +62,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con init { primaryColor = context.getAdjustedPrimaryColor() textColor = config.textColor - redTextColor = context.resources.getColor(R.color.red_text) + weekendsTextColor = config.highlightWeekendsColor showWeekNumbers = config.showWeekNumbers dimPastEvents = config.dimPastEvents highlightWeekends = config.highlightWeekends @@ -214,7 +214,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con if (i == currDayOfWeek && !isPrintVersion) { weekDayLetterPaint = getColoredPaint(primaryColor) } else if (highlightWeekends && isWeekend(i, config.isSundayFirst)) { - weekDayLetterPaint = getColoredPaint(redTextColor) + weekDayLetterPaint = getColoredPaint(weekendsTextColor) } 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) { paintColor = primaryColor.getContrastColor() } else if (highlightWeekends && startDay.isWeekend) { - paintColor = redTextColor + paintColor = weekendsTextColor } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt index ee8e37d09..79379099b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt @@ -21,7 +21,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie private var todayCirclePaint: Paint private var dayWidth = 0f private var textColor = 0 - private var redTextColor = 0 + private var weekendsTextColor = 0 private var days = 31 private var isLandscape = false private var highlightWeekends = false @@ -58,7 +58,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie val baseColor = context.config.textColor 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 isSundayFirst = context.config.isSundayFirst @@ -108,7 +108,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie return curPaint } else if (highlightWeekends && isWeekend(weekDay - 1, isSundayFirst)) { val curPaint = Paint(paint) - curPaint.color = redTextColor + curPaint.color = weekendsTextColor return curPaint } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index bc5f49a1b..c440422d4 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -169,6 +169,33 @@ android:text="@string/highlight_weekends" /> + + + + + + + +