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 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)
}

View File

@ -194,14 +194,19 @@
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_repeat"/>
<com.simplemobiletools.commons.views.MyAppCompatSpinner
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/event_repetition"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:entries="@array/repetition"
android:padding="@dimen/normal_margin"/>
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:textSize="@dimen/day_text_size"/>
</RelativeLayout>
</ScrollView>