Skip to content

Commit 9862f95

Browse files
committed
show task icon at the event list too
1 parent 1bda604 commit 9862f95

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.pro.adapters
22

33
import android.content.Context
44
import android.content.Intent
5+
import android.graphics.Paint
56
import android.widget.RemoteViews
67
import android.widget.RemoteViewsService
78
import com.simplemobiletools.calendar.pro.R
@@ -29,6 +30,8 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
2930
private var replaceDescription = context.config.replaceDescription
3031
private var dimPastEvents = context.config.dimPastEvents
3132
private var mediumFontSize = context.getWidgetFontSize()
33+
private var smallMargin = context.resources.getDimension(R.dimen.small_margin).toInt()
34+
private var normalMargin = context.resources.getDimension(R.dimen.normal_margin).toInt()
3235

3336
init {
3437
initConfigValues()
@@ -107,6 +110,21 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
107110
setTextSize(R.id.event_item_title, mediumFontSize)
108111
setTextSize(R.id.event_item_time, mediumFontSize)
109112

113+
setVisibleIf(R.id.event_item_task_image, item.isTask)
114+
applyColorFilter(R.id.event_item_task_image, curTextColor)
115+
116+
if (item.isTask) {
117+
setViewPadding(R.id.event_item_title, 0, 0, smallMargin, 0)
118+
} else {
119+
setViewPadding(R.id.event_item_title, normalMargin, 0, smallMargin, 0)
120+
}
121+
122+
if (item.isTaskCompleted) {
123+
setInt(R.id.event_item_title, "setPaintFlags", Paint.ANTI_ALIAS_FLAG or Paint.STRIKE_THRU_TEXT_FLAG)
124+
} else {
125+
setInt(R.id.event_item_title, "setPaintFlags", Paint.ANTI_ALIAS_FLAG)
126+
}
127+
110128
Intent().apply {
111129
putExtra(EVENT_ID, item.id)
112130
putExtra(EVENT_OCCURRENCE_TS, item.startTS)

app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetMonthlyProvider.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
151151
setTextSize(R.id.day_monthly_event_id, smallerFontSize - 3f)
152152
setBackgroundColor(R.id.day_monthly_event_holder, backgroundColor)
153153
setVisibleIf(R.id.day_monthly_task_image, it.isTask())
154+
applyColorFilter(R.id.day_monthly_task_image, eventTextColor)
154155

155156
if (it.isTaskCompleted()) {
156157
setInt(R.id.day_monthly_event_id, "setPaintFlags", Paint.ANTI_ALIAS_FLAG or Paint.STRIKE_THRU_TEXT_FLAG)

app/src/main/res/layout/event_list_item_widget.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@
2020
android:paddingTop="@dimen/tiny_margin"
2121
android:scaleType="fitXY" />
2222

23+
<ImageView
24+
android:id="@+id/event_item_task_image"
25+
android:layout_width="wrap_content"
26+
android:layout_height="wrap_content"
27+
android:layout_alignTop="@+id/event_item_title"
28+
android:layout_alignBottom="@+id/event_item_title"
29+
android:layout_marginStart="@dimen/normal_margin"
30+
android:contentDescription="@string/task"
31+
android:src="@drawable/ic_task_vector" />
32+
2333
<TextView
2434
android:id="@+id/event_item_title"
2535
android:layout_width="match_parent"
2636
android:layout_height="wrap_content"
27-
android:layout_marginStart="@dimen/normal_margin"
37+
android:layout_toEndOf="@+id/event_item_task_image"
2838
android:ellipsize="end"
2939
android:includeFontPadding="false"
3040
android:maxLines="1"
@@ -37,7 +47,7 @@
3747
android:layout_width="match_parent"
3848
android:layout_height="wrap_content"
3949
android:layout_below="@+id/event_item_title"
40-
android:layout_alignStart="@+id/event_item_title"
50+
android:layout_marginStart="@dimen/normal_margin"
4151
android:alpha="0.8"
4252
android:ellipsize="end"
4353
android:includeFontPadding="false"

0 commit comments

Comments
 (0)