Merge pull request #1543 from ikazuhiro/customize-weekends-color
Customize weekends highlight color
This commit is contained in:
commit
ce4a5eccb8
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<TextView>(resources.getIdentifier("label_$i", "id", packageName)).apply {
|
||||
val textColor = if (config.highlightWeekends && isWeekend(i, config.isSundayFirst)) {
|
||||
mRedTextColor
|
||||
mWeekendsTextColor
|
||||
} else {
|
||||
mTextColor
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,33 @@
|
|||
android:text="@string/highlight_weekends" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_highlight_weekends_color_holder"
|
||||
style="@style/SettingsHolderTextViewStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple_bottom_corners">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_highlight_weekends_color_text_label"
|
||||
style="@style/SettingsTextLabelStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/settings_highlight_weekends_color"
|
||||
android:layout_alignBottom="@+id/settings_highlight_weekends_color"
|
||||
android:layout_toStartOf="@+id/settings_highlight_weekends_color"
|
||||
android:gravity="center_vertical|start"
|
||||
android:text="@string/highlight_weekends_color" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/settings_highlight_weekends_color"
|
||||
android:layout_width="@dimen/color_sample_size"
|
||||
android:layout_height="@dimen/color_sample_size"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:clickable="false" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in New Issue