mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-02 03:36:50 +01:00
fix #154, properly update the actionbar title at yearly view
This commit is contained in:
parent
f63e7a5924
commit
00efe5b33a
@ -335,6 +335,10 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
if (config.storedView == YEARLY_VIEW) {
|
||||||
|
val dateTime = Formatter.getDateTimeFromCode(codes[position])
|
||||||
|
title = "${getString(R.string.app_launcher_name)} - ${Formatter.getYear(dateTime)}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
currentItem = mDefaultMonthlyPage
|
currentItem = mDefaultMonthlyPage
|
||||||
@ -391,7 +395,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
setupActionbarTitle(weekTSs[position])
|
setupWeeklyActionbarTitle(weekTSs[position])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
currentItem = mDefaultWeeklyPage
|
currentItem = mDefaultWeeklyPage
|
||||||
@ -419,7 +423,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
return weekTSs
|
return weekTSs
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupActionbarTitle(timestamp: Int) {
|
private fun setupWeeklyActionbarTitle(timestamp: Int) {
|
||||||
val startDateTime = Formatter.getDateTimeFromTS(timestamp)
|
val startDateTime = Formatter.getDateTimeFromTS(timestamp)
|
||||||
val endDateTime = Formatter.getDateTimeFromTS(timestamp + WEEK_SECONDS)
|
val endDateTime = Formatter.getDateTimeFromTS(timestamp + WEEK_SECONDS)
|
||||||
val startMonthName = Formatter.getMonthName(this, startDateTime.monthOfYear)
|
val startMonthName = Formatter.getMonthName(this, startDateTime.monthOfYear)
|
||||||
|
@ -67,6 +67,8 @@ object Formatter {
|
|||||||
// use manually translated month names, as DateFormat and Joda have issues with a lot of languages
|
// use manually translated month names, as DateFormat and Joda have issues with a lot of languages
|
||||||
fun getMonthName(context: Context, id: Int) = context.resources.getStringArray(R.array.months)[id - 1]
|
fun getMonthName(context: Context, id: Int) = context.resources.getStringArray(R.array.months)[id - 1]
|
||||||
|
|
||||||
|
fun getYear(dateTime: DateTime) = dateTime.toString(YEAR_PATTERN)
|
||||||
|
|
||||||
fun getHourPattern(context: Context) = if (context.config.use24hourFormat) PATTERN_HOURS_24 else PATTERN_HOURS_12
|
fun getHourPattern(context: Context) = if (context.config.use24hourFormat) PATTERN_HOURS_24 else PATTERN_HOURS_12
|
||||||
|
|
||||||
fun getTimePattern(context: Context) = if (context.config.use24hourFormat) PATTERN_TIME_24 else PATTERN_TIME_12
|
fun getTimePattern(context: Context) = if (context.config.use24hourFormat) PATTERN_TIME_24 else PATTERN_TIME_12
|
||||||
|
Loading…
x
Reference in New Issue
Block a user