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 1458ae6aa..751e5e03a 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 @@ -1186,6 +1186,7 @@ class EventActivity : SimpleActivity() { private fun setupTimeZone() { Intent(this, SelectTimeZoneActivity::class.java).apply { + putExtra(CURRENT_TIME_ZONE, mEvent.getTimeZoneString()) startActivityForResult(this, SELECT_TIME_ZONE_INTENT) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SelectTimeZoneActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SelectTimeZoneActivity.kt index a5e025bd7..11746941a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SelectTimeZoneActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SelectTimeZoneActivity.kt @@ -10,6 +10,7 @@ import androidx.appcompat.widget.SearchView import androidx.core.view.MenuItemCompat import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.adapters.SelectTimeZoneAdapter +import com.simplemobiletools.calendar.pro.helpers.CURRENT_TIME_ZONE import com.simplemobiletools.calendar.pro.helpers.TIME_ZONE import com.simplemobiletools.calendar.pro.helpers.getAllTimeZones import com.simplemobiletools.calendar.pro.models.MyTimeZone @@ -18,13 +19,14 @@ import java.util.* class SelectTimeZoneActivity : SimpleActivity() { private var mSearchMenuItem: MenuItem? = null + private val allTimeZones = getAllTimeZones() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_select_time_zone) title = "" - SelectTimeZoneAdapter(this, getAllTimeZones()) { + SelectTimeZoneAdapter(this, allTimeZones) { val data = Intent() data.putExtra(TIME_ZONE, it as MyTimeZone) setResult(RESULT_OK, data) @@ -32,6 +34,12 @@ class SelectTimeZoneActivity : SimpleActivity() { }.apply { select_time_zone_list.adapter = this } + + val currentTimeZone = intent.getStringExtra(CURRENT_TIME_ZONE) ?: TimeZone.getDefault().id + val pos = allTimeZones.indexOfFirst { it.zoneName.equals(currentTimeZone, true) } + if (pos != -1) { + select_time_zone_list.scrollToPosition(pos) + } } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -74,7 +82,7 @@ class SelectTimeZoneActivity : SimpleActivity() { } private fun searchQueryChanged(text: String) { - val timeZones = getAllTimeZones().filter { + val timeZones = allTimeZones.filter { it.zoneName.toLowerCase(Locale.getDefault()).contains(text.toLowerCase(Locale.getDefault())) }.toMutableList() as ArrayList (select_time_zone_list.adapter as? SelectTimeZoneAdapter)?.updateTimeZones(timeZones) 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 7be15d7e2..e42d8e3d1 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 @@ -18,6 +18,7 @@ const val VIEW_TO_OPEN = "view_to_open" const val SHORTCUT_NEW_EVENT = "shortcut_new_event" const val REGULAR_EVENT_TYPE_ID = 1L const val TIME_ZONE = "time_zone" +const val CURRENT_TIME_ZONE = "current_time_zone" const val MONTHLY_VIEW = 1 const val YEARLY_VIEW = 2