adding a helper function in MonthView
This commit is contained in:
parent
f2bc8ba5c8
commit
baa1c44bcd
|
@ -268,10 +268,10 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupWeekNumbers() {
|
||||
settings_week_numbers.isChecked = config.displayWeekNumbers
|
||||
settings_week_numbers.isChecked = config.showWeekNumbers
|
||||
settings_week_numbers_holder.setOnClickListener {
|
||||
settings_week_numbers.toggle()
|
||||
config.displayWeekNumbers = settings_week_numbers.isChecked
|
||||
config.showWeekNumbers = settings_week_numbers.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
fun newInstance(context: Context) = Config(context)
|
||||
}
|
||||
|
||||
var displayWeekNumbers: Boolean
|
||||
var showWeekNumbers: Boolean
|
||||
get() = prefs.getBoolean(WEEK_NUMBERS, false)
|
||||
set(displayWeekNumbers) = prefs.edit().putBoolean(WEEK_NUMBERS, displayWeekNumbers).apply()
|
||||
set(showWeekNumbers) = prefs.edit().putBoolean(WEEK_NUMBERS, showWeekNumbers).apply()
|
||||
|
||||
var startWeeklyAt: Int
|
||||
get() = prefs.getInt(START_WEEKLY_AT, 7)
|
||||
|
|
|
@ -82,7 +82,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
|
|||
}
|
||||
|
||||
private fun updateDays(context: Context, views: RemoteViews, days: List<DayMonthly>) {
|
||||
val displayWeekNumbers = context.config.displayWeekNumbers
|
||||
val displayWeekNumbers = context.config.showWeekNumbers
|
||||
val textColor = context.config.widgetTextColor
|
||||
val smallerFontSize = context.config.getFontSize() - 3f
|
||||
val res = context.resources
|
||||
|
|
|
@ -42,6 +42,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
private var smallPadding = 0
|
||||
private var availableHeightForEvents = 0
|
||||
private var maxEventsPerDay = 0
|
||||
private var showWeekNumbers = false
|
||||
private var allEvents = ArrayList<MonthViewEvent>()
|
||||
private var bgRectF = RectF()
|
||||
private var dayLetters = ArrayList<String>()
|
||||
|
@ -54,6 +55,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
init {
|
||||
primaryColor = context.getAdjustedPrimaryColor()
|
||||
textColor = context.config.textColor
|
||||
showWeekNumbers = context.config.showWeekNumbers
|
||||
weakTextColor = textColor.adjustAlpha(LOW_ALPHA)
|
||||
|
||||
smallPadding = resources.displayMetrics.density.toInt()
|
||||
|
@ -82,6 +84,12 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
days = newDays
|
||||
initWeekDayLetters()
|
||||
setupCurrentDayOfWeekIndex()
|
||||
showWeekNumbers = context.config.showWeekNumbers
|
||||
groupAllEvents()
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private fun groupAllEvents() {
|
||||
days.forEach {
|
||||
val day = it
|
||||
day.dayEvents.forEach {
|
||||
|
@ -99,7 +107,6 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
}
|
||||
|
||||
allEvents = allEvents.sortedWith(compareBy({ -it.daysCnt }, { !it.isAllDay }, { it.startTS }, { it.startDayIndex }, { it.title })).toMutableList() as ArrayList<MonthViewEvent>
|
||||
invalidate()
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
|
|
Loading…
Reference in New Issue