mark current day at the monthly view properly
This commit is contained in:
parent
eca236119e
commit
869102cdd9
2 changed files with 30 additions and 42 deletions
|
@ -6,12 +6,15 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.addDayEvents
|
||||
import com.simplemobiletools.calendar.pro.extensions.addDayNumber
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.helpers.MonthlyCalendarImpl
|
||||
import com.simplemobiletools.calendar.pro.helpers.MyWidgetMonthlyProvider
|
||||
|
@ -21,6 +24,7 @@ import com.simplemobiletools.calendar.pro.models.DayMonthly
|
|||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
|
||||
import kotlinx.android.synthetic.main.day_monthly_number_view.view.*
|
||||
import kotlinx.android.synthetic.main.first_row.*
|
||||
import kotlinx.android.synthetic.main.top_navigation.*
|
||||
import kotlinx.android.synthetic.main.widget_config_monthly.*
|
||||
|
@ -175,12 +179,36 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
|
|||
mTextColor
|
||||
}
|
||||
|
||||
context.addDayNumber(dayTextColor, day, this, dayLabelHeight) { dayLabelHeight = it }
|
||||
addDayNumber(dayTextColor, day, this, dayLabelHeight) { dayLabelHeight = it }
|
||||
context.addDayEvents(day, this, resources, dividerMargin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: LinearLayout, dayLabelHeight: Int, callback: (Int) -> Unit) {
|
||||
var textColor = rawTextColor
|
||||
if (!day.isThisMonth) {
|
||||
textColor = textColor.adjustAlpha(LOWER_ALPHA)
|
||||
}
|
||||
|
||||
(View.inflate(applicationContext, R.layout.day_monthly_number_view, null) as RelativeLayout).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
linearLayout.addView(this)
|
||||
|
||||
day_monthly_number_background.beVisibleIf(day.isToday)
|
||||
day_monthly_number_id.apply {
|
||||
setTextColor(textColor)
|
||||
text = day.value.toString()
|
||||
gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
||||
}
|
||||
|
||||
if (day.isToday) {
|
||||
day_monthly_number_background.setColorFilter(getProperPrimaryColor())
|
||||
day_monthly_number_id.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
mBgAlpha = progress.toFloat() / 100.toFloat()
|
||||
|
|
|
@ -15,12 +15,9 @@ import android.media.AudioAttributes
|
|||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.CalendarContract
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.app.AlarmManagerCompat
|
||||
|
@ -43,7 +40,6 @@ import com.simplemobiletools.calendar.pro.services.SnoozeService
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import kotlinx.android.synthetic.main.day_monthly_event_view.view.*
|
||||
import kotlinx.android.synthetic.main.day_monthly_number_view.view.*
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import org.joda.time.LocalDate
|
||||
|
@ -439,42 +435,6 @@ fun Context.scheduleCalDAVSync(activate: Boolean) {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: LinearLayout, dayLabelHeight: Int, callback: (Int) -> Unit) {
|
||||
var textColor = rawTextColor
|
||||
if (!day.isThisMonth)
|
||||
textColor = textColor.adjustAlpha(LOWER_ALPHA)
|
||||
|
||||
(View.inflate(applicationContext, R.layout.day_monthly_number_view, null) as RelativeLayout).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
linearLayout.addView(this)
|
||||
|
||||
day_monthly_number_id.apply {
|
||||
setTextColor(textColor)
|
||||
text = day.value.toString()
|
||||
gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
||||
|
||||
if (day.isToday) {
|
||||
val primaryColor = getProperPrimaryColor()
|
||||
setTextColor(primaryColor.getContrastColor())
|
||||
if (dayLabelHeight == 0) {
|
||||
onGlobalLayout {
|
||||
val height = this@apply.height
|
||||
if (height > 0) {
|
||||
callback(height)
|
||||
addTodaysBackground(this, resources, height, primaryColor)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addTodaysBackground(this, resources, dayLabelHeight, primaryColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addTodaysBackground(textView: TextView, res: Resources, dayLabelHeight: Int, primaryColor: Int) =
|
||||
textView.addResizedBackgroundDrawable(res, dayLabelHeight, primaryColor, R.drawable.ic_circle_vector)
|
||||
|
||||
fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resources, dividerMargin: Int) {
|
||||
val eventLayoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
|
||||
|
|
Loading…
Reference in a new issue