@ -15,7 +15,6 @@ import org.tasks.Strings
import org.tasks.data.Tag
import org.tasks.data.Tag
import org.tasks.date.DateTimeUtils
import org.tasks.date.DateTimeUtils
import org.tasks.date.DateTimeUtils.toDateTime
import org.tasks.date.DateTimeUtils.toDateTime
import org.tasks.time.DateTime
import org.tasks.time.DateTimeUtils.startOfDay
import org.tasks.time.DateTimeUtils.startOfDay
import timber.log.Timber
import timber.log.Timber
@ -87,8 +86,8 @@ class Task : Parcelable {
@ColumnInfo ( name = " recurrence " )
@ColumnInfo ( name = " recurrence " )
var recurrence : String ? = null
var recurrence : String ? = null
@ColumnInfo ( name = " repeat Until" )
@ColumnInfo ( name = " repeat _from" , defaultValue = RepeatFrom . DUE_DATE . toString ( ) )
var repeat Until = 0L
var repeat From: Int = RepeatFrom . DUE _DATE
@ColumnInfo ( name = " calendarUri " )
@ColumnInfo ( name = " calendarUri " )
var calendarURI : String ? = null
var calendarURI : String ? = null
@ -127,7 +126,6 @@ class Task : Parcelable {
recurrence = parcel . readString ( )
recurrence = parcel . readString ( )
ringFlags = parcel . readInt ( )
ringFlags = parcel . readInt ( )
reminderLast = parcel . readLong ( )
reminderLast = parcel . readLong ( )
repeatUntil = parcel . readLong ( )
timerStart = parcel . readLong ( )
timerStart = parcel . readLong ( )
title = parcel . readString ( )
title = parcel . readString ( )
remoteId = parcel . readString ( ) ?: NO _UUID
remoteId = parcel . readString ( ) ?: NO _UUID
@ -197,7 +195,7 @@ class Task : Parcelable {
return dueDate < compareTo && !is Completed
return dueDate < compareTo && !is Completed
}
}
fun repeatAfterCompletion ( ) : Boolean = re currence. isRepeatAfterCompletion ( )
fun repeatAfterCompletion ( ) : Boolean = re peatFrom == RepeatFrom . COMPLETION _DATE
fun setDueDateAdjustingHideUntil ( newDueDate : Long ) {
fun setDueDateAdjustingHideUntil ( newDueDate : Long ) {
if ( dueDate > 0 ) {
if ( dueDate > 0 ) {
@ -211,18 +209,8 @@ class Task : Parcelable {
val isRecurring : Boolean
val isRecurring : Boolean
get ( ) = ! Strings . isNullOrEmpty ( recurrence )
get ( ) = ! Strings . isNullOrEmpty ( recurrence )
fun setRecurrence ( rrule : String , afterCompletion : Boolean ) {
recurrence = rrule + if ( afterCompletion ) " ;FROM=COMPLETION " else " "
}
fun setRecurrence ( rrule : Recur ? ) {
fun setRecurrence ( rrule : Recur ? ) {
if ( rrule == null ) {
recurrence = rrule ?. toString ( )
repeatUntil = 0
recurrence = null
} else {
repeatUntil = rrule . until ?. let { DateTime ( it ) . millis } ?: 0
recurrence = rrule . toString ( ) + if ( repeatAfterCompletion ( ) ) " ;FROM=COMPLETION " else " "
}
}
}
fun hasNotes ( ) : Boolean {
fun hasNotes ( ) : Boolean {
@ -271,7 +259,6 @@ class Task : Parcelable {
dest . writeString ( recurrence )
dest . writeString ( recurrence )
dest . writeInt ( ringFlags )
dest . writeInt ( ringFlags )
dest . writeLong ( reminderLast )
dest . writeLong ( reminderLast )
dest . writeLong ( repeatUntil )
dest . writeLong ( timerStart )
dest . writeLong ( timerStart )
dest . writeString ( title )
dest . writeString ( title )
dest . writeString ( remoteId )
dest . writeString ( remoteId )
@ -300,7 +287,6 @@ class Task : Parcelable {
&& elapsedSeconds == task . elapsedSeconds
&& elapsedSeconds == task . elapsedSeconds
&& ringFlags == task . ringFlags
&& ringFlags == task . ringFlags
&& recurrence == task . recurrence
&& recurrence == task . recurrence
&& repeatUntil == task . repeatUntil
&& calendarURI == task . calendarURI
&& calendarURI == task . calendarURI
&& parent == task . parent
&& parent == task . parent
&& remoteId == task . remoteId
&& remoteId == task . remoteId
@ -335,7 +321,6 @@ class Task : Parcelable {
&& notes == original . notes
&& notes == original . notes
&& recurrence == original . recurrence
&& recurrence == original . recurrence
&& parent == original . parent
&& parent == original . parent
&& repeatUntil == original . repeatUntil
&& isCollapsed == original . isCollapsed
&& isCollapsed == original . isCollapsed
}
}
@ -418,7 +403,6 @@ class Task : Parcelable {
if ( ringFlags != other . ringFlags ) return false
if ( ringFlags != other . ringFlags ) return false
if ( reminderLast != other . reminderLast ) return false
if ( reminderLast != other . reminderLast ) return false
if ( recurrence != other . recurrence ) return false
if ( recurrence != other . recurrence ) return false
if ( repeatUntil != other . repeatUntil ) return false
if ( calendarURI != other . calendarURI ) return false
if ( calendarURI != other . calendarURI ) return false
if ( remoteId != other . remoteId ) return false
if ( remoteId != other . remoteId ) return false
if ( isCollapsed != other . isCollapsed ) return false
if ( isCollapsed != other . isCollapsed ) return false
@ -445,7 +429,6 @@ class Task : Parcelable {
result = 31 * result + ringFlags
result = 31 * result + ringFlags
result = 31 * result + reminderLast . hashCode ( )
result = 31 * result + reminderLast . hashCode ( )
result = 31 * result + ( recurrence ?. hashCode ( ) ?: 0 )
result = 31 * result + ( recurrence ?. hashCode ( ) ?: 0 )
result = 31 * result + repeatUntil . hashCode ( )
result = 31 * result + ( calendarURI ?. hashCode ( ) ?: 0 )
result = 31 * result + ( calendarURI ?. hashCode ( ) ?: 0 )
result = 31 * result + remoteId . hashCode ( )
result = 31 * result + remoteId . hashCode ( )
result = 31 * result + isCollapsed . hashCode ( )
result = 31 * result + isCollapsed . hashCode ( )
@ -455,7 +438,7 @@ class Task : Parcelable {
}
}
override fun toString ( ) : String {
override fun toString ( ) : String {
return " Task(id= $id , title= $title , priority= $priority , dueDate= $dueDate , hideUntil= $hideUntil , creationDate= $creationDate , modificationDate= $modificationDate , completionDate= $completionDate , deletionDate= $deletionDate , notes= $notes , estimatedSeconds= $estimatedSeconds , elapsedSeconds= $elapsedSeconds , timerStart= $timerStart , ringFlags= $ringFlags , reminderLast= $reminderLast , recurrence= $recurrence , repeatUntil=$repeatUntil , calendarURI=$calendarURI , remoteId=' $remoteId ', isCollapsed= $isCollapsed , parent= $parent , transitoryData= $transitoryData ) "
return " Task(id= $id , title= $title , priority= $priority , dueDate= $dueDate , hideUntil= $hideUntil , creationDate= $creationDate , modificationDate= $modificationDate , completionDate= $completionDate , deletionDate= $deletionDate , notes= $notes , estimatedSeconds= $estimatedSeconds , elapsedSeconds= $elapsedSeconds , timerStart= $timerStart , ringFlags= $ringFlags , reminderLast= $reminderLast , recurrence= $recurrence , calendarURI=$calendarURI , remoteId=' $remoteId ', isCollapsed= $isCollapsed , parent= $parent , transitoryData= $transitoryData ) "
}
}
@Retention ( AnnotationRetention . SOURCE )
@Retention ( AnnotationRetention . SOURCE )
@ -469,6 +452,15 @@ class Task : Parcelable {
}
}
}
}
@Retention ( AnnotationRetention . SOURCE )
@IntDef ( RepeatFrom . DUE _DATE , RepeatFrom . COMPLETION _DATE )
annotation class RepeatFrom {
companion object {
const val DUE _DATE = 0
const val COMPLETION _DATE = 1
}
}
fun clone ( ) : Task {
fun clone ( ) : Task {
val parcel = Parcel . obtain ( )
val parcel = Parcel . obtain ( )
writeToParcel ( parcel , 0 )
writeToParcel ( parcel , 0 )
@ -615,8 +607,5 @@ class Task : Parcelable {
return NO _UUID == uuid || Strings . isNullOrEmpty ( uuid )
return NO _UUID == uuid || Strings . isNullOrEmpty ( uuid )
}
}
fun String ?. isRepeatAfterCompletion ( ) = this ?. contains ( " FROM=COMPLETION " ) ?: false
fun String ?. withoutFrom ( ) : String ? = this ?. replace ( " ;?FROM=[^;]* " . toRegex ( ) , " " )
}
}
}
}