From af885f2b160cbca9337316341a43f3db7a5d29ce Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 2 Feb 2017 23:55:05 +0100 Subject: [PATCH] change repetition spinner to a textview in Event details screen --- .../calendar/activities/EventActivity.kt | 50 +++++++++---------- app/src/main/res/layout/activity_event.xml | 13 +++-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index 7e90e79e6..da84ef4dc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -24,6 +24,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { private var mWasEndDateSet = false private var mWasEndTimeSet = false private var mReminderMinutes = 0 + private var mRepeatInterval = 0 private var mDialogTheme = 0 lateinit var mEventStartDateTime: DateTime @@ -53,11 +54,11 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } updateReminderText() + updateRepetitionText() updateStartDate() updateStartTime() updateEndDate() updateEndTime() - setupRepetition() mWasEndDateSet = event != null mWasEndTimeSet = event != null @@ -69,6 +70,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_all_day.setOnCheckedChangeListener { compoundButton, isChecked -> toggleAllDay(isChecked) } event_reminder.setOnClickListener { showReminderDialog() } + event_repetition.setOnClickListener { showRepeatIntervalDialog() } updateTextColors(event_scrollview) updateIconColors() @@ -82,6 +84,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_title.setText(mEvent.title) event_description.setText(mEvent.description) mReminderMinutes = mEvent.reminderMinutes + mRepeatInterval = mEvent.repeatInterval } private fun setupNewEvent(dateTime: DateTime) { @@ -98,6 +101,14 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } } + private fun showRepeatIntervalDialog() { + + } + + private fun updateReminderText() { + event_reminder.text = getReminderMinutesToString(mReminderMinutes) + } + private fun getReminderMinutesToString(minutes: Int) = when (minutes) { -1 -> getString(R.string.no_reminder) 0 -> getString(R.string.at_start) @@ -113,22 +124,18 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } } - private fun updateReminderText() { - event_reminder.text = getReminderMinutesToString(mReminderMinutes) + private fun updateRepetitionText() { + event_repetition.text = getRepetitionToString(mRepeatInterval) } - private fun setupRepetition() { - event_repetition.setSelection( - when (mEvent.repeatInterval) { - DAY -> 1 - WEEK -> 2 - BIWEEK -> 3 - MONTH -> 4 - YEAR -> 5 - else -> 0 - } - ) - } + private fun getRepetitionToString(seconds: Int) = getString(when (seconds) { + DAY -> R.string.daily + WEEK -> R.string.weekly + BIWEEK -> R.string.biweekly + MONTH -> R.string.monthly + YEAR -> R.string.yearly + else -> R.string.no_repetition + }) fun toggleAllDay(isChecked: Boolean) { event_start_time.beGoneIf(isChecked) @@ -184,7 +191,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { title = newTitle description = newDescription reminderMinutes = mReminderMinutes - repeatInterval = getRepeatInterval() + repeatInterval = mRepeatInterval } if (mEvent.id == 0) { @@ -194,17 +201,6 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } } - private fun getRepeatInterval(): Int { - return when (event_repetition.selectedItemPosition) { - 1 -> DAY - 2 -> WEEK - 3 -> BIWEEK - 4 -> MONTH - 5 -> YEAR - else -> 0 - } - } - private fun updateStartDate() { event_start_date.text = Formatter.getDate(applicationContext, mEventStartDateTime) } diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index 51e2945b9..5fb2631d3 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -194,14 +194,19 @@ android:padding="@dimen/medium_margin" android:src="@drawable/ic_repeat"/> - + android:background="?attr/selectableItemBackground" + android:paddingBottom="@dimen/normal_margin" + android:paddingTop="@dimen/normal_margin" + android:textSize="@dimen/day_text_size"/>