use a bit higher alpha for dimmed event titles

This commit is contained in:
tibbi 2021-03-10 16:55:40 +01:00
parent db4d27b0db
commit 89ecc74042
11 changed files with 28 additions and 22 deletions

View File

@ -9,12 +9,12 @@ import android.widget.SeekBar
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.LOW_ALPHA
import com.simplemobiletools.calendar.pro.helpers.MyWidgetDateProvider import com.simplemobiletools.calendar.pro.helpers.MyWidgetDateProvider
import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.setFillWithStroke import com.simplemobiletools.commons.extensions.setFillWithStroke
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import kotlinx.android.synthetic.main.widget_config_date.* import kotlinx.android.synthetic.main.widget_config_date.*
class WidgetDateConfigureActivity : SimpleActivity() { class WidgetDateConfigureActivity : SimpleActivity() {
@ -112,7 +112,7 @@ class WidgetDateConfigureActivity : SimpleActivity() {
private fun updateColors() { private fun updateColors() {
mTextColor = mTextColorWithoutTransparency mTextColor = mTextColorWithoutTransparency
mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOW_ALPHA) mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOWER_ALPHA)
mPrimaryColor = config.primaryColor mPrimaryColor = config.primaryColor
config_text_color.setFillWithStroke(mTextColor, Color.BLACK) config_text_color.setFillWithStroke(mTextColor, Color.BLACK)

View File

@ -13,7 +13,6 @@ import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.addDayEvents import com.simplemobiletools.calendar.pro.extensions.addDayEvents
import com.simplemobiletools.calendar.pro.extensions.addDayNumber import com.simplemobiletools.calendar.pro.extensions.addDayNumber
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.LOW_ALPHA
import com.simplemobiletools.calendar.pro.helpers.MonthlyCalendarImpl import com.simplemobiletools.calendar.pro.helpers.MonthlyCalendarImpl
import com.simplemobiletools.calendar.pro.helpers.MyWidgetMonthlyProvider import com.simplemobiletools.calendar.pro.helpers.MyWidgetMonthlyProvider
import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
@ -23,6 +22,7 @@ import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beVisible import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.setFillWithStroke import com.simplemobiletools.commons.extensions.setFillWithStroke
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import kotlinx.android.synthetic.main.first_row.* import kotlinx.android.synthetic.main.first_row.*
import kotlinx.android.synthetic.main.top_navigation.* import kotlinx.android.synthetic.main.top_navigation.*
import kotlinx.android.synthetic.main.widget_config_monthly.* import kotlinx.android.synthetic.main.widget_config_monthly.*
@ -127,7 +127,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private fun updateColors() { private fun updateColors() {
mTextColor = mTextColorWithoutTransparency mTextColor = mTextColorWithoutTransparency
mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOW_ALPHA) mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOWER_ALPHA)
mPrimaryColor = config.primaryColor mPrimaryColor = config.primaryColor
top_left_arrow.applyColorFilter(mTextColor) top_left_arrow.applyColorFilter(mTextColor)

View File

@ -13,13 +13,13 @@ import com.simplemobiletools.calendar.pro.extensions.shareEvents
import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.ITEM_EVENT import com.simplemobiletools.calendar.pro.helpers.ITEM_EVENT
import com.simplemobiletools.calendar.pro.helpers.ITEM_EVENT_SIMPLE import com.simplemobiletools.calendar.pro.helpers.ITEM_EVENT_SIMPLE
import com.simplemobiletools.calendar.pro.helpers.LOW_ALPHA
import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beInvisible import com.simplemobiletools.commons.extensions.beInvisible
import com.simplemobiletools.commons.extensions.beInvisibleIf import com.simplemobiletools.commons.extensions.beInvisibleIf
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.event_item_day_view.view.* import kotlinx.android.synthetic.main.event_item_day_view.view.*
@ -136,7 +136,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
var newTextColor = textColor var newTextColor = textColor
if (dimPastEvents && event.isPastEvent && !isPrintVersion) { if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
newTextColor = newTextColor.adjustAlpha(LOW_ALPHA) newTextColor = newTextColor.adjustAlpha(LOWER_ALPHA)
} }
event_item_start.setTextColor(newTextColor) event_item_start.setTextColor(newTextColor)

View File

@ -20,6 +20,7 @@ import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beInvisible import com.simplemobiletools.commons.extensions.beInvisible
import com.simplemobiletools.commons.extensions.beInvisibleIf import com.simplemobiletools.commons.extensions.beInvisibleIf
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
@ -177,8 +178,8 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
} }
if (tryDimPastEvents && dimPastEvents && listEvent.isPastEvent && !isPrintVersion) { if (tryDimPastEvents && dimPastEvents && listEvent.isPastEvent && !isPrintVersion) {
startTextColor = startTextColor.adjustAlpha(LOW_ALPHA) startTextColor = startTextColor.adjustAlpha(LOWER_ALPHA)
endTextColor = endTextColor.adjustAlpha(LOW_ALPHA) endTextColor = endTextColor.adjustAlpha(LOWER_ALPHA)
} }
} else if (listEvent.startTS <= now && listEvent.endTS >= now && !isPrintVersion) { } else if (listEvent.startTS <= now && listEvent.endTS >= now && !isPrintVersion) {
startTextColor = adjustedPrimaryColor startTextColor = adjustedPrimaryColor
@ -197,7 +198,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
setCompoundDrawablesWithIntrinsicBounds(null, if (position == 0) null else topDivider, null, null) setCompoundDrawablesWithIntrinsicBounds(null, if (position == 0) null else topDivider, null, null)
var color = if (listSection.isToday && !isPrintVersion) adjustedPrimaryColor else textColor var color = if (listSection.isToday && !isPrintVersion) adjustedPrimaryColor else textColor
if (dimPastEvents && listSection.isPastSection && !isPrintVersion) { if (dimPastEvents && listSection.isPastSection && !isPrintVersion) {
color = color.adjustAlpha(LOW_ALPHA) color = color.adjustAlpha(LOWER_ALPHA)
} }
setTextColor(color) setTextColor(color)
} }

View File

@ -22,6 +22,7 @@ import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.setBackgroundColor import com.simplemobiletools.commons.extensions.setBackgroundColor
import com.simplemobiletools.commons.extensions.setText import com.simplemobiletools.commons.extensions.setText
import com.simplemobiletools.commons.extensions.setTextSize import com.simplemobiletools.commons.extensions.setTextSize
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import org.joda.time.DateTime import org.joda.time.DateTime
import java.util.* import java.util.*
@ -32,7 +33,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
private val allDayString = context.resources.getString(R.string.all_day) private val allDayString = context.resources.getString(R.string.all_day)
private var events = ArrayList<ListItem>() private var events = ArrayList<ListItem>()
private var textColor = context.config.widgetTextColor private var textColor = context.config.widgetTextColor
private var weakTextColor = textColor.adjustAlpha(LOW_ALPHA) private var weakTextColor = textColor.adjustAlpha(LOWER_ALPHA)
private val replaceDescription = context.config.replaceDescription private val replaceDescription = context.config.replaceDescription
private val dimPastEvents = context.config.dimPastEvents private val dimPastEvents = context.config.dimPastEvents
private var mediumFontSize = context.getWidgetFontSize() private var mediumFontSize = context.getWidgetFontSize()
@ -157,7 +158,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
override fun onDataSetChanged() { override fun onDataSetChanged() {
textColor = context.config.widgetTextColor textColor = context.config.widgetTextColor
weakTextColor = textColor.adjustAlpha(LOW_ALPHA) weakTextColor = textColor.adjustAlpha(LOWER_ALPHA)
mediumFontSize = context.getWidgetFontSize() mediumFontSize = context.getWidgetFontSize()
val fromTS = DateTime().seconds() - context.config.displayPastEvents * 60 val fromTS = DateTime().seconds() - context.config.displayPastEvents * 60
val toTS = DateTime().plusYears(1).seconds() val toTS = DateTime().plusYears(1).seconds()

View File

@ -389,7 +389,7 @@ fun Context.scheduleCalDAVSync(activate: Boolean) {
fun Context.addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: LinearLayout, dayLabelHeight: Int, callback: (Int) -> Unit) { fun Context.addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: LinearLayout, dayLabelHeight: Int, callback: (Int) -> Unit) {
var textColor = rawTextColor var textColor = rawTextColor
if (!day.isThisMonth) if (!day.isThisMonth)
textColor = textColor.adjustAlpha(LOW_ALPHA) textColor = textColor.adjustAlpha(LOWER_ALPHA)
(View.inflate(applicationContext, R.layout.day_monthly_number_view, null) as TextView).apply { (View.inflate(applicationContext, R.layout.day_monthly_number_view, null) as TextView).apply {
setTextColor(textColor) setTextColor(textColor)

View File

@ -25,6 +25,8 @@ import com.simplemobiletools.calendar.pro.models.EventWeeklyView
import com.simplemobiletools.calendar.pro.views.MyScrollView import com.simplemobiletools.calendar.pro.views.MyScrollView
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.DAY_SECONDS import com.simplemobiletools.commons.helpers.DAY_SECONDS
import com.simplemobiletools.commons.helpers.HIGHER_ALPHA
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.WEEK_SECONDS import com.simplemobiletools.commons.helpers.WEEK_SECONDS
import com.simplemobiletools.commons.views.MyTextView import com.simplemobiletools.commons.views.MyTextView
import kotlinx.android.synthetic.main.fragment_week.* import kotlinx.android.synthetic.main.fragment_week.*
@ -451,8 +453,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
var backgroundColor = eventTypeColors.get(event.eventType, primaryColor) var backgroundColor = eventTypeColors.get(event.eventType, primaryColor)
var textColor = backgroundColor.getContrastColor() var textColor = backgroundColor.getContrastColor()
if (dimPastEvents && event.isPastEvent && !isPrintVersion) { if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
backgroundColor = backgroundColor.adjustAlpha(LOW_ALPHA) backgroundColor = backgroundColor.adjustAlpha(LOWER_ALPHA)
textColor = textColor.adjustAlpha(LOW_ALPHA) textColor = textColor.adjustAlpha(HIGHER_ALPHA)
} }
background = ColorDrawable(backgroundColor) background = ColorDrawable(backgroundColor)
@ -558,8 +560,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
var backgroundColor = eventTypeColors.get(event.eventType, primaryColor) var backgroundColor = eventTypeColors.get(event.eventType, primaryColor)
var textColor = backgroundColor.getContrastColor() var textColor = backgroundColor.getContrastColor()
if (dimPastEvents && event.isPastEvent && !isPrintVersion) { if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
backgroundColor = backgroundColor.adjustAlpha(LOW_ALPHA) backgroundColor = backgroundColor.adjustAlpha(LOWER_ALPHA)
textColor = textColor.adjustAlpha(LOW_ALPHA) textColor = textColor.adjustAlpha(HIGHER_ALPHA)
} }
background = ColorDrawable(backgroundColor) background = ColorDrawable(backgroundColor)

View File

@ -1,7 +1,5 @@
package com.simplemobiletools.calendar.pro.helpers package com.simplemobiletools.calendar.pro.helpers
const val LOW_ALPHA = .3f
const val MEDIUM_ALPHA = .6f
const val STORED_LOCALLY_ONLY = 0 const val STORED_LOCALLY_ONLY = 0
const val ROW_COUNT = 6 const val ROW_COUNT = 6
const val COLUMN_COUNT = 7 const val COLUMN_COUNT = 7

View File

@ -18,6 +18,7 @@ import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
import com.simplemobiletools.calendar.pro.models.DayMonthly import com.simplemobiletools.calendar.pro.models.DayMonthly
import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import org.joda.time.DateTime import org.joda.time.DateTime
class MyWidgetMonthlyProvider : AppWidgetProvider() { class MyWidgetMonthlyProvider : AppWidgetProvider() {

View File

@ -18,6 +18,9 @@ import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getContrastColor import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.commons.extensions.moveLastItemToFront import com.simplemobiletools.commons.extensions.moveLastItemToFront
import com.simplemobiletools.commons.helpers.HIGHER_ALPHA
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.Days import org.joda.time.Days
@ -75,7 +78,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
} }
gridPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { gridPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = textColor.adjustAlpha(LOW_ALPHA) color = textColor.adjustAlpha(LOWER_ALPHA)
} }
circleStrokePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { circleStrokePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
@ -322,7 +325,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
private fun getEventTitlePaint(event: MonthViewEvent, startDay: DayMonthly, endDay: DayMonthly): Paint { private fun getEventTitlePaint(event: MonthViewEvent, startDay: DayMonthly, endDay: DayMonthly): Paint {
var paintColor = event.color.getContrastColor() var paintColor = event.color.getContrastColor()
if ((!startDay.isThisMonth && !endDay.isThisMonth) || (dimPastEvents && event.isPastEvent && !isPrintVersion)) { if ((!startDay.isThisMonth && !endDay.isThisMonth) || (dimPastEvents && event.isPastEvent && !isPrintVersion)) {
paintColor = paintColor.adjustAlpha(MEDIUM_ALPHA) paintColor = paintColor.adjustAlpha(HIGHER_ALPHA)
} }
val curPaint = Paint(eventTitlePaint) val curPaint = Paint(eventTitlePaint)
@ -400,7 +403,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
} }
textPaint.color = textColor textPaint.color = textColor
gridPaint.color = textColor.adjustAlpha(LOW_ALPHA) gridPaint.color = textColor.adjustAlpha(LOWER_ALPHA)
invalidate() invalidate()
initWeekDayLetters() initWeekDayLetters()
} }

View File

@ -8,11 +8,11 @@ import android.util.AttributeSet
import android.view.View import android.view.View
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.MEDIUM_ALPHA
import com.simplemobiletools.calendar.pro.helpers.isWeekend import com.simplemobiletools.calendar.pro.helpers.isWeekend
import com.simplemobiletools.calendar.pro.models.DayYearly import com.simplemobiletools.calendar.pro.models.DayYearly
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import java.util.* import java.util.*
// used for displaying months at Yearly view // used for displaying months at Yearly view