add a button for marking tasks complete
This commit is contained in:
parent
c1e1ee4685
commit
03237f4ffd
|
@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.activities
|
|||
import android.app.DatePickerDialog
|
||||
import android.app.TimePickerDialog
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
@ -156,6 +157,17 @@ class TaskActivity : SimpleActivity() {
|
|||
mEventTypeId = mTask.eventType
|
||||
task_title.setText(mTask.title)
|
||||
task_description.setText(mTask.description)
|
||||
|
||||
mark_complete.setOnClickListener { toggleCompletion() }
|
||||
mark_complete.beVisible()
|
||||
|
||||
val markCompleteBgColor = if (isWhiteTheme()) {
|
||||
Color.WHITE
|
||||
} else {
|
||||
getAdjustedPrimaryColor()
|
||||
}
|
||||
|
||||
mark_complete.setTextColor(markCompleteBgColor.getContrastColor())
|
||||
}
|
||||
|
||||
private fun setupNewTask() {
|
||||
|
@ -270,6 +282,20 @@ class TaskActivity : SimpleActivity() {
|
|||
task_time.beGoneIf(isChecked)
|
||||
}
|
||||
|
||||
private fun toggleCompletion() {
|
||||
if (mTask.isTaskCompleted()) {
|
||||
mTask.flags = mTask.flags.removeBit(FLAG_TASK_COMPLETED)
|
||||
} else {
|
||||
mTask.flags = mTask.flags or FLAG_TASK_COMPLETED
|
||||
}
|
||||
|
||||
ensureBackgroundThread {
|
||||
eventsDB.updateTaskCompletion(mTask.id!!, mTask.flags)
|
||||
hideKeyboard()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showEventTypeDialog() {
|
||||
hideKeyboard()
|
||||
SelectEventTypeDialog(this, mEventTypeId, false, true, false, true) {
|
||||
|
|
|
@ -122,7 +122,7 @@ const val REPEAT_ORDER_WEEKDAY = 4 // i.e. every 4th sunday
|
|||
const val FLAG_ALL_DAY = 1
|
||||
const val FLAG_IS_IN_PAST = 2
|
||||
const val FLAG_MISSING_YEAR = 4
|
||||
const val FLAG_TASK_COMPLETE = 8
|
||||
const val FLAG_TASK_COMPLETED = 8
|
||||
|
||||
// constants related to ICS file exporting / importing
|
||||
const val BEGIN_CALENDAR = "BEGIN:VCALENDAR"
|
||||
|
|
|
@ -109,6 +109,9 @@ interface EventsDao {
|
|||
@Query("UPDATE events SET repetition_exceptions = :repetitionExceptions WHERE id = :id AND type = $TYPE_EVENT")
|
||||
fun updateEventRepetitionExceptions(repetitionExceptions: String, id: Long)
|
||||
|
||||
@Query("UPDATE events SET flags = :newFlags WHERE id = :id")
|
||||
fun updateTaskCompletion(id: Long, newFlags: Int)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertOrUpdate(event: Event): Long
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ data class Event(
|
|||
fun getIsAllDay() = flags and FLAG_ALL_DAY != 0
|
||||
fun hasMissingYear() = flags and FLAG_MISSING_YEAR != 0
|
||||
fun isTask() = type == TYPE_TASK
|
||||
fun isTaskCompleted() = flags and FLAG_TASK_COMPLETED != 0
|
||||
|
||||
fun getReminders() = listOf(
|
||||
Reminder(reminder1Minutes, reminder1Type),
|
||||
|
|
|
@ -170,5 +170,17 @@
|
|||
android:layout_below="@+id/event_type_holder"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<android.widget.TextView
|
||||
android:id="@+id/mark_complete"
|
||||
style="@style/ColoredButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/event_type_divider"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:text="@string/mark_completed"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in New Issue