update some views at toggling all-day task

This commit is contained in:
tibbi 2022-02-21 23:03:03 +01:00
parent 2c74fbe68f
commit 39a5283a97
2 changed files with 26 additions and 10 deletions

View File

@ -565,7 +565,7 @@ class EventActivity : SimpleActivity() {
} }
private fun handleNotificationAvailability(callback: () -> Unit) { private fun handleNotificationAvailability(callback: () -> Unit) {
if (NotificationManagerCompat.from(applicationContext).areNotificationsEnabled()) { if (NotificationManagerCompat.from(this).areNotificationsEnabled()) {
callback() callback()
} else { } else {
ConfirmationDialog(this, messageId = R.string.notifications_disabled, positive = R.string.ok, negative = 0) { ConfirmationDialog(this, messageId = R.string.notifications_disabled, positive = R.string.ok, negative = 0) {
@ -642,7 +642,7 @@ class EventActivity : SimpleActivity() {
mRepeatLimit > 0 -> { mRepeatLimit > 0 -> {
event_repetition_limit_label.text = getString(R.string.repeat_till) event_repetition_limit_label.text = getString(R.string.repeat_till)
val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit) val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit)
Formatter.getFullDate(applicationContext, repeatLimitDateTime) Formatter.getFullDate(this, repeatLimitDateTime)
} }
else -> { else -> {
event_repetition_limit_label.text = getString(R.string.repeat) event_repetition_limit_label.text = getString(R.string.repeat)
@ -1263,7 +1263,7 @@ class EventActivity : SimpleActivity() {
} }
private fun updateStartDateText() { private fun updateStartDateText() {
event_start_date.text = Formatter.getDate(applicationContext, mEventStartDateTime) event_start_date.text = Formatter.getDate(this, mEventStartDateTime)
checkStartEndValidity() checkStartEndValidity()
} }
@ -1278,7 +1278,7 @@ class EventActivity : SimpleActivity() {
} }
private fun updateEndDateText() { private fun updateEndDateText() {
event_end_date.text = Formatter.getDate(applicationContext, mEventEndDateTime) event_end_date.text = Formatter.getDate(this, mEventEndDateTime)
checkStartEndValidity() checkStartEndValidity()
} }
@ -1554,7 +1554,7 @@ class EventActivity : SimpleActivity() {
val placeholder = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(event_contact_name.value)) val placeholder = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(event_contact_name.value))
event_contact_image.apply { event_contact_image.apply {
attendee.updateImage(applicationContext, this, placeholder) attendee.updateImage(this@EventActivity, this, placeholder)
beVisible() beVisible()
} }

View File

@ -5,12 +5,12 @@ import android.view.Menu
import android.view.WindowManager import android.view.WindowManager
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.TASK_ID import com.simplemobiletools.calendar.pro.helpers.TASK_ID
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.checkAppSideloading import com.simplemobiletools.commons.helpers.mydebug
import com.simplemobiletools.commons.extensions.updateActionBarTitle
import com.simplemobiletools.commons.extensions.updateTextColors
import kotlinx.android.synthetic.main.activity_task.* import kotlinx.android.synthetic.main.activity_task.*
import org.joda.time.DateTime
class TaskActivity : SimpleActivity() { class TaskActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -23,8 +23,8 @@ class TaskActivity : SimpleActivity() {
val intent = intent ?: return val intent = intent ?: return
val taskId = intent.getLongExtra(TASK_ID, 0L) val taskId = intent.getLongExtra(TASK_ID, 0L)
setupNewTask()
updateColors() updateColors()
gotTask()
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
@ -32,12 +32,28 @@ class TaskActivity : SimpleActivity() {
return true return true
} }
private fun gotTask() {
task_all_day.setOnCheckedChangeListener { compoundButton, isChecked -> toggleAllDay(isChecked) }
task_all_day_holder.setOnClickListener {
task_all_day.toggle()
}
task_start_date.text = Formatter.getDate(this, DateTime.now())
task_start_time.text = Formatter.getTime(this, DateTime.now())
setupNewTask()
}
private fun setupNewTask() { private fun setupNewTask() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
task_title.requestFocus() task_title.requestFocus()
updateActionBarTitle(getString(R.string.new_task)) updateActionBarTitle(getString(R.string.new_task))
} }
private fun toggleAllDay(isChecked: Boolean) {
hideKeyboard()
task_start_time.beGoneIf(isChecked)
}
private fun updateColors() { private fun updateColors() {
updateTextColors(task_scrollview) updateTextColors(task_scrollview)
task_time_image.applyColorFilter(config.textColor) task_time_image.applyColorFilter(config.textColor)