diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index 4ec5e74d0..f05e7fcf7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -313,6 +313,7 @@ class EventActivity : SimpleActivity() { checkReminderTexts() updateStartTexts() updateEndTexts() + updateTimeZoneText() updateAttendeesVisibility() } @@ -1054,6 +1055,10 @@ class EventActivity : SimpleActivity() { checkStartEndValidity() } + private fun updateTimeZoneText() { + event_timezone.text = mEvent.getTimeZoneString() + } + private fun checkStartEndValidity() { val textColor = if (mEventStartDateTime.isAfter(mEventEndDateTime)) resources.getColor(R.color.red_text) else config.textColor event_end_date.setTextColor(textColor) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index 696d37451..96e64983d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -1,5 +1,7 @@ package com.simplemobiletools.calendar.pro.helpers +import com.simplemobiletools.calendar.pro.models.MyTimeZone + const val LOW_ALPHA = .3f const val MEDIUM_ALPHA = .6f const val STORED_LOCALLY_ONLY = 0 @@ -157,3 +159,10 @@ const val REMINDER_NOTIFICATION = 0 const val REMINDER_EMAIL = 1 fun getNowSeconds() = System.currentTimeMillis() / 1000L + +// timezones fetched from https://www.joda.org/joda-time/timezones.html +fun getAllTimeZones() = arrayListOf( + MyTimeZone(1, "GMT-11:00", "Pacific/Midway"), + MyTimeZone(2, "GMT-11:00", "Pacific/Niue"), + MyTimeZone(3, "GMT-11:00", "Pacific/Pago_Pago") +) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt index d23df05fc..026cb63ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt @@ -9,6 +9,7 @@ import com.simplemobiletools.calendar.pro.extensions.seconds import com.simplemobiletools.calendar.pro.helpers.* import com.simplemobiletools.commons.extensions.addBitIf import org.joda.time.DateTime +import org.joda.time.DateTimeZone import java.io.Serializable @Entity(tableName = "events", indices = [(Index(value = ["id"], unique = true))]) @@ -177,4 +178,12 @@ data class Event( } var color: Int = 0 + + fun getTimeZoneString(): String { + return if (timeZone.isNotEmpty() && getAllTimeZones().map { it.zoneName }.contains(timeZone)) { + timeZone + } else { + DateTimeZone.getDefault().id + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/MyTimeZone.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/MyTimeZone.kt new file mode 100644 index 000000000..ee842162f --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/MyTimeZone.kt @@ -0,0 +1,3 @@ +package com.simplemobiletools.calendar.pro.models + +data class MyTimeZone(val id: Int, var title: String, val zoneName: String)