mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
Merge pull request #1608 from Aga-C/fix-widget-date-open
Fixed going to date from event list widget (#1607)
This commit is contained in:
@@ -849,12 +849,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
currentFragments.clear()
|
currentFragments.clear()
|
||||||
currentFragments.add(fragment)
|
currentFragments.add(fragment)
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
|
val fixedDayCode = fixDayCode(dayCode)
|
||||||
|
|
||||||
when (config.storedView) {
|
when (config.storedView) {
|
||||||
DAILY_VIEW -> bundle.putString(DAY_CODE, dayCode ?: Formatter.getTodayCode())
|
DAILY_VIEW -> bundle.putString(DAY_CODE, fixedDayCode ?: Formatter.getTodayCode())
|
||||||
WEEKLY_VIEW -> bundle.putString(WEEK_START_DATE_TIME, dayCode ?: getDatesWeekDateTime(DateTime()))
|
WEEKLY_VIEW -> bundle.putString(WEEK_START_DATE_TIME, fixedDayCode ?: getDatesWeekDateTime(DateTime()))
|
||||||
MONTHLY_VIEW, MONTHLY_DAILY_VIEW -> bundle.putString(DAY_CODE, dayCode ?: Formatter.getTodayCode())
|
MONTHLY_VIEW, MONTHLY_DAILY_VIEW -> bundle.putString(DAY_CODE, fixedDayCode ?: Formatter.getTodayCode())
|
||||||
YEARLY_VIEW -> bundle.putString(YEAR_TO_OPEN, dayCode)
|
YEARLY_VIEW -> bundle.putString(YEAR_TO_OPEN, fixedDayCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment.arguments = bundle
|
fragment.arguments = bundle
|
||||||
@@ -862,6 +863,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun fixDayCode(dayCode: String? = null): String? = when {
|
||||||
|
config.storedView == WEEKLY_VIEW && (dayCode?.length == Formatter.DAYCODE_PATTERN.length) -> getDatesWeekDateTime(Formatter.getDateTimeFromCode(dayCode))
|
||||||
|
config.storedView == YEARLY_VIEW && (dayCode?.length == Formatter.DAYCODE_PATTERN.length) -> Formatter.getYearFromDayCode(dayCode)
|
||||||
|
else -> dayCode
|
||||||
|
}
|
||||||
|
|
||||||
fun openMonthFromYearly(dateTime: DateTime) {
|
fun openMonthFromYearly(dateTime: DateTime) {
|
||||||
if (currentFragments.last() is MonthFragmentsHolder) {
|
if (currentFragments.last() is MonthFragmentsHolder) {
|
||||||
return
|
return
|
||||||
|
@@ -136,4 +136,6 @@ object Formatter {
|
|||||||
fun getUTCDayCodeFromTS(ts: Long) = getUTCDateTimeFromTS(ts).toString(DAYCODE_PATTERN)
|
fun getUTCDayCodeFromTS(ts: Long) = getUTCDateTimeFromTS(ts).toString(DAYCODE_PATTERN)
|
||||||
|
|
||||||
fun getShiftedImportTimestamp(ts: Long) = getUTCDateTimeFromTS(ts).withTime(13, 0, 0, 0).withZoneRetainFields(DateTimeZone.getDefault()).seconds()
|
fun getShiftedImportTimestamp(ts: Long) = getUTCDateTimeFromTS(ts).withTime(13, 0, 0, 0).withZoneRetainFields(DateTimeZone.getDefault()).seconds()
|
||||||
|
|
||||||
|
fun getYearFromDayCode(dayCode: String) = getDateTimeFromCode(dayCode).toString(YEAR_PATTERN)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user