adding some initial timezone handling
This commit is contained in:
parent
40fb2e318c
commit
fb828812ba
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package com.simplemobiletools.calendar.pro.models
|
||||
|
||||
data class MyTimeZone(val id: Int, var title: String, val zoneName: String)
|
Loading…
Reference in New Issue