From d8a3382eda228ff2ed833c7d1635b1e63d8eb95c Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 16 Jan 2018 21:06:26 +0100 Subject: [PATCH] fix #313, fix some B&W theme related issues --- .../com/simplemobiletools/calendar/extensions/Context.kt | 4 ++-- .../simplemobiletools/calendar/fragments/MonthFragment.kt | 2 -- .../simplemobiletools/calendar/fragments/WeekFragment.kt | 6 ++++-- .../simplemobiletools/calendar/fragments/YearFragment.kt | 3 ++- .../com/simplemobiletools/calendar/views/SmallMonthView.kt | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index 6be1aeb39..316b8926a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -311,8 +311,8 @@ fun Context.addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: Linea linearLayout.addView(this) if (day.isToday) { - val primaryColor = config.primaryColor - setTextColor(config.primaryColor.getContrastColor()) + val primaryColor = getAdjustedPrimaryColor() + setTextColor(primaryColor.getContrastColor()) if (dayLabelHeight == 0) { onGlobalLayout { val height = this@apply.height diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt index 17cdaf443..5f029e0ff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt @@ -30,7 +30,6 @@ import org.joda.time.DateTime class MonthFragment : Fragment(), MonthlyCalendar { private var mTextColor = 0 - private var mPrimaryColor = 0 private var mSundayFirst = false private var mDayCode = "" private var mPackageName = "" @@ -99,7 +98,6 @@ class MonthFragment : Fragment(), MonthlyCalendar { private fun setupButtons() { val baseColor = mConfig.textColor mTextColor = baseColor - mPrimaryColor = mConfig.primaryColor mHolder.top_left_arrow.apply { applyColorFilter(mTextColor) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt index d1fa45543..62dcc4bb6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt @@ -23,6 +23,7 @@ import com.simplemobiletools.calendar.models.Event import com.simplemobiletools.calendar.views.MyScrollView import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.beGone +import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import com.simplemobiletools.commons.extensions.getContrastColor import kotlinx.android.synthetic.main.fragment_week.* 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() minScrollY = mRowHeight * context!!.config.startWeeklyAt mWeekTimestamp = arguments!!.getInt(WEEK_START_TIMESTAMP) - primaryColor = context!!.config.primaryColor + primaryColor = context!!.getAdjustedPrimaryColor() mRes = resources allDayRows.add(HashSet()) @@ -189,12 +190,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { val rowHeight = resources.getDimension(R.dimen.weekly_view_row_height) 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) background = ColorDrawable(primaryColor) layoutParams.width = view.width layoutParams.height = rowHeight.toInt() y = hour * rowHeight + applyColorFilter(primaryColor.getContrastColor()) setOnClickListener { val timestamp = mWeekTimestamp + index * DAY_SECONDS + hour * 60 * 60 diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt index 6231faed7..3d6d6df4e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.calendar.interfaces.NavigationListener import com.simplemobiletools.calendar.interfaces.YearlyCalendar import com.simplemobiletools.calendar.models.DayYearly import com.simplemobiletools.calendar.views.SmallMonthView +import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import com.simplemobiletools.commons.extensions.updateTextColors import kotlinx.android.synthetic.main.fragment_year.view.* import org.joda.time.DateTime @@ -80,7 +81,7 @@ class YearFragment : Fragment(), YearlyCalendar { val now = DateTime() if (now.year == mYear) { val monthLabel = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}_label", "id", context!!.packageName)) - monthLabel.setTextColor(context!!.config.primaryColor) + monthLabel.setTextColor(context!!.getAdjustedPrimaryColor()) val monthView = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}", "id", context!!.packageName)) monthView.todaysId = now.dayOfMonth diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt index 51467e1ac..9ba798b32 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt @@ -11,6 +11,7 @@ import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.helpers.MEDIUM_ALPHA import com.simplemobiletools.calendar.models.DayYearly import com.simplemobiletools.commons.extensions.adjustAlpha +import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import java.util.* 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.color = context.config.primaryColor.adjustAlpha(MEDIUM_ALPHA) + todayCirclePaint.color = context.getAdjustedPrimaryColor().adjustAlpha(MEDIUM_ALPHA) isLandscape = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE }