Merge tag '10.5' into main

pull/1194/head
Alex Baker 5 years ago
commit 0f0323ce0f

@ -1,7 +1,7 @@
Change Log Change Log
--- ---
======= =======
### 10.5 (2020-10-19) ### 10.5 (2020-10-21)
* Multi-select rescheduling * Multi-select rescheduling
* New task default settings * New task default settings

@ -44,7 +44,7 @@ android {
defaultConfig { defaultConfig {
testApplicationId = "org.tasks.test" testApplicationId = "org.tasks.test"
applicationId = "org.tasks" applicationId = "org.tasks"
versionCode = 100500 versionCode = 100501
versionName = "10.5" versionName = "10.5"
targetSdkVersion(Versions.targetSdk) targetSdkVersion(Versions.targetSdk)
minSdkVersion(Versions.minSdk) minSdkVersion(Versions.minSdk)

@ -67,6 +67,8 @@ class TaskDao @Inject constructor(
suspend fun setParent(parent: Long, tasks: List<Long>) = taskDao.setParent(parent, tasks) suspend fun setParent(parent: Long, tasks: List<Long>) = taskDao.setParent(parent, tasks)
suspend fun getChildren(ids: List<Long>) = taskDao.getChildren(ids)
suspend fun getChildren(id: Long): List<Long> = taskDao.getChildren(id) suspend fun getChildren(id: Long): List<Long> = taskDao.getChildren(id)
suspend fun setCollapsed(id: Long, collapsed: Boolean) = taskDao.setCollapsed(id, collapsed) suspend fun setCollapsed(id: Long, collapsed: Boolean) = taskDao.setCollapsed(id, collapsed)

@ -7,6 +7,7 @@ import com.todoroo.astrid.data.Task
import com.todoroo.astrid.gcal.GCalHelper import com.todoroo.astrid.gcal.GCalHelper
import org.tasks.LocalBroadcastManager import org.tasks.LocalBroadcastManager
import org.tasks.data.* import org.tasks.data.*
import org.tasks.db.DbUtils.dbchunk
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -25,7 +26,12 @@ class TaskDuplicator @Inject constructor(
suspend fun duplicate(taskIds: List<Long>): List<Task> { suspend fun duplicate(taskIds: List<Long>): List<Task> {
val result: MutableList<Task> = ArrayList() val result: MutableList<Task> = ArrayList()
for (task in taskDao.fetch(taskIds)) { val tasks = ArrayList(taskIds)
taskIds.dbchunk().forEach {
tasks.removeAll(googleTaskDao.getChildren(it))
tasks.removeAll(taskDao.getChildren(it))
}
for (task in taskDao.fetch(tasks)) {
result.add(clone(task)) result.add(clone(task))
} }
localBroadcastManager.broadcastRefresh() localBroadcastManager.broadcastRefresh()

@ -87,8 +87,8 @@ class DateTimePicker : BottomSheetDialogFragment() {
bundle.putLongArray(EXTRA_TASKS, tasks.map { it.id }.toLongArray()) bundle.putLongArray(EXTRA_TASKS, tasks.map { it.id }.toLongArray())
val dueDates = tasks.map { it.dueDate.startOfDay() }.toSet() val dueDates = tasks.map { it.dueDate.startOfDay() }.toSet()
val dueTimes = tasks.map { it.dueDate.millisOfDay() }.toSet() val dueTimes = tasks.map { it.dueDate.millisOfDay() }.toSet()
bundle.putLong(EXTRA_DAY, if (dueDates.size == 1) dueDates.first() else -1) bundle.putLong(EXTRA_DAY, if (dueDates.size == 1) dueDates.first() else MULTIPLE_DAYS)
bundle.putInt(EXTRA_TIME, if (dueTimes.size == 1) dueTimes.first() else -1) bundle.putInt(EXTRA_TIME, if (dueTimes.size == 1) dueTimes.first() else MULTIPLE_TIMES)
bundle.putBoolean(EXTRA_AUTO_CLOSE, autoClose) bundle.putBoolean(EXTRA_AUTO_CLOSE, autoClose)
val fragment = DateTimePicker() val fragment = DateTimePicker()
fragment.arguments = bundle fragment.arguments = bundle
@ -129,7 +129,11 @@ class DateTimePicker : BottomSheetDialogFragment() {
binding.calendarView.firstDayOfWeek = firstDayOfWeek binding.calendarView.firstDayOfWeek = firstDayOfWeek
} }
selectedDay = savedInstanceState?.getLong(EXTRA_DAY) ?: requireArguments().getLong(EXTRA_DAY) selectedDay = savedInstanceState?.getLong(EXTRA_DAY) ?: requireArguments().getLong(EXTRA_DAY)
selectedTime = savedInstanceState?.getInt(EXTRA_TIME) ?: requireArguments().getInt(EXTRA_TIME) selectedTime =
savedInstanceState?.getInt(EXTRA_TIME)
?: requireArguments().getInt(EXTRA_TIME)
.takeIf { it == MULTIPLE_TIMES || Task.hasDueTime(it.toLong()) }
?: NO_TIME
return binding.root return binding.root
} }
@ -275,14 +279,26 @@ class DateTimePicker : BottomSheetDialogFragment() {
taskDao taskDao
.fetch(taskIds.toList()) .fetch(taskIds.toList())
.forEach { .forEach {
val day = if (selectedDay == MULTIPLE_DAYS) {
if (it.hasDueDate()) it.dueDate else today.millis
} else {
selectedDay
}
val time = if (selectedTime == MULTIPLE_TIMES) {
if (it.hasDueTime()) it.dueDate.millisOfDay() else NO_TIME
} else {
selectedTime
}
it.setDueDateAdjustingHideUntil(when { it.setDueDateAdjustingHideUntil(when {
selectedDay == MULTIPLE_DAYS -> day == NO_DAY -> 0L
it.dueDate.toDateTime().withMillisOfDay(selectedTime).millis time == NO_TIME -> Task.createDueDate(
selectedDay == NO_DAY -> 0L Task.URGENCY_SPECIFIC_DAY,
selectedTime == MULTIPLE_TIMES -> day
selectedDay.toDateTime().withMillisOfDay(it.dueDate.millisOfDay()).millis )
selectedTime == NO_TIME -> selectedDay else -> Task.createDueDate(
else -> selectedDay.toDateTime().withMillisOfDay(selectedTime).millis Task.URGENCY_SPECIFIC_DAY_TIME,
day.toDateTime().withMillisOfDay(time).millis
)
}) })
taskDao.save(it) taskDao.save(it)
} }

Loading…
Cancel
Save