change repetition spinner to a textview in Event details screen

This commit is contained in:
tibbi
2017-02-02 23:55:05 +01:00
parent 3b92072a06
commit af885f2b16
2 changed files with 32 additions and 31 deletions

View File

@@ -24,6 +24,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
private var mWasEndDateSet = false private var mWasEndDateSet = false
private var mWasEndTimeSet = false private var mWasEndTimeSet = false
private var mReminderMinutes = 0 private var mReminderMinutes = 0
private var mRepeatInterval = 0
private var mDialogTheme = 0 private var mDialogTheme = 0
lateinit var mEventStartDateTime: DateTime lateinit var mEventStartDateTime: DateTime
@@ -53,11 +54,11 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
} }
updateReminderText() updateReminderText()
updateRepetitionText()
updateStartDate() updateStartDate()
updateStartTime() updateStartTime()
updateEndDate() updateEndDate()
updateEndTime() updateEndTime()
setupRepetition()
mWasEndDateSet = event != null mWasEndDateSet = event != null
mWasEndTimeSet = event != null mWasEndTimeSet = event != null
@@ -69,6 +70,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
event_all_day.setOnCheckedChangeListener { compoundButton, isChecked -> toggleAllDay(isChecked) } event_all_day.setOnCheckedChangeListener { compoundButton, isChecked -> toggleAllDay(isChecked) }
event_reminder.setOnClickListener { showReminderDialog() } event_reminder.setOnClickListener { showReminderDialog() }
event_repetition.setOnClickListener { showRepeatIntervalDialog() }
updateTextColors(event_scrollview) updateTextColors(event_scrollview)
updateIconColors() updateIconColors()
@@ -82,6 +84,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
event_title.setText(mEvent.title) event_title.setText(mEvent.title)
event_description.setText(mEvent.description) event_description.setText(mEvent.description)
mReminderMinutes = mEvent.reminderMinutes mReminderMinutes = mEvent.reminderMinutes
mRepeatInterval = mEvent.repeatInterval
} }
private fun setupNewEvent(dateTime: DateTime) { 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) { private fun getReminderMinutesToString(minutes: Int) = when (minutes) {
-1 -> getString(R.string.no_reminder) -1 -> getString(R.string.no_reminder)
0 -> getString(R.string.at_start) 0 -> getString(R.string.at_start)
@@ -113,22 +124,18 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
} }
} }
private fun updateReminderText() { private fun updateRepetitionText() {
event_reminder.text = getReminderMinutesToString(mReminderMinutes) event_repetition.text = getRepetitionToString(mRepeatInterval)
} }
private fun setupRepetition() { private fun getRepetitionToString(seconds: Int) = getString(when (seconds) {
event_repetition.setSelection( DAY -> R.string.daily
when (mEvent.repeatInterval) { WEEK -> R.string.weekly
DAY -> 1 BIWEEK -> R.string.biweekly
WEEK -> 2 MONTH -> R.string.monthly
BIWEEK -> 3 YEAR -> R.string.yearly
MONTH -> 4 else -> R.string.no_repetition
YEAR -> 5 })
else -> 0
}
)
}
fun toggleAllDay(isChecked: Boolean) { fun toggleAllDay(isChecked: Boolean) {
event_start_time.beGoneIf(isChecked) event_start_time.beGoneIf(isChecked)
@@ -184,7 +191,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
title = newTitle title = newTitle
description = newDescription description = newDescription
reminderMinutes = mReminderMinutes reminderMinutes = mReminderMinutes
repeatInterval = getRepeatInterval() repeatInterval = mRepeatInterval
} }
if (mEvent.id == 0) { 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() { private fun updateStartDate() {
event_start_date.text = Formatter.getDate(applicationContext, mEventStartDateTime) event_start_date.text = Formatter.getDate(applicationContext, mEventStartDateTime)
} }

View File

@@ -194,14 +194,19 @@
android:padding="@dimen/medium_margin" android:padding="@dimen/medium_margin"
android:src="@drawable/ic_repeat"/> android:src="@drawable/ic_repeat"/>
<com.simplemobiletools.commons.views.MyAppCompatSpinner <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/event_repetition" android:id="@+id/event_repetition"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/event_reminder_divider" android:layout_below="@+id/event_reminder_divider"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginStart="@dimen/small_margin"
android:layout_toEndOf="@+id/event_repetition_image"
android:layout_toRightOf="@+id/event_repetition_image" android:layout_toRightOf="@+id/event_repetition_image"
android:entries="@array/repetition" android:background="?attr/selectableItemBackground"
android:padding="@dimen/normal_margin"/> android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:textSize="@dimen/day_text_size"/>
</RelativeLayout> </RelativeLayout>
</ScrollView> </ScrollView>