allow customizing the time zone at the Event Details

This commit is contained in:
tibbi 2019-12-10 12:33:45 +01:00
parent 30511d284e
commit 8fc6724b6f
4 changed files with 31 additions and 3 deletions

View file

@ -1,5 +1,6 @@
package com.simplemobiletools.calendar.pro.activities package com.simplemobiletools.calendar.pro.activities
import android.app.Activity
import android.app.DatePickerDialog import android.app.DatePickerDialog
import android.app.TimePickerDialog import android.app.TimePickerDialog
import android.content.Intent import android.content.Intent
@ -61,6 +62,7 @@ class EventActivity : SimpleActivity() {
private val ATTENDEES = "ATTENDEES" private val ATTENDEES = "ATTENDEES"
private val EVENT_TYPE_ID = "EVENT_TYPE_ID" private val EVENT_TYPE_ID = "EVENT_TYPE_ID"
private val EVENT_CALENDAR_ID = "EVENT_CALENDAR_ID" private val EVENT_CALENDAR_ID = "EVENT_CALENDAR_ID"
private val SELECT_TIME_ZONE_INTENT = 1
private var mReminder1Minutes = REMINDER_OFF private var mReminder1Minutes = REMINDER_OFF
private var mReminder2Minutes = REMINDER_OFF private var mReminder2Minutes = REMINDER_OFF
@ -310,6 +312,15 @@ class EventActivity : SimpleActivity() {
checkAttendees() checkAttendees()
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
if (requestCode == SELECT_TIME_ZONE_INTENT && resultCode == Activity.RESULT_OK && resultData?.hasExtra(TIME_ZONE) == true) {
val timeZone = resultData.getSerializableExtra(TIME_ZONE) as MyTimeZone
mEvent.timeZone = timeZone.zoneName
updateTimeZoneText()
}
super.onActivityResult(requestCode, resultCode, resultData)
}
private fun updateTexts() { private fun updateTexts() {
updateRepetitionText() updateRepetitionText()
checkReminderTexts() checkReminderTexts()
@ -1172,7 +1183,9 @@ class EventActivity : SimpleActivity() {
} }
private fun setupTimeZone() { private fun setupTimeZone() {
Intent(this, SelectTimeZoneActivity::class.java).apply {
startActivityForResult(this, SELECT_TIME_ZONE_INTENT)
}
} }
private fun checkRepeatRule() { private fun checkRepeatRule() {

View file

@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.pro.activities
import android.app.SearchManager import android.app.SearchManager
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
@ -9,7 +10,9 @@ import androidx.appcompat.widget.SearchView
import androidx.core.view.MenuItemCompat import androidx.core.view.MenuItemCompat
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.SelectTimeZoneAdapter import com.simplemobiletools.calendar.pro.adapters.SelectTimeZoneAdapter
import com.simplemobiletools.calendar.pro.helpers.TIME_ZONE
import com.simplemobiletools.calendar.pro.helpers.getAllTimeZones import com.simplemobiletools.calendar.pro.helpers.getAllTimeZones
import com.simplemobiletools.calendar.pro.models.MyTimeZone
import kotlinx.android.synthetic.main.activity_select_time_zone.* import kotlinx.android.synthetic.main.activity_select_time_zone.*
class SelectTimeZoneActivity : SimpleActivity() { class SelectTimeZoneActivity : SimpleActivity() {
@ -22,7 +25,10 @@ class SelectTimeZoneActivity : SimpleActivity() {
title = "" title = ""
SelectTimeZoneAdapter(this, getAllTimeZones()) { SelectTimeZoneAdapter(this, getAllTimeZones()) {
val data = Intent()
data.putExtra(TIME_ZONE, it as MyTimeZone)
setResult(RESULT_OK, data)
finish()
}.apply { }.apply {
select_time_zone_list.adapter = this select_time_zone_list.adapter = this
} }

View file

@ -19,6 +19,7 @@ const val CALDAV = "Caldav"
const val VIEW_TO_OPEN = "view_to_open" const val VIEW_TO_OPEN = "view_to_open"
const val SHORTCUT_NEW_EVENT = "shortcut_new_event" const val SHORTCUT_NEW_EVENT = "shortcut_new_event"
const val REGULAR_EVENT_TYPE_ID = 1L const val REGULAR_EVENT_TYPE_ID = 1L
const val TIME_ZONE = "time_zone"
const val MONTHLY_VIEW = 1 const val MONTHLY_VIEW = 1
const val YEARLY_VIEW = 2 const val YEARLY_VIEW = 2

View file

@ -1,3 +1,11 @@
package com.simplemobiletools.calendar.pro.models package com.simplemobiletools.calendar.pro.models
data class MyTimeZone(val id: Int, var title: String, val zoneName: String) import java.io.Serializable
// sample MyTimeZone(id=1, title="GMT+1", zoneName="Europe/Bratislava")
data class MyTimeZone(val id: Int, var title: String, val zoneName: String) : Serializable {
companion object {
private const val serialVersionUID = -32456354132688616L
}
}