properly toggle the Mark in/complete task button
This commit is contained in:
parent
03237f4ffd
commit
ee64a90b35
|
@ -8,6 +8,7 @@ import android.os.Bundle
|
|||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.dialogs.SelectEventTypeDialog
|
||||
import com.simplemobiletools.calendar.pro.extensions.*
|
||||
|
@ -157,17 +158,7 @@ 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())
|
||||
setupMarkCompleteButton()
|
||||
}
|
||||
|
||||
private fun setupNewTask() {
|
||||
|
@ -282,6 +273,23 @@ class TaskActivity : SimpleActivity() {
|
|||
task_time.beGoneIf(isChecked)
|
||||
}
|
||||
|
||||
private fun setupMarkCompleteButton() {
|
||||
toggle_mark_complete.setOnClickListener { toggleCompletion() }
|
||||
toggle_mark_complete.beVisible()
|
||||
if (mTask.isTaskCompleted()) {
|
||||
toggle_mark_complete.background = ContextCompat.getDrawable(this, R.drawable.button_background_stroke)
|
||||
toggle_mark_complete.setText(R.string.mark_incomplete)
|
||||
toggle_mark_complete.setTextColor(config.textColor)
|
||||
} else {
|
||||
val markCompleteBgColor = if (isWhiteTheme()) {
|
||||
Color.WHITE
|
||||
} else {
|
||||
getAdjustedPrimaryColor()
|
||||
}
|
||||
toggle_mark_complete.setTextColor(markCompleteBgColor.getContrastColor())
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleCompletion() {
|
||||
if (mTask.isTaskCompleted()) {
|
||||
mTask.flags = mTask.flags.removeBit(FLAG_TASK_COMPLETED)
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
android:importantForAccessibility="no" />
|
||||
|
||||
<android.widget.TextView
|
||||
android:id="@+id/mark_complete"
|
||||
android:id="@+id/toggle_mark_complete"
|
||||
style="@style/ColoredButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
Loading…
Reference in New Issue