add some UI handling for multiple reminders

This commit is contained in:
tibbi 2017-02-06 20:03:16 +01:00
parent 2f784cf56a
commit febfc12fbd
2 changed files with 43 additions and 16 deletions

View file

@ -47,8 +47,8 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
} else {
mEvent = Event()
mReminder1Minutes = config.defaultReminderMinutes
mReminder2Minutes = 0
mReminder3Minutes = 0
mReminder2Minutes = -1
mReminder3Minutes = -1
val startTS = intent.getIntExtra(NEW_EVENT_START_TS, 0)
if (startTS == 0)
return
@ -56,9 +56,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
setupNewEvent(Formatter.getDateTimeFromTS(startTS))
}
updateReminder1Text()
updateReminder2Text()
updateReminder3Text()
checkReminderTexts()
updateRepetitionText()
updateStartDate()
updateStartTime()
@ -113,21 +111,21 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
private fun showReminder1Dialog() {
EventReminderDialog(this, mReminder1Minutes) {
mReminder1Minutes = it
updateReminder1Text()
checkReminderTexts()
}
}
private fun showReminder2Dialog() {
EventReminderDialog(this, mReminder2Minutes) {
mReminder2Minutes = it
updateReminder2Text()
checkReminderTexts()
}
}
private fun showReminder3Dialog() {
EventReminderDialog(this, mReminder3Minutes) {
mReminder3Minutes = it
updateReminder3Text()
checkReminderTexts()
}
}
@ -171,16 +169,45 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
}
}
private fun checkReminderTexts() {
updateReminder1Text()
updateReminder2Text()
updateReminder3Text()
}
private fun updateReminder1Text() {
event_reminder_1.text = getReminderText(mReminder1Minutes)
if (mReminder1Minutes == REMINDER_OFF) {
mReminder2Minutes = REMINDER_OFF
mReminder3Minutes = REMINDER_OFF
}
}
private fun updateReminder2Text() {
event_reminder_2.text = getReminderText(mReminder2Minutes)
event_reminder_2.apply {
beGoneIf(mReminder1Minutes == REMINDER_OFF)
if (mReminder2Minutes == REMINDER_OFF) {
text = resources.getString(R.string.add_another_reminder)
alpha = 0.4f
mReminder3Minutes = REMINDER_OFF
} else {
text = getReminderText(mReminder2Minutes)
alpha = 1f
}
}
}
private fun updateReminder3Text() {
event_reminder_2.text = getReminderText(mReminder3Minutes)
event_reminder_3.apply {
beGoneIf(mReminder2Minutes == REMINDER_OFF || mReminder1Minutes == REMINDER_OFF)
if (mReminder3Minutes == REMINDER_OFF) {
text = resources.getString(R.string.add_another_reminder)
alpha = 0.4f
} else {
text = getReminderText(mReminder3Minutes)
alpha = 1f
}
}
}
private fun updateRepetitionText() {

View file

@ -169,8 +169,8 @@
android:layout_toEndOf="@+id/event_reminder_image"
android:layout_toRightOf="@+id/event_reminder_image"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:textSize="@dimen/day_text_size"/>
<com.simplemobiletools.commons.views.MyTextView
@ -182,8 +182,8 @@
android:layout_below="@+id/event_reminder_1"
android:alpha="0.4"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/add_another_reminder"
android:textSize="@dimen/day_text_size"
android:visibility="gone"/>
@ -197,8 +197,8 @@
android:layout_below="@+id/event_reminder_2"
android:alpha="0.4"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/add_another_reminder"
android:textSize="@dimen/day_text_size"
android:visibility="gone"/>