adjust New Event default date/time according to currently selected fragment
This commit is contained in:
parent
438935c301
commit
3857707345
8 changed files with 19 additions and 4 deletions
|
@ -103,7 +103,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
refreshCalDAVCalendars(false)
|
||||
}
|
||||
|
||||
calendar_fab.setOnClickListener { launchNewEventIntent() }
|
||||
calendar_fab.setOnClickListener {
|
||||
launchNewEventIntent(currentFragments.last().getNewEventDayCode())
|
||||
}
|
||||
calendar_fab.beVisibleIf(config.storedView != YEARLY_VIEW)
|
||||
checkOpenIntents()
|
||||
}
|
||||
|
|
|
@ -232,10 +232,9 @@ private fun getSnoozePendingIntent(context: Context, event: Event): PendingInten
|
|||
return PendingIntent.getService(context, event.id, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
}
|
||||
|
||||
fun Context.launchNewEventIntent() {
|
||||
val code = Formatter.getDayCodeFromDateTime(DateTime(DateTimeZone.getDefault()))
|
||||
fun Context.launchNewEventIntent(dayCode: String = Formatter.getTodayCode(this)) {
|
||||
Intent(applicationContext, EventActivity::class.java).apply {
|
||||
putExtra(NEW_EVENT_START_TS, getNewEventTimestampFromCode(code))
|
||||
putExtra(NEW_EVENT_START_TS, getNewEventTimestampFromCode(dayCode))
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(this)
|
||||
}
|
||||
|
|
|
@ -105,4 +105,6 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
override fun updateActionBarTitle() {
|
||||
(activity as MainActivity).supportActionBar?.title = getString(R.string.app_launcher_name)
|
||||
}
|
||||
|
||||
override fun getNewEventDayCode() = currentDayCode
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.simplemobiletools.calendar.adapters.EventListAdapter
|
|||
import com.simplemobiletools.calendar.extensions.*
|
||||
import com.simplemobiletools.calendar.helpers.EVENT_ID
|
||||
import com.simplemobiletools.calendar.helpers.EVENT_OCCURRENCE_TS
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
import com.simplemobiletools.calendar.models.ListEvent
|
||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||
|
@ -124,4 +125,6 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||
override fun updateActionBarTitle() {
|
||||
(activity as MainActivity).supportActionBar?.title = getString(R.string.app_launcher_name)
|
||||
}
|
||||
|
||||
override fun getNewEventDayCode() = Formatter.getTodayCode(context!!)
|
||||
}
|
||||
|
|
|
@ -106,4 +106,6 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
override fun updateActionBarTitle() {
|
||||
(activity as MainActivity).supportActionBar?.title = getString(R.string.app_launcher_name)
|
||||
}
|
||||
|
||||
override fun getNewEventDayCode() = currentDayCode
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simplemobiletools.calendar.fragments
|
||||
|
||||
import android.support.v4.app.Fragment
|
||||
import org.joda.time.DateTime
|
||||
|
||||
abstract class MyFragmentHolder : Fragment() {
|
||||
abstract fun goToToday()
|
||||
|
@ -10,4 +11,6 @@ abstract class MyFragmentHolder : Fragment() {
|
|||
abstract fun shouldGoToTodayBeVisible(): Boolean
|
||||
|
||||
abstract fun updateActionBarTitle()
|
||||
|
||||
abstract fun getNewEventDayCode(): String
|
||||
}
|
||||
|
|
|
@ -133,6 +133,8 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
setupWeeklyActionbarTitle(currentWeekTS)
|
||||
}
|
||||
|
||||
override fun getNewEventDayCode() = Formatter.getDayCodeFromTS(currentWeekTS)
|
||||
|
||||
override fun scrollTo(y: Int) {
|
||||
weekHolder!!.week_view_hours_scrollview.scrollY = y
|
||||
weekScrollY = y
|
||||
|
|
|
@ -87,4 +87,6 @@ class YearFragmentsHolder : MyFragmentHolder() {
|
|||
override fun updateActionBarTitle() {
|
||||
(activity as? MainActivity)?.supportActionBar?.title = "${getString(R.string.app_launcher_name)} - $currentYear"
|
||||
}
|
||||
|
||||
override fun getNewEventDayCode() = Formatter.getTodayCode(context!!)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue