fix #313, fix some B&W theme related issues

This commit is contained in:
tibbi 2018-01-16 21:06:26 +01:00
parent 9a670a843a
commit d8a3382eda
5 changed files with 10 additions and 8 deletions

View File

@ -311,8 +311,8 @@ fun Context.addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: Linea
linearLayout.addView(this) linearLayout.addView(this)
if (day.isToday) { if (day.isToday) {
val primaryColor = config.primaryColor val primaryColor = getAdjustedPrimaryColor()
setTextColor(config.primaryColor.getContrastColor()) setTextColor(primaryColor.getContrastColor())
if (dayLabelHeight == 0) { if (dayLabelHeight == 0) {
onGlobalLayout { onGlobalLayout {
val height = this@apply.height val height = this@apply.height

View File

@ -30,7 +30,6 @@ import org.joda.time.DateTime
class MonthFragment : Fragment(), MonthlyCalendar { class MonthFragment : Fragment(), MonthlyCalendar {
private var mTextColor = 0 private var mTextColor = 0
private var mPrimaryColor = 0
private var mSundayFirst = false private var mSundayFirst = false
private var mDayCode = "" private var mDayCode = ""
private var mPackageName = "" private var mPackageName = ""
@ -99,7 +98,6 @@ class MonthFragment : Fragment(), MonthlyCalendar {
private fun setupButtons() { private fun setupButtons() {
val baseColor = mConfig.textColor val baseColor = mConfig.textColor
mTextColor = baseColor mTextColor = baseColor
mPrimaryColor = mConfig.primaryColor
mHolder.top_left_arrow.apply { mHolder.top_left_arrow.apply {
applyColorFilter(mTextColor) applyColorFilter(mTextColor)

View File

@ -23,6 +23,7 @@ import com.simplemobiletools.calendar.models.Event
import com.simplemobiletools.calendar.views.MyScrollView import com.simplemobiletools.calendar.views.MyScrollView
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beGone import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getContrastColor import com.simplemobiletools.commons.extensions.getContrastColor
import kotlinx.android.synthetic.main.fragment_week.* import kotlinx.android.synthetic.main.fragment_week.*
import kotlinx.android.synthetic.main.fragment_week.view.* import kotlinx.android.synthetic.main.fragment_week.view.*
@ -62,7 +63,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
mRowHeight = (context!!.resources.getDimension(R.dimen.weekly_view_row_height)).toInt() mRowHeight = (context!!.resources.getDimension(R.dimen.weekly_view_row_height)).toInt()
minScrollY = mRowHeight * context!!.config.startWeeklyAt minScrollY = mRowHeight * context!!.config.startWeeklyAt
mWeekTimestamp = arguments!!.getInt(WEEK_START_TIMESTAMP) mWeekTimestamp = arguments!!.getInt(WEEK_START_TIMESTAMP)
primaryColor = context!!.config.primaryColor primaryColor = context!!.getAdjustedPrimaryColor()
mRes = resources mRes = resources
allDayRows.add(HashSet()) allDayRows.add(HashSet())
@ -189,12 +190,13 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val rowHeight = resources.getDimension(R.dimen.weekly_view_row_height) val rowHeight = resources.getDimension(R.dimen.weekly_view_row_height)
val hour = (event.y / rowHeight).toInt() val hour = (event.y / rowHeight).toInt()
selectedGrid = (inflater.inflate(R.layout.week_grid_item, null, false) as View).apply { selectedGrid = (inflater.inflate(R.layout.week_grid_item, null, false) as ImageView).apply {
view.addView(this) view.addView(this)
background = ColorDrawable(primaryColor) background = ColorDrawable(primaryColor)
layoutParams.width = view.width layoutParams.width = view.width
layoutParams.height = rowHeight.toInt() layoutParams.height = rowHeight.toInt()
y = hour * rowHeight y = hour * rowHeight
applyColorFilter(primaryColor.getContrastColor())
setOnClickListener { setOnClickListener {
val timestamp = mWeekTimestamp + index * DAY_SECONDS + hour * 60 * 60 val timestamp = mWeekTimestamp + index * DAY_SECONDS + hour * 60 * 60

View File

@ -16,6 +16,7 @@ import com.simplemobiletools.calendar.interfaces.NavigationListener
import com.simplemobiletools.calendar.interfaces.YearlyCalendar import com.simplemobiletools.calendar.interfaces.YearlyCalendar
import com.simplemobiletools.calendar.models.DayYearly import com.simplemobiletools.calendar.models.DayYearly
import com.simplemobiletools.calendar.views.SmallMonthView import com.simplemobiletools.calendar.views.SmallMonthView
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.updateTextColors
import kotlinx.android.synthetic.main.fragment_year.view.* import kotlinx.android.synthetic.main.fragment_year.view.*
import org.joda.time.DateTime import org.joda.time.DateTime
@ -80,7 +81,7 @@ class YearFragment : Fragment(), YearlyCalendar {
val now = DateTime() val now = DateTime()
if (now.year == mYear) { if (now.year == mYear) {
val monthLabel = mView.findViewById<TextView>(res.getIdentifier("month_${now.monthOfYear}_label", "id", context!!.packageName)) val monthLabel = mView.findViewById<TextView>(res.getIdentifier("month_${now.monthOfYear}_label", "id", context!!.packageName))
monthLabel.setTextColor(context!!.config.primaryColor) monthLabel.setTextColor(context!!.getAdjustedPrimaryColor())
val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_${now.monthOfYear}", "id", context!!.packageName)) val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_${now.monthOfYear}", "id", context!!.packageName))
monthView.todaysId = now.dayOfMonth monthView.todaysId = now.dayOfMonth

View File

@ -11,6 +11,7 @@ import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.helpers.MEDIUM_ALPHA import com.simplemobiletools.calendar.helpers.MEDIUM_ALPHA
import com.simplemobiletools.calendar.models.DayYearly import com.simplemobiletools.calendar.models.DayYearly
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import java.util.* import java.util.*
class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) { class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) {
@ -59,7 +60,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
} }
todayCirclePaint = Paint(paint) todayCirclePaint = Paint(paint)
todayCirclePaint.color = context.config.primaryColor.adjustAlpha(MEDIUM_ALPHA) todayCirclePaint.color = context.getAdjustedPrimaryColor().adjustAlpha(MEDIUM_ALPHA)
isLandscape = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE isLandscape = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
} }