display month name and week number in title
This commit is contained in:
parent
3834c389ad
commit
606e227bad
14 changed files with 66 additions and 6 deletions
|
@ -115,6 +115,7 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
}
|
||||
|
||||
private fun updateViewPager() {
|
||||
resetTitle()
|
||||
if (config.storedView == YEARLY_VIEW) {
|
||||
fillYearlyViewPager()
|
||||
} else if (config.storedView == EVENTS_LIST_VIEW) {
|
||||
|
@ -145,6 +146,11 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun resetTitle() {
|
||||
title = getString(R.string.app_launcher_name)
|
||||
supportActionBar?.subtitle = ""
|
||||
}
|
||||
|
||||
private fun fillMonthlyViewPager(targetDay: String) {
|
||||
main_weekly_scrollview.visibility = View.GONE
|
||||
calendar_fab.visibility = View.VISIBLE
|
||||
|
@ -157,7 +163,6 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
currentItem = codes.size / 2
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
title = getString(R.string.app_launcher_name)
|
||||
calendar_event_list_holder.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
@ -183,7 +188,6 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
main_view_pager.visibility = View.GONE
|
||||
calendar_event_list_holder.visibility = View.GONE
|
||||
main_weekly_scrollview.visibility = View.VISIBLE
|
||||
title = getString(R.string.app_launcher_name)
|
||||
|
||||
week_view_hours_holder.removeAllViews()
|
||||
for (i in 1..23) {
|
||||
|
@ -195,6 +199,17 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
|
||||
week_view_view_pager.apply {
|
||||
adapter = weeklyAdapter
|
||||
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
setupActionbarTitle(weekTSs[position])
|
||||
}
|
||||
})
|
||||
currentItem = weekTSs.size / 2
|
||||
}
|
||||
|
||||
|
@ -214,6 +229,19 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
return weekTSs
|
||||
}
|
||||
|
||||
private fun setupActionbarTitle(timestamp: Int) {
|
||||
val startDateTime = Formatter.getDateTimeFromTS(timestamp)
|
||||
val endDateTime = Formatter.getDateTimeFromTS(timestamp + secondsInWeek)
|
||||
val startMonthName = Formatter.getMonthName(this, startDateTime.monthOfYear)
|
||||
if (startDateTime.monthOfYear == endDateTime.monthOfYear) {
|
||||
title = startMonthName
|
||||
} else {
|
||||
val endMonthName = Formatter.getMonthName(this, endDateTime.monthOfYear)
|
||||
title = "$startMonthName - $endMonthName"
|
||||
}
|
||||
supportActionBar?.subtitle = "${getString(R.string.week)} ${startDateTime.weekOfWeekyear.toString()}"
|
||||
}
|
||||
|
||||
private fun fillYearlyViewPager() {
|
||||
main_weekly_scrollview.visibility = View.GONE
|
||||
calendar_fab.visibility = View.GONE
|
||||
|
@ -271,7 +299,6 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
}
|
||||
|
||||
private fun fillEventsList() {
|
||||
title = getString(R.string.app_launcher_name)
|
||||
main_view_pager.adapter = null
|
||||
main_view_pager.visibility = View.GONE
|
||||
main_weekly_scrollview.visibility = View.GONE
|
||||
|
|
|
@ -20,7 +20,7 @@ object Formatter {
|
|||
val dateTime = getDateTimeFromCode(dayCode)
|
||||
val day = dateTime.toString(DAY_PATTERN)
|
||||
val year = dateTime.toString(YEAR_PATTERN)
|
||||
val monthIndex = Integer.valueOf(dayCode.substring(4, 6))!! - 1
|
||||
val monthIndex = Integer.valueOf(dayCode.substring(4, 6))!!
|
||||
val month = getMonthName(context, monthIndex)
|
||||
var date = "$month $day"
|
||||
if (year != DateTime().toString(YEAR_PATTERN))
|
||||
|
@ -56,7 +56,7 @@ object Formatter {
|
|||
fun getDateTimeFromTS(ts: Int) = DateTime(ts * 1000L, DateTimeZone.getDefault())
|
||||
|
||||
// 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]
|
||||
fun getMonthName(context: Context, id: Int) = context.resources.getStringArray(R.array.months)[id - 1]
|
||||
|
||||
fun getTimePattern(context: Context) = if (DateFormat.is24HourFormat(context)) PATTERN_TIME_24 else PATTERN_TIME_12
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
|||
|
||||
private val monthName: String
|
||||
get() {
|
||||
var month = Formatter.getMonthName(mContext, mTargetDate.monthOfYear - 1)
|
||||
var month = Formatter.getMonthName(mContext, mTargetDate.monthOfYear)
|
||||
val targetYear = mTargetDate.toString(YEAR_PATTERN)
|
||||
if (targetYear != DateTime().toString(YEAR_PATTERN)) {
|
||||
month += " $targetYear"
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Ende (optional)</string>
|
||||
<string name="description">Beschreibung</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Sonntag als erster Wochentag</string>
|
||||
<string name="week_numbers">Zeige Kalenderwoche an</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Fin (opcional)</string>
|
||||
<string name="description">Descripción</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Domingo como primer día</string>
|
||||
<string name="week_numbers">Mostrar los números de la semana</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Fin (optionnel)</string>
|
||||
<string name="description">Description</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Dimanche en premier jour</string>
|
||||
<string name="week_numbers">Afficher les numéros de semaine</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">अंत (वैकल्पिक)</string>
|
||||
<string name="description">विवरण</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">रविवार पहला दिन हैं</string>
|
||||
<string name="week_numbers">सफ्ताह क्रमांक दिखाए</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Vég (nem kötelező)</string>
|
||||
<string name="description">Leírás</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Vasárnap a hét első napja</string>
|
||||
<string name="week_numbers">Hetek sorszámának mutatása</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Fine (facoltativo)</string>
|
||||
<string name="description">Descrizione</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Sunday as first day</string>
|
||||
<string name="week_numbers">Show week numbers in monthy view</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">終了 (任意)</string>
|
||||
<string name="description">説明</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">日曜日が最初</string>
|
||||
<string name="week_numbers">週番号を表示</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Fim (opcional)</string>
|
||||
<string name="description">Descrição</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Domingo como primeiro dia</string>
|
||||
<string name="week_numbers">Mostrar número das semanas</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Окончание (необязательно)</string>
|
||||
<string name="description">Описание</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Воскресенье - начало недели</string>
|
||||
<string name="week_numbers">Отображать номера недель</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">Slut (frivillig)</string>
|
||||
<string name="description">Beskrivning</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Sunday as first day</string>
|
||||
<string name="week_numbers">Show week numbers in monthy view</string>
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<string name="end">End (optional)</string>
|
||||
<string name="description">Description</string>
|
||||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="sunday_first">Sunday as first day</string>
|
||||
<string name="week_numbers">Show week numbers in monthy view</string>
|
||||
|
|
Loading…
Reference in a new issue