diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt
index 87e4f07bf..e359e0a3f 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt
@@ -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
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt
index 3a81b9f0f..c93cad5c7 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt
@@ -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
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt
index 92ed36fc0..b75b9ba68 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt
@@ -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"
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index d379ddabc..896b7d146 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -49,6 +49,9 @@
Ende (optional)
Beschreibung
+
+ Week
+
Sonntag als erster Wochentag
Zeige Kalenderwoche an
diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml
index 4f4f9808d..1075722cb 100644
--- a/app/src/main/res/values-es-rES/strings.xml
+++ b/app/src/main/res/values-es-rES/strings.xml
@@ -49,6 +49,9 @@
Fin (opcional)
Descripción
+
+ Week
+
Domingo como primer día
Mostrar los números de la semana
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 5228095aa..d2cdfd632 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -49,6 +49,9 @@
Fin (optionnel)
Description
+
+ Week
+
Dimanche en premier jour
Afficher les numéros de semaine
diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml
index bf235802e..739c21bd7 100644
--- a/app/src/main/res/values-hi-rIN/strings.xml
+++ b/app/src/main/res/values-hi-rIN/strings.xml
@@ -49,6 +49,9 @@
अंत (वैकल्पिक)
विवरण
+
+ Week
+
रविवार पहला दिन हैं
सफ्ताह क्रमांक दिखाए
diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml
index dd0e4d1fb..1b0f9d929 100644
--- a/app/src/main/res/values-hu/strings.xml
+++ b/app/src/main/res/values-hu/strings.xml
@@ -49,6 +49,9 @@
Vég (nem kötelező)
Leírás
+
+ Week
+
Vasárnap a hét első napja
Hetek sorszámának mutatása
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 6edd1e0f0..b59c81eab 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -49,6 +49,9 @@
Fine (facoltativo)
Descrizione
+
+ Week
+
Sunday as first day
Show week numbers in monthy view
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 78711550f..bd557a031 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -49,6 +49,9 @@
終了 (任意)
説明
+
+ Week
+
日曜日が最初
週番号を表示
diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml
index 268d7066c..177d2e0fc 100644
--- a/app/src/main/res/values-pt-rPT/strings.xml
+++ b/app/src/main/res/values-pt-rPT/strings.xml
@@ -49,6 +49,9 @@
Fim (opcional)
Descrição
+
+ Week
+
Domingo como primeiro dia
Mostrar número das semanas
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 69f0957f0..96b9b70e3 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -49,6 +49,9 @@
Окончание (необязательно)
Описание
+
+ Week
+
Воскресенье - начало недели
Отображать номера недель
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 31d2ed2f1..9ad979d24 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -49,6 +49,9 @@
Slut (frivillig)
Beskrivning
+
+ Week
+
Sunday as first day
Show week numbers in monthy view
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bf1139717..1dd8e2732 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -49,6 +49,9 @@
End (optional)
Description
+
+ Week
+
Sunday as first day
Show week numbers in monthy view