From d4994d5ed48afefdc39cd21e4ad37f1066b0c8a1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 26 Feb 2022 22:08:17 +0100 Subject: [PATCH] show a Task icon at tasks at some views --- .../calendar/pro/adapters/DayEventsAdapter.kt | 16 ++++++++++++-- .../calendar/pro/adapters/EventListAdapter.kt | 11 ++++++++++ app/src/main/res/layout/event_list_item.xml | 21 +++++++++++++++---- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt index 0ab467661..28d8008b8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt @@ -1,9 +1,9 @@ package com.simplemobiletools.calendar.pro.adapters -import android.graphics.Paint import android.view.Menu import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintLayout import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.activities.SimpleActivity import com.simplemobiletools.calendar.pro.dialogs.DeleteEventDialog @@ -11,7 +11,9 @@ import com.simplemobiletools.calendar.pro.extensions.* import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter -import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.extensions.adjustAlpha +import com.simplemobiletools.commons.extensions.applyColorFilter +import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.views.MyRecyclerView @@ -25,6 +27,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r private val replaceDescriptionWithLocation = activity.config.replaceDescription private val dimPastEvents = activity.config.dimPastEvents private var isPrintVersion = false + private val mediumMargin = activity.resources.getDimension(R.dimen.medium_margin).toInt() init { setupDragListener(true) @@ -98,6 +101,15 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r event_item_time.setTextColor(newTextColor) event_item_title.setTextColor(newTextColor) event_item_description?.setTextColor(newTextColor) + event_item_task_image.applyColorFilter(newTextColor) + event_item_task_image.beVisibleIf(event.isTask()) + + val startMargin = if (event.isTask()) { + 0 + } else { + mediumMargin + } + (event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt index 97ecd9438..eb5e4bd40 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.adapters import android.view.Menu import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintLayout import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.activities.SimpleActivity import com.simplemobiletools.calendar.pro.dialogs.DeleteEventDialog @@ -38,6 +39,7 @@ class EventListAdapter( private var use24HourFormat = activity.config.use24HourFormat private var currentItemsHash = listItems.hashCode() private var isPrintVersion = false + private val mediumMargin = activity.resources.getDimension(R.dimen.medium_margin).toInt() init { setupDragListener(true) @@ -165,6 +167,15 @@ class EventListAdapter( event_item_time.setTextColor(newTextColor) event_item_title.setTextColor(newTextColor) event_item_description.setTextColor(newTextColor) + event_item_task_image.applyColorFilter(newTextColor) + event_item_task_image.beVisibleIf(listEvent.isTask) + + val startMargin = if (listEvent.isTask) { + 0 + } else { + mediumMargin + } + (event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin } } diff --git a/app/src/main/res/layout/event_list_item.xml b/app/src/main/res/layout/event_list_item.xml index 05a790d9a..1c81eae4d 100644 --- a/app/src/main/res/layout/event_list_item.xml +++ b/app/src/main/res/layout/event_list_item.xml @@ -31,11 +31,22 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@id/event_item_title" /> + + @@ -54,12 +65,13 @@ android:layout_height="wrap_content" android:layout_below="@+id/event_item_title" android:layout_alignStart="@+id/event_item_title" + android:layout_marginStart="@dimen/medium_margin" android:alpha="0.8" android:includeFontPadding="false" android:paddingBottom="@dimen/small_margin" android:textFontWeight="300" android:textSize="@dimen/normal_text_size" - app:layout_constraintStart_toStartOf="@+id/event_item_title" + app:layout_constraintStart_toEndOf="@+id/event_item_color_bar" app:layout_constraintTop_toBottomOf="@+id/event_item_title" tools:text="13:00" /> @@ -68,6 +80,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_below="@+id/event_item_title" + android:layout_marginStart="@dimen/medium_margin" android:alpha="0.8" android:ellipsize="end" android:includeFontPadding="false" @@ -77,7 +90,7 @@ android:textFontWeight="300" android:textSize="@dimen/normal_text_size" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="@+id/event_item_time" + app:layout_constraintStart_toEndOf="@+id/event_item_color_bar" app:layout_constraintTop_toBottomOf="@+id/event_item_time" tools:text="Event description" />