Skip to content

Commit

Permalink
Persistent sunday highlight through appearances
Browse files Browse the repository at this point in the history
  • Loading branch information
m-i-n-a-r committed Mar 10, 2023
1 parent a7afeaf commit 3e58b3d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion tasticalendar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ publishing {
release(MavenPublication) {
groupId = 'com.github.m-i-n-a-r'
artifactId = 'tasticalendar'
version = '1.3.4'
version = '1.3.5'

afterEvaluate {
from components.release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class TastiCalendarMonth(context: Context, attrs: AttributeSet) : LinearLayout(c
private var snackBarsPrefix: Int? = null
private var snackBarsBaseView: View? = null
private var snackBarsDuration: Int = 3000
private var sundayIndex = 6

init {
context.theme.obtainStyledAttributes(
Expand Down Expand Up @@ -367,7 +368,6 @@ class TastiCalendarMonth(context: Context, attrs: AttributeSet) : LinearLayout(c
val sunday = DayOfWeek.SUNDAY
val locale = Locale.getDefault()
if (!hideWeekDays) {
var sundayIndex = 6
if (!sundayFirst) {
weekDaysList[0].text = monday.getDisplayName(TextStyle.NARROW, locale)
weekDaysList[1].text = tuesday.getDisplayName(TextStyle.NARROW, locale)
Expand All @@ -386,45 +386,6 @@ class TastiCalendarMonth(context: Context, attrs: AttributeSet) : LinearLayout(c
weekDaysList[5].text = friday.getDisplayName(TextStyle.NARROW, locale)
weekDaysList[6].text = saturday.getDisplayName(TextStyle.NARROW, locale)
}
// Set the highlighting style for sunday
when (sundayAppearance) {
0 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.NORMAL)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorOnSurfaceVariant,
context
)
)
}
1 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.BOLD)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorOnSurfaceVariant,
context
)
)
}
2 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.NORMAL)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorTertiary,
context
)
)
}
3 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.BOLD)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorTertiary,
context
)
)
}
}
} else {
weekDaysList[0].visibility = View.GONE
weekDaysList[1].visibility = View.GONE
Expand Down Expand Up @@ -781,5 +742,45 @@ class TastiCalendarMonth(context: Context, attrs: AttributeSet) : LinearLayout(c
)
)
for (weekDay in weekDaysList) weekDay.alpha = .85f

// Set the highlighting style for sunday
when (sundayAppearance) {
0 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.NORMAL)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorOnSurfaceVariant,
context
)
)
}
1 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.BOLD)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorOnSurfaceVariant,
context
)
)
}
2 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.NORMAL)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorTertiary,
context
)
)
}
3 -> {
weekDaysList[sundayIndex].setTypeface(null, Typeface.BOLD)
weekDaysList[sundayIndex].setTextColor(
getThemeColor(
com.google.android.material.R.attr.colorTertiary,
context
)
)
}
}
}
}

0 comments on commit 3e58b3d

Please sign in to comment.