mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 04:10:45 +01:00
Add task repetition
This commit is contained in:
parent
085d16d908
commit
84ab2f7806
@ -12,6 +12,8 @@ import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.dialogs.ReminderWarningDialog
|
||||
import com.simplemobiletools.calendar.pro.dialogs.RepeatLimitTypePickerDialog
|
||||
import com.simplemobiletools.calendar.pro.dialogs.RepeatRuleWeeklyDialog
|
||||
import com.simplemobiletools.calendar.pro.dialogs.SelectEventTypeDialog
|
||||
import com.simplemobiletools.calendar.pro.extensions.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.*
|
||||
@ -20,24 +22,31 @@ import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
import com.simplemobiletools.calendar.pro.models.Reminder
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.EVERY_DAY_BIT
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import kotlinx.android.synthetic.main.activity_task.*
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
import kotlin.math.pow
|
||||
|
||||
class TaskActivity : SimpleActivity() {
|
||||
private var mEventTypeId = REGULAR_EVENT_TYPE_ID
|
||||
private lateinit var mTaskDateTime: DateTime
|
||||
private lateinit var mTask: Event
|
||||
private var mIsAllDayEvent = false
|
||||
|
||||
private var mIsAllDayEvent = false
|
||||
private var mReminder1Minutes = REMINDER_OFF
|
||||
private var mReminder2Minutes = REMINDER_OFF
|
||||
private var mReminder3Minutes = REMINDER_OFF
|
||||
private var mReminder1Type = REMINDER_NOTIFICATION
|
||||
private var mReminder2Type = REMINDER_NOTIFICATION
|
||||
private var mReminder3Type = REMINDER_NOTIFICATION
|
||||
private var mRepeatInterval = 0
|
||||
private var mRepeatLimit = 0L
|
||||
private var mRepeatRule = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -103,6 +112,10 @@ class TaskActivity : SimpleActivity() {
|
||||
putInt(REMINDER_1_MINUTES, mReminder1Minutes)
|
||||
putInt(REMINDER_2_MINUTES, mReminder2Minutes)
|
||||
putInt(REMINDER_3_MINUTES, mReminder3Minutes)
|
||||
|
||||
putInt(REPEAT_INTERVAL, mRepeatInterval)
|
||||
putInt(REPEAT_RULE, mRepeatRule)
|
||||
putLong(REPEAT_LIMIT, mRepeatLimit)
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,11 +135,14 @@ class TaskActivity : SimpleActivity() {
|
||||
mReminder1Minutes = getInt(REMINDER_1_MINUTES)
|
||||
mReminder2Minutes = getInt(REMINDER_2_MINUTES)
|
||||
mReminder3Minutes = getInt(REMINDER_3_MINUTES)
|
||||
|
||||
mRepeatInterval = getInt(REPEAT_INTERVAL)
|
||||
mRepeatRule = getInt(REPEAT_RULE)
|
||||
mRepeatLimit = getLong(REPEAT_LIMIT)
|
||||
}
|
||||
|
||||
updateEventType()
|
||||
updateDateText()
|
||||
updateTimeText()
|
||||
updateTexts()
|
||||
}
|
||||
|
||||
private fun gotTask(savedInstanceState: Bundle?, localEventType: EventType?, task: Event?) {
|
||||
@ -167,9 +183,12 @@ class TaskActivity : SimpleActivity() {
|
||||
|
||||
task_date.setOnClickListener { setupDate() }
|
||||
task_time.setOnClickListener { setupTime() }
|
||||
event_type_holder.setOnClickListener { showEventTypeDialog() }
|
||||
task_type_holder.setOnClickListener { showEventTypeDialog() }
|
||||
task_repetition.setOnClickListener { showRepeatIntervalDialog() }
|
||||
task_repetition_rule_holder.setOnClickListener { showRepetitionRuleDialog() }
|
||||
task_repetition_limit_holder.setOnClickListener { showRepetitionTypePicker() }
|
||||
|
||||
event_reminder_1.setOnClickListener {
|
||||
task_reminder_1.setOnClickListener {
|
||||
handleNotificationAvailability {
|
||||
if (config.wasAlarmWarningShown) {
|
||||
showReminder1Dialog()
|
||||
@ -182,14 +201,12 @@ class TaskActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
event_reminder_2.setOnClickListener { showReminder2Dialog() }
|
||||
event_reminder_3.setOnClickListener { showReminder3Dialog() }
|
||||
task_reminder_2.setOnClickListener { showReminder2Dialog() }
|
||||
task_reminder_3.setOnClickListener { showReminder3Dialog() }
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
updateEventType()
|
||||
updateDateText()
|
||||
updateTimeText()
|
||||
updateReminderTexts()
|
||||
updateTexts()
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,12 +222,16 @@ class TaskActivity : SimpleActivity() {
|
||||
mReminder1Type = mTask.reminder1Type
|
||||
mReminder2Type = mTask.reminder2Type
|
||||
mReminder3Type = mTask.reminder3Type
|
||||
mRepeatInterval = mTask.repeatInterval
|
||||
mRepeatLimit = mTask.repeatLimit
|
||||
mRepeatRule = mTask.repeatRule
|
||||
|
||||
task_title.setText(mTask.title)
|
||||
task_description.setText(mTask.description)
|
||||
task_all_day.isChecked = mTask.getIsAllDay()
|
||||
toggleAllDay(mTask.getIsAllDay())
|
||||
setupMarkCompleteButton()
|
||||
checkRepeatTexts(mRepeatInterval)
|
||||
}
|
||||
|
||||
private fun setupNewTask() {
|
||||
@ -278,6 +299,10 @@ class TaskActivity : SimpleActivity() {
|
||||
reminder2Type = mReminder2Type
|
||||
reminder3Minutes = mReminder3Minutes
|
||||
reminder3Type = mReminder3Type
|
||||
|
||||
repeatInterval = mRepeatInterval
|
||||
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
|
||||
repeatRule = mRepeatRule
|
||||
}
|
||||
|
||||
ensureBackgroundThread {
|
||||
@ -354,6 +379,13 @@ class TaskActivity : SimpleActivity() {
|
||||
updateTimeText()
|
||||
}
|
||||
|
||||
private fun updateTexts() {
|
||||
updateDateText()
|
||||
updateTimeText()
|
||||
updateReminderTexts()
|
||||
updateRepetitionText()
|
||||
}
|
||||
|
||||
private fun updateDateText() {
|
||||
task_date.text = Formatter.getDate(this, mTaskDateTime)
|
||||
}
|
||||
@ -405,12 +437,12 @@ class TaskActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun updateReminder1Text() {
|
||||
event_reminder_1.text = getFormattedMinutes(mReminder1Minutes)
|
||||
task_reminder_1.text = getFormattedMinutes(mReminder1Minutes)
|
||||
}
|
||||
|
||||
private fun updateReminder2Text() {
|
||||
event_reminder_2.apply {
|
||||
beGoneIf(event_reminder_2.isGone() && mReminder1Minutes == REMINDER_OFF)
|
||||
task_reminder_2.apply {
|
||||
beGoneIf(task_reminder_2.isGone() && mReminder1Minutes == REMINDER_OFF)
|
||||
if (mReminder2Minutes == REMINDER_OFF) {
|
||||
text = resources.getString(R.string.add_another_reminder)
|
||||
alpha = 0.4f
|
||||
@ -422,8 +454,8 @@ class TaskActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun updateReminder3Text() {
|
||||
event_reminder_3.apply {
|
||||
beGoneIf(event_reminder_3.isGone() && (mReminder2Minutes == REMINDER_OFF || mReminder1Minutes == REMINDER_OFF))
|
||||
task_reminder_3.apply {
|
||||
beGoneIf(task_reminder_3.isGone() && (mReminder2Minutes == REMINDER_OFF || mReminder1Minutes == REMINDER_OFF))
|
||||
if (mReminder3Minutes == REMINDER_OFF) {
|
||||
text = resources.getString(R.string.add_another_reminder)
|
||||
alpha = 0.4f
|
||||
@ -495,8 +527,8 @@ class TaskActivity : SimpleActivity() {
|
||||
val eventType = eventTypesDB.getEventTypeWithId(mEventTypeId)
|
||||
if (eventType != null) {
|
||||
runOnUiThread {
|
||||
event_type.text = eventType.title
|
||||
event_type_color.setFillWithStroke(eventType.color, getProperBackgroundColor())
|
||||
task_type.text = eventType.title
|
||||
task_type_color.setFillWithStroke(eventType.color, getProperBackgroundColor())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -506,9 +538,226 @@ class TaskActivity : SimpleActivity() {
|
||||
updateTextColors(task_scrollview)
|
||||
val textColor = getProperTextColor()
|
||||
arrayOf(
|
||||
task_time_image, event_reminder_image, event_type_image
|
||||
task_time_image, task_reminder_image, task_type_image
|
||||
).forEach {
|
||||
it.applyColorFilter(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun showRepeatIntervalDialog() {
|
||||
showEventRepeatIntervalDialog(mRepeatInterval) {
|
||||
setRepeatInterval(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setRepeatInterval(interval: Int) {
|
||||
mRepeatInterval = interval
|
||||
updateRepetitionText()
|
||||
checkRepeatTexts(interval)
|
||||
|
||||
when {
|
||||
mRepeatInterval.isXWeeklyRepetition() -> setRepeatRule(2.0.pow((mTaskDateTime.dayOfWeek - 1).toDouble()).toInt())
|
||||
mRepeatInterval.isXMonthlyRepetition() -> setRepeatRule(REPEAT_SAME_DAY)
|
||||
mRepeatInterval.isXYearlyRepetition() -> setRepeatRule(REPEAT_SAME_DAY)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkRepeatTexts(limit: Int) {
|
||||
task_repetition_limit_holder.beGoneIf(limit == 0)
|
||||
checkRepetitionLimitText()
|
||||
|
||||
task_repetition_rule_holder.beVisibleIf(mRepeatInterval.isXWeeklyRepetition() || mRepeatInterval.isXMonthlyRepetition() || mRepeatInterval.isXYearlyRepetition())
|
||||
checkRepetitionRuleText()
|
||||
}
|
||||
|
||||
private fun showRepetitionTypePicker() {
|
||||
hideKeyboard()
|
||||
RepeatLimitTypePickerDialog(this, mRepeatLimit, mTaskDateTime.seconds()) {
|
||||
setRepeatLimit(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setRepeatLimit(limit: Long) {
|
||||
mRepeatLimit = limit
|
||||
checkRepetitionLimitText()
|
||||
}
|
||||
|
||||
private fun checkRepetitionLimitText() {
|
||||
task_repetition_limit.text = when {
|
||||
mRepeatLimit == 0L -> {
|
||||
task_repetition_limit_label.text = getString(R.string.repeat)
|
||||
resources.getString(R.string.forever)
|
||||
}
|
||||
mRepeatLimit > 0 -> {
|
||||
task_repetition_limit_label.text = getString(R.string.repeat_till)
|
||||
val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit)
|
||||
Formatter.getFullDate(this, repeatLimitDateTime)
|
||||
}
|
||||
else -> {
|
||||
task_repetition_limit_label.text = getString(R.string.repeat)
|
||||
"${-mRepeatLimit} ${getString(R.string.times)}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showRepetitionRuleDialog() {
|
||||
hideKeyboard()
|
||||
when {
|
||||
mRepeatInterval.isXWeeklyRepetition() -> RepeatRuleWeeklyDialog(this, mRepeatRule) {
|
||||
setRepeatRule(it)
|
||||
}
|
||||
mRepeatInterval.isXMonthlyRepetition() -> {
|
||||
val items = getAvailableMonthlyRepetitionRules()
|
||||
RadioGroupDialog(this, items, mRepeatRule) {
|
||||
setRepeatRule(it as Int)
|
||||
}
|
||||
}
|
||||
mRepeatInterval.isXYearlyRepetition() -> {
|
||||
val items = getAvailableYearlyRepetitionRules()
|
||||
RadioGroupDialog(this, items, mRepeatRule) {
|
||||
setRepeatRule(it as Int)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAvailableMonthlyRepetitionRules(): ArrayList<RadioItem> {
|
||||
val items = arrayListOf(RadioItem(REPEAT_SAME_DAY, getString(R.string.repeat_on_the_same_day_monthly)))
|
||||
|
||||
items.add(RadioItem(REPEAT_ORDER_WEEKDAY, getRepeatXthDayString(true, REPEAT_ORDER_WEEKDAY)))
|
||||
if (isLastWeekDayOfMonth()) {
|
||||
items.add(RadioItem(REPEAT_ORDER_WEEKDAY_USE_LAST, getRepeatXthDayString(true, REPEAT_ORDER_WEEKDAY_USE_LAST)))
|
||||
}
|
||||
|
||||
if (isLastDayOfTheMonth()) {
|
||||
items.add(RadioItem(REPEAT_LAST_DAY, getString(R.string.repeat_on_the_last_day_monthly)))
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
private fun getAvailableYearlyRepetitionRules(): ArrayList<RadioItem> {
|
||||
val items = arrayListOf(RadioItem(REPEAT_SAME_DAY, getString(R.string.repeat_on_the_same_day_yearly)))
|
||||
|
||||
items.add(RadioItem(REPEAT_ORDER_WEEKDAY, getRepeatXthDayInMonthString(true, REPEAT_ORDER_WEEKDAY)))
|
||||
if (isLastWeekDayOfMonth()) {
|
||||
items.add(RadioItem(REPEAT_ORDER_WEEKDAY_USE_LAST, getRepeatXthDayInMonthString(true, REPEAT_ORDER_WEEKDAY_USE_LAST)))
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
private fun isLastDayOfTheMonth() = mTaskDateTime.dayOfMonth == mTaskDateTime.dayOfMonth().withMaximumValue().dayOfMonth
|
||||
|
||||
private fun isLastWeekDayOfMonth() = mTaskDateTime.monthOfYear != mTaskDateTime.plusDays(7).monthOfYear
|
||||
|
||||
private fun getRepeatXthDayString(includeBase: Boolean, repeatRule: Int): String {
|
||||
val dayOfWeek = mTaskDateTime.dayOfWeek
|
||||
val base = getBaseString(dayOfWeek)
|
||||
val order = getOrderString(repeatRule)
|
||||
val dayString = getDayString(dayOfWeek)
|
||||
return if (includeBase) {
|
||||
"$base $order $dayString"
|
||||
} else {
|
||||
val everyString = getString(if (isMaleGender(mTaskDateTime.dayOfWeek)) R.string.every_m else R.string.every_f)
|
||||
"$everyString $order $dayString"
|
||||
}
|
||||
}
|
||||
|
||||
private fun getBaseString(day: Int): String {
|
||||
return getString(
|
||||
if (isMaleGender(day)) {
|
||||
R.string.repeat_every_m
|
||||
} else {
|
||||
R.string.repeat_every_f
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun isMaleGender(day: Int) = day == 1 || day == 2 || day == 4 || day == 5
|
||||
|
||||
private fun getOrderString(repeatRule: Int): String {
|
||||
val dayOfMonth = mTaskDateTime.dayOfMonth
|
||||
var order = (dayOfMonth - 1) / 7 + 1
|
||||
if (isLastWeekDayOfMonth() && repeatRule == REPEAT_ORDER_WEEKDAY_USE_LAST) {
|
||||
order = -1
|
||||
}
|
||||
|
||||
val isMale = isMaleGender(mTaskDateTime.dayOfWeek)
|
||||
return getString(
|
||||
when (order) {
|
||||
1 -> if (isMale) R.string.first_m else R.string.first_f
|
||||
2 -> if (isMale) R.string.second_m else R.string.second_f
|
||||
3 -> if (isMale) R.string.third_m else R.string.third_f
|
||||
4 -> if (isMale) R.string.fourth_m else R.string.fourth_f
|
||||
5 -> if (isMale) R.string.fifth_m else R.string.fifth_f
|
||||
else -> if (isMale) R.string.last_m else R.string.last_f
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun getDayString(day: Int): String {
|
||||
return getString(
|
||||
when (day) {
|
||||
1 -> R.string.monday_alt
|
||||
2 -> R.string.tuesday_alt
|
||||
3 -> R.string.wednesday_alt
|
||||
4 -> R.string.thursday_alt
|
||||
5 -> R.string.friday_alt
|
||||
6 -> R.string.saturday_alt
|
||||
else -> R.string.sunday_alt
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun getRepeatXthDayInMonthString(includeBase: Boolean, repeatRule: Int): String {
|
||||
val weekDayString = getRepeatXthDayString(includeBase, repeatRule)
|
||||
val monthString = resources.getStringArray(R.array.in_months)[mTaskDateTime.monthOfYear - 1]
|
||||
return "$weekDayString $monthString"
|
||||
}
|
||||
|
||||
private fun setRepeatRule(rule: Int) {
|
||||
mRepeatRule = rule
|
||||
checkRepetitionRuleText()
|
||||
if (rule == 0) {
|
||||
setRepeatInterval(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkRepetitionRuleText() {
|
||||
when {
|
||||
mRepeatInterval.isXWeeklyRepetition() -> {
|
||||
task_repetition_rule.text = if (mRepeatRule == EVERY_DAY_BIT) getString(R.string.every_day) else getSelectedDaysString(mRepeatRule)
|
||||
}
|
||||
mRepeatInterval.isXMonthlyRepetition() -> {
|
||||
val repeatString = if (mRepeatRule == REPEAT_ORDER_WEEKDAY_USE_LAST || mRepeatRule == REPEAT_ORDER_WEEKDAY)
|
||||
R.string.repeat else R.string.repeat_on
|
||||
|
||||
task_repetition_rule_label.text = getString(repeatString)
|
||||
task_repetition_rule.text = getMonthlyRepetitionRuleText()
|
||||
}
|
||||
mRepeatInterval.isXYearlyRepetition() -> {
|
||||
val repeatString = if (mRepeatRule == REPEAT_ORDER_WEEKDAY_USE_LAST || mRepeatRule == REPEAT_ORDER_WEEKDAY)
|
||||
R.string.repeat else R.string.repeat_on
|
||||
|
||||
task_repetition_rule_label.text = getString(repeatString)
|
||||
task_repetition_rule.text = getYearlyRepetitionRuleText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMonthlyRepetitionRuleText() = when (mRepeatRule) {
|
||||
REPEAT_SAME_DAY -> getString(R.string.the_same_day)
|
||||
REPEAT_LAST_DAY -> getString(R.string.the_last_day)
|
||||
else -> getRepeatXthDayString(false, mRepeatRule)
|
||||
}
|
||||
|
||||
private fun getYearlyRepetitionRuleText() = when (mRepeatRule) {
|
||||
REPEAT_SAME_DAY -> getString(R.string.the_same_day)
|
||||
else -> getRepeatXthDayInMonthString(false, mRepeatRule)
|
||||
}
|
||||
|
||||
private fun updateRepetitionText() {
|
||||
task_repetition.text = getRepetitionText(mRepeatInterval)
|
||||
}
|
||||
}
|
||||
|
@ -285,7 +285,6 @@ class EventsHelper(val context: Context) {
|
||||
} else {
|
||||
try {
|
||||
val typesList = context.config.getDisplayEventTypessAsList()
|
||||
events.addAll(eventsDB.getTasksFromTo(fromTS, toTS, typesList))
|
||||
|
||||
events.addAll(eventsDB.getOneTimeEventsFromToWithTypes(toTS, fromTS, typesList).toMutableList() as ArrayList<Event>)
|
||||
} catch (e: Exception) {
|
||||
@ -364,13 +363,13 @@ class EventsHelper(val context: Context) {
|
||||
if (displayEventTypes.isEmpty()) {
|
||||
return ArrayList()
|
||||
} else {
|
||||
eventsDB.getRepeatableEventsFromToWithTypes(toTS, context.config.getDisplayEventTypessAsList()).toMutableList() as ArrayList<Event>
|
||||
eventsDB.getRepeatableEventsOrTasksWithTypes(toTS, context.config.getDisplayEventTypessAsList()).toMutableList() as ArrayList<Event>
|
||||
}
|
||||
} else {
|
||||
if (eventId == -1L) {
|
||||
eventsDB.getRepeatableEventsFromToWithTypes(toTS).toMutableList() as ArrayList<Event>
|
||||
eventsDB.getRepeatableEventsOrTasksWithTypes(toTS).toMutableList() as ArrayList<Event>
|
||||
} else {
|
||||
eventsDB.getRepeatableEventFromToWithId(eventId, toTS).toMutableList() as ArrayList<Event>
|
||||
eventsDB.getRepeatableEventsOrTasksWithId(eventId, toTS).toMutableList() as ArrayList<Event>
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,14 @@ interface EventsDao {
|
||||
@Query("SELECT * FROM events WHERE end_ts > :toTS AND repeat_interval = 0 AND event_type IN (:eventTypeIds) AND type = $TYPE_EVENT")
|
||||
fun getOneTimeFutureEventsWithTypes(toTS: Long, eventTypeIds: List<Long>): List<Event>
|
||||
|
||||
@Query("SELECT * FROM events WHERE start_ts <= :toTS AND repeat_interval != 0 AND type = $TYPE_EVENT")
|
||||
fun getRepeatableEventsFromToWithTypes(toTS: Long): List<Event>
|
||||
@Query("SELECT * FROM events WHERE start_ts <= :toTS AND repeat_interval != 0 AND (type = $TYPE_EVENT OR type = $TYPE_TASK)")
|
||||
fun getRepeatableEventsOrTasksWithTypes(toTS: Long): List<Event>
|
||||
|
||||
@Query("SELECT * FROM events WHERE id = :id AND start_ts <= :toTS AND repeat_interval != 0 AND type = $TYPE_EVENT")
|
||||
fun getRepeatableEventFromToWithId(id: Long, toTS: Long): List<Event>
|
||||
@Query("SELECT * FROM events WHERE id = :id AND start_ts <= :toTS AND repeat_interval != 0 AND (type = $TYPE_EVENT OR type = $TYPE_TASK)")
|
||||
fun getRepeatableEventsOrTasksWithId(id: Long, toTS: Long): List<Event>
|
||||
|
||||
@Query("SELECT * FROM events WHERE start_ts <= :toTS AND start_ts != 0 AND repeat_interval != 0 AND event_type IN (:eventTypeIds) AND type = $TYPE_EVENT")
|
||||
fun getRepeatableEventsFromToWithTypes(toTS: Long, eventTypeIds: List<Long>): List<Event>
|
||||
@Query("SELECT * FROM events WHERE start_ts <= :toTS AND start_ts != 0 AND repeat_interval != 0 AND event_type IN (:eventTypeIds) AND (type = $TYPE_EVENT OR type = $TYPE_TASK)")
|
||||
fun getRepeatableEventsOrTasksWithTypes(toTS: Long, eventTypeIds: List<Long>): List<Event>
|
||||
|
||||
@Query("SELECT * FROM events WHERE repeat_interval != 0 AND (repeat_limit == 0 OR repeat_limit > :currTS) AND event_type IN (:eventTypeIds) AND type = $TYPE_EVENT")
|
||||
fun getRepeatableFutureEventsWithTypes(currTS: Long, eventTypeIds: List<Long>): List<Event>
|
||||
@ -106,10 +106,10 @@ interface EventsDao {
|
||||
@Query("UPDATE events SET import_id = :importId, source = :source WHERE id = :id AND type = $TYPE_EVENT")
|
||||
fun updateEventImportIdAndSource(importId: String, source: String, id: Long)
|
||||
|
||||
@Query("UPDATE events SET repeat_limit = :repeatLimit WHERE id = :id AND type = $TYPE_EVENT")
|
||||
@Query("UPDATE events SET repeat_limit = :repeatLimit WHERE id = :id AND (type = $TYPE_EVENT OR type = $TYPE_TASK)")
|
||||
fun updateEventRepetitionLimit(repeatLimit: Long, id: Long)
|
||||
|
||||
@Query("UPDATE events SET repetition_exceptions = :repetitionExceptions WHERE id = :id AND type = $TYPE_EVENT")
|
||||
@Query("UPDATE events SET repetition_exceptions = :repetitionExceptions WHERE id = :id AND (type = $TYPE_EVENT OR type = $TYPE_TASK)")
|
||||
fun updateEventRepetitionExceptions(repetitionExceptions: String, id: Long)
|
||||
|
||||
@Query("UPDATE events SET flags = :newFlags WHERE id = :id")
|
||||
|
@ -114,7 +114,7 @@
|
||||
tools:text="00:00" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/event_date_time_divider"
|
||||
android:id="@+id/task_date_time_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_below="@+id/task_date"
|
||||
@ -124,23 +124,23 @@
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/event_reminder_image"
|
||||
android:id="@+id/task_reminder_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/event_date_time_divider"
|
||||
android:layout_alignTop="@+id/event_reminder_1"
|
||||
android:layout_alignBottom="@+id/event_reminder_1"
|
||||
android:layout_below="@+id/task_date_time_divider"
|
||||
android:layout_alignTop="@+id/task_reminder_1"
|
||||
android:layout_alignBottom="@+id/task_reminder_1"
|
||||
android:layout_marginStart="@dimen/normal_margin"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_bell_vector" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/event_reminder_1"
|
||||
android:id="@+id/task_reminder_1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_date_time_divider"
|
||||
android:layout_below="@+id/task_date_time_divider"
|
||||
android:layout_marginStart="@dimen/small_margin"
|
||||
android:layout_toEndOf="@+id/event_reminder_image"
|
||||
android:layout_toEndOf="@+id/task_reminder_image"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
@ -152,11 +152,11 @@
|
||||
tools:text="@string/add_another_reminder" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/event_reminder_2"
|
||||
android:id="@+id/task_reminder_2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_reminder_1"
|
||||
android:layout_alignStart="@+id/event_reminder_1"
|
||||
android:layout_below="@+id/task_reminder_1"
|
||||
android:layout_alignStart="@+id/task_reminder_1"
|
||||
android:alpha="0.4"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:ellipsize="end"
|
||||
@ -171,11 +171,11 @@
|
||||
tools:text="@string/add_another_reminder" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/event_reminder_3"
|
||||
android:id="@+id/task_reminder_3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_reminder_2"
|
||||
android:layout_alignStart="@+id/event_reminder_1"
|
||||
android:layout_below="@+id/task_reminder_2"
|
||||
android:layout_alignStart="@+id/task_reminder_1"
|
||||
android:alpha="0.4"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:ellipsize="end"
|
||||
@ -190,49 +190,146 @@
|
||||
tools:text="@string/add_another_reminder" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/event_caldav_calendar_divider"
|
||||
android:id="@+id/task_caldav_calendar_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_below="@+id/event_reminder_3"
|
||||
android:layout_below="@+id/task_reminder_3"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/event_type_image"
|
||||
android:id="@+id/task_repetition_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_below="@+id/task_caldav_calendar_divider"
|
||||
android:layout_alignTop="@+id/task_repetition"
|
||||
android:layout_alignBottom="@+id/task_repetition"
|
||||
android:layout_marginStart="@dimen/normal_margin"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_repeat_vector" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/task_repetition"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/task_caldav_calendar_divider"
|
||||
android:layout_marginStart="@dimen/small_margin"
|
||||
android:layout_toEndOf="@+id/task_repetition_image"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/normal_margin"
|
||||
android:textSize="@dimen/day_text_size"
|
||||
tools:text="@string/no_repetition" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/task_repetition_rule_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/task_repetition"
|
||||
android:layout_alignStart="@+id/task_repetition"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/task_repetition_rule_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/repeat_on"
|
||||
android:textSize="@dimen/day_text_size" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/task_repetition_rule"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_toEndOf="@+id/task_repetition_rule_label"
|
||||
android:clickable="false"
|
||||
android:gravity="end"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:text="@string/every_day"
|
||||
android:textSize="@dimen/day_text_size" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/task_repetition_limit_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/task_repetition_rule_holder"
|
||||
android:layout_alignStart="@+id/task_repetition"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/task_repetition_limit_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@+id/task_repetition_limit"
|
||||
android:clickable="false"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/repeat_till"
|
||||
android:textSize="@dimen/day_text_size" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/task_repetition_limit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:clickable="false"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:text="@string/forever"
|
||||
android:textSize="@dimen/day_text_size" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/task_repetition_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_below="@+id/task_repetition_limit_holder"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/task_type_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/task_repetition_divider"
|
||||
android:layout_alignTop="@+id/task_type_holder"
|
||||
android:layout_alignBottom="@+id/task_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:id="@+id/task_type_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_caldav_calendar_divider"
|
||||
android:layout_below="@+id/task_repetition_divider"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:layout_toEndOf="@+id/event_type_image"
|
||||
android:layout_toEndOf="@+id/task_type_image"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/event_type"
|
||||
android:id="@+id/task_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:layout_toStartOf="@+id/task_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:id="@+id/task_type_color"
|
||||
android:layout_width="@dimen/color_sample_size"
|
||||
android:layout_height="@dimen/color_sample_size"
|
||||
android:layout_alignParentEnd="true"
|
||||
@ -243,10 +340,10 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/event_type_divider"
|
||||
android:id="@+id/task_type_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_below="@+id/event_type_holder"
|
||||
android:layout_below="@+id/task_type_holder"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
@ -255,7 +352,7 @@
|
||||
style="@style/ColoredButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_type_divider"
|
||||
android:layout_below="@+id/task_type_divider"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:text="@string/mark_completed"
|
||||
|
Loading…
x
Reference in New Issue
Block a user