mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
allow customizing the task event type
This commit is contained in:
@@ -7,7 +7,9 @@ import android.view.Menu
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.calendar.pro.R
|
import com.simplemobiletools.calendar.pro.R
|
||||||
|
import com.simplemobiletools.calendar.pro.dialogs.SelectEventTypeDialog
|
||||||
import com.simplemobiletools.calendar.pro.extensions.config
|
import com.simplemobiletools.calendar.pro.extensions.config
|
||||||
|
import com.simplemobiletools.calendar.pro.extensions.eventTypesDB
|
||||||
import com.simplemobiletools.calendar.pro.extensions.seconds
|
import com.simplemobiletools.calendar.pro.extensions.seconds
|
||||||
import com.simplemobiletools.calendar.pro.helpers.*
|
import com.simplemobiletools.calendar.pro.helpers.*
|
||||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||||
@@ -20,6 +22,7 @@ import java.util.*
|
|||||||
|
|
||||||
class TaskActivity : SimpleActivity() {
|
class TaskActivity : SimpleActivity() {
|
||||||
private var mDialogTheme = 0
|
private var mDialogTheme = 0
|
||||||
|
private var mEventTypeId = REGULAR_EVENT_TYPE_ID
|
||||||
private lateinit var mTaskDateTime: DateTime
|
private lateinit var mTaskDateTime: DateTime
|
||||||
private lateinit var mTask: Event
|
private lateinit var mTask: Event
|
||||||
|
|
||||||
@@ -35,7 +38,7 @@ class TaskActivity : SimpleActivity() {
|
|||||||
mDialogTheme = getDialogTheme()
|
mDialogTheme = getDialogTheme()
|
||||||
updateColors()
|
updateColors()
|
||||||
val taskId = intent.getLongExtra(TASK_ID, 0L)
|
val taskId = intent.getLongExtra(TASK_ID, 0L)
|
||||||
gotTask(null)
|
gotTask(savedInstanceState, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
@@ -59,13 +62,15 @@ class TaskActivity : SimpleActivity() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotTask(task: Event?) {
|
private fun gotTask(savedInstanceState: Bundle?, task: Event?) {
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
mTask = task
|
mTask = task
|
||||||
} else {
|
} else {
|
||||||
mTask = Event(null)
|
mTask = Event(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mEventTypeId = if (config.defaultEventTypeId == -1L) config.lastUsedLocalEventTypeId else config.defaultEventTypeId
|
||||||
|
|
||||||
task_all_day.setOnCheckedChangeListener { compoundButton, isChecked -> toggleAllDay(isChecked) }
|
task_all_day.setOnCheckedChangeListener { compoundButton, isChecked -> toggleAllDay(isChecked) }
|
||||||
task_all_day_holder.setOnClickListener {
|
task_all_day_holder.setOnClickListener {
|
||||||
task_all_day.toggle()
|
task_all_day.toggle()
|
||||||
@@ -73,10 +78,15 @@ class TaskActivity : SimpleActivity() {
|
|||||||
|
|
||||||
task_date.setOnClickListener { setupDate() }
|
task_date.setOnClickListener { setupDate() }
|
||||||
task_time.setOnClickListener { setupTime() }
|
task_time.setOnClickListener { setupTime() }
|
||||||
|
event_type_holder.setOnClickListener { showEventTypeDialog() }
|
||||||
|
|
||||||
setupNewTask()
|
setupNewTask()
|
||||||
updateDateText()
|
|
||||||
updateTimeText()
|
if (savedInstanceState == null) {
|
||||||
|
updateEventType()
|
||||||
|
updateDateText()
|
||||||
|
updateTimeText()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupNewTask() {
|
private fun setupNewTask() {
|
||||||
@@ -99,12 +109,15 @@ class TaskActivity : SimpleActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.lastUsedLocalEventTypeId = mEventTypeId
|
||||||
mTask.apply {
|
mTask.apply {
|
||||||
startTS = mTaskDateTime.withSecondOfMinute(0).withMillisOfSecond(0).seconds()
|
startTS = mTaskDateTime.withSecondOfMinute(0).withMillisOfSecond(0).seconds()
|
||||||
title = newTitle
|
title = newTitle
|
||||||
description = task_description.value
|
description = task_description.value
|
||||||
flags = mTask.flags.addBitIf(task_all_day.isChecked, FLAG_ALL_DAY)
|
flags = mTask.flags.addBitIf(task_all_day.isChecked, FLAG_ALL_DAY)
|
||||||
lastUpdated = System.currentTimeMillis()
|
lastUpdated = System.currentTimeMillis()
|
||||||
|
eventType = mEventTypeId
|
||||||
|
type = TYPE_TASK
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
@@ -167,8 +180,29 @@ class TaskActivity : SimpleActivity() {
|
|||||||
task_time.beGoneIf(isChecked)
|
task_time.beGoneIf(isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showEventTypeDialog() {
|
||||||
|
hideKeyboard()
|
||||||
|
SelectEventTypeDialog(this, mEventTypeId, false, true, false, true) {
|
||||||
|
mEventTypeId = it.id!!
|
||||||
|
updateEventType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateEventType() {
|
||||||
|
ensureBackgroundThread {
|
||||||
|
val eventType = eventTypesDB.getEventTypeWithId(mEventTypeId)
|
||||||
|
if (eventType != null) {
|
||||||
|
runOnUiThread {
|
||||||
|
event_type.text = eventType.title
|
||||||
|
event_type_color.setFillWithStroke(eventType.color, config.backgroundColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateColors() {
|
private fun updateColors() {
|
||||||
updateTextColors(task_scrollview)
|
updateTextColors(task_scrollview)
|
||||||
task_time_image.applyColorFilter(config.textColor)
|
task_time_image.applyColorFilter(config.textColor)
|
||||||
|
event_type_image.applyColorFilter(config.textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -112,5 +112,55 @@
|
|||||||
android:textSize="@dimen/day_text_size"
|
android:textSize="@dimen/day_text_size"
|
||||||
tools:text="00:00" />
|
tools:text="00:00" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/event_caldav_calendar_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:layout_below="@+id/task_time"
|
||||||
|
android:background="@color/divider_grey"
|
||||||
|
android:importantForAccessibility="no" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/event_type_image"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@+id/event_caldav_calendar_divider"
|
||||||
|
android:layout_alignTop="@+id/event_type_holder"
|
||||||
|
android:layout_alignBottom="@+id/event_type_holder"
|
||||||
|
android:layout_marginStart="@dimen/normal_margin"
|
||||||
|
android:padding="@dimen/medium_margin"
|
||||||
|
android:src="@drawable/ic_color_vector" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/event_type_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/event_caldav_calendar_divider"
|
||||||
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
|
android:layout_marginBottom="@dimen/medium_margin"
|
||||||
|
android:layout_toEndOf="@+id/event_type_image"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/event_type"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/small_margin"
|
||||||
|
android:layout_marginEnd="@dimen/medium_margin"
|
||||||
|
android:layout_toStartOf="@+id/event_type_color"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:textSize="@dimen/day_text_size" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/event_type_color"
|
||||||
|
android:layout_width="@dimen/color_sample_size"
|
||||||
|
android:layout_height="@dimen/color_sample_size"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginEnd="@dimen/activity_margin"
|
||||||
|
android:clickable="false" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
Reference in New Issue
Block a user