From 1bda60498c765c0470068c29e6422c459315183d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 27 Feb 2022 16:25:45 +0100 Subject: [PATCH] show tasks at the monthly widget --- .../pro/helpers/MyWidgetMonthlyProvider.kt | 12 +++++- .../layout/day_monthly_event_view_widget.xml | 38 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/layout/day_monthly_event_view_widget.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt index c0ba309e7..7a017c069 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt @@ -7,6 +7,7 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.res.Resources +import android.graphics.Paint import android.view.View import android.widget.RemoteViews import com.simplemobiletools.calendar.pro.R @@ -144,11 +145,18 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { backgroundColor = backgroundColor.adjustAlpha(MEDIUM_ALPHA) } - val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_event_view).apply { + val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_event_view_widget).apply { setText(R.id.day_monthly_event_id, it.title.replace(" ", "\u00A0")) setTextColor(R.id.day_monthly_event_id, eventTextColor) setTextSize(R.id.day_monthly_event_id, smallerFontSize - 3f) - setBackgroundColor(R.id.day_monthly_event_id, backgroundColor) + setBackgroundColor(R.id.day_monthly_event_holder, backgroundColor) + setVisibleIf(R.id.day_monthly_task_image, it.isTask()) + + if (it.isTaskCompleted()) { + setInt(R.id.day_monthly_event_id, "setPaintFlags", Paint.ANTI_ALIAS_FLAG or Paint.STRIKE_THRU_TEXT_FLAG) + } else { + setInt(R.id.day_monthly_event_id, "setPaintFlags", Paint.ANTI_ALIAS_FLAG) + } } views.addView(id, newRemoteView) } diff --git a/app/src/main/res/layout/day_monthly_event_view_widget.xml b/app/src/main/res/layout/day_monthly_event_view_widget.xml new file mode 100644 index 000000000..c64987a18 --- /dev/null +++ b/app/src/main/res/layout/day_monthly_event_view_widget.xml @@ -0,0 +1,38 @@ + + + + + + + + +