Merge pull request #1491 from 0x8664b2/issue/1212

Start the weekly view with the current date
This commit is contained in:
Tibor Kaputa 2021-10-09 20:41:01 +02:00 committed by GitHub
commit f0b4a0a029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 92 additions and 9 deletions

View File

@ -81,6 +81,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private var mStoredUse24HourFormat = false private var mStoredUse24HourFormat = false
private var mStoredDimPastEvents = true private var mStoredDimPastEvents = true
private var mStoredHighlightWeekends = false private var mStoredHighlightWeekends = false
private var mStoredStartWeeklyViewWithCurrentDate = false
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -122,7 +123,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
} }
if (!config.wasUpgradedFromFreeShown && isPackageInstalled("com.simplemobiletools.calendar")) { if (!config.wasUpgradedFromFreeShown && isPackageInstalled("com.simplemobiletools.calendar")) {
ConfirmationDialog(this, "", R.string.upgraded_from_free, R.string.ok, 0, false) {} ConfirmationDialog(this, "", R.string.upgraded_from_free, R.string.ok, 0) {}
config.wasUpgradedFromFreeShown = true config.wasUpgradedFromFreeShown = true
} }
} }
@ -143,7 +144,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
} }
if (config.storedView == WEEKLY_VIEW) { if (config.storedView == WEEKLY_VIEW) {
if (mStoredIsSundayFirst != config.isSundayFirst || mStoredUse24HourFormat != config.use24HourFormat || mStoredMidnightSpan != config.showMidnightSpanningEventsAtTop) { if (mStoredIsSundayFirst != config.isSundayFirst || mStoredUse24HourFormat != config.use24HourFormat
|| mStoredMidnightSpan != config.showMidnightSpanningEventsAtTop || mStoredStartWeeklyViewWithCurrentDate != config.startWeeklyViewWithCurrentDate) {
updateViewPager() updateViewPager()
} }
} }
@ -258,6 +260,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
mStoredDimPastEvents = dimPastEvents mStoredDimPastEvents = dimPastEvents
mStoredHighlightWeekends = highlightWeekends mStoredHighlightWeekends = highlightWeekends
mStoredMidnightSpan = showMidnightSpanningEventsAtTop mStoredMidnightSpan = showMidnightSpanningEventsAtTop
mStoredStartWeeklyViewWithCurrentDate = startWeeklyViewWithCurrentDate
} }
mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor() mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor()
mStoredDayCode = Formatter.getTodayCode() mStoredDayCode = Formatter.getTodayCode()
@ -816,15 +819,19 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
} }
private fun getThisWeekDateTime(): String { private fun getThisWeekDateTime(): String {
val currentOffsetHours = TimeZone.getDefault().rawOffset / 1000 / 60 / 60 return if(! config.startWeeklyViewWithCurrentDate) {
val currentOffsetHours = TimeZone.getDefault().rawOffset / 1000 / 60 / 60
// not great, not terrible // not great, not terrible
val useHours = if (currentOffsetHours >= 10) 8 else 12 val useHours = if (currentOffsetHours >= 10) 8 else 12
var thisweek = DateTime().withZone(DateTimeZone.UTC).withDayOfWeek(1).withHourOfDay(useHours).minusDays(if (config.isSundayFirst) 1 else 0) var thisweek = DateTime().withZone(DateTimeZone.UTC).withDayOfWeek(1).withHourOfDay(useHours).minusDays(if (config.isSundayFirst) 1 else 0)
if (DateTime().minusDays(7).seconds() > thisweek.seconds()) { if (DateTime().minusDays(7).seconds() > thisweek.seconds()) {
thisweek = thisweek.plusDays(7) thisweek = thisweek.plusDays(7)
}
thisweek.toString()
} else {
DateTime().withZone(DateTimeZone.UTC).toString()
} }
return thisweek.toString()
} }
private fun getFragmentsHolder() = when (config.storedView) { private fun getFragmentsHolder() = when (config.storedView) {

View File

@ -58,6 +58,7 @@ class SettingsActivity : SimpleActivity() {
setupWeeklyStart() setupWeeklyStart()
setupMidnightSpanEvents() setupMidnightSpanEvents()
setupAllowCustomiseDayCount() setupAllowCustomiseDayCount()
setupStartWeeklyViewWithCurrentDate()
setupVibrate() setupVibrate()
setupReminderSound() setupReminderSound()
setupReminderAudioStream() setupReminderAudioStream()
@ -358,6 +359,13 @@ class SettingsActivity : SimpleActivity() {
} }
} }
private fun setupStartWeeklyViewWithCurrentDate() {
settings_start_weekly_view_with_current_date.isChecked = config.startWeeklyViewWithCurrentDate
settings_start_weekly_view_with_current_date.setOnClickListener {
config.startWeeklyViewWithCurrentDate = settings_start_weekly_view_with_current_date.isChecked
}
}
private fun setupWeekNumbers() { private fun setupWeekNumbers() {
settings_week_numbers.isChecked = config.showWeekNumbers settings_week_numbers.isChecked = config.showWeekNumbers
settings_week_numbers_holder.setOnClickListener { settings_week_numbers_holder.setOnClickListener {

View File

@ -23,6 +23,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(START_WEEKLY_AT, 7) get() = prefs.getInt(START_WEEKLY_AT, 7)
set(startWeeklyAt) = prefs.edit().putInt(START_WEEKLY_AT, startWeeklyAt).apply() set(startWeeklyAt) = prefs.edit().putInt(START_WEEKLY_AT, startWeeklyAt).apply()
var startWeeklyViewWithCurrentDate: Boolean
get() = prefs.getBoolean(START_WEEKLY_VIEW_WITH_CURRENT_DATE, false)
set(startWeeklyViewWithCurrentDate) = prefs.edit().putBoolean(START_WEEKLY_VIEW_WITH_CURRENT_DATE, startWeeklyViewWithCurrentDate).apply()
var showMidnightSpanningEventsAtTop: Boolean var showMidnightSpanningEventsAtTop: Boolean
get() = prefs.getBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, true) get() = prefs.getBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, true)
set(midnightSpanning) = prefs.edit().putBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, midnightSpanning).apply() set(midnightSpanning) = prefs.edit().putBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, midnightSpanning).apply()

View File

@ -45,6 +45,7 @@ const val YEAR = 31536000
// Shared Preferences // Shared Preferences
const val WEEK_NUMBERS = "week_numbers" const val WEEK_NUMBERS = "week_numbers"
const val START_WEEKLY_AT = "start_weekly_at" const val START_WEEKLY_AT = "start_weekly_at"
const val START_WEEKLY_VIEW_WITH_CURRENT_DATE = "start_weekly_with_current_date"
const val SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP = "show_midnight_spanning_events_at_top" const val SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP = "show_midnight_spanning_events_at_top"
const val ALLOW_CUSTOMIZE_DAY_COUNT = "allow_customise_day_count" const val ALLOW_CUSTOMIZE_DAY_COUNT = "allow_customise_day_count"
const val VIBRATE = "vibrate" const val VIBRATE = "vibrate"

View File

@ -744,6 +744,28 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/settings_start_weekly_view_with_current_date_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_start_weekly_view_with_current_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:text="@string/start_week_with_current_day" />
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/monthly_view_label" android:id="@+id/monthly_view_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">أسبوع</string> <string name="week">أسبوع</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">أنواع الأحداث</string> <string name="event_types">أنواع الأحداث</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Həftə</string> <string name="week">Həftə</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Hadisə tipləri</string> <string name="event_types">Hadisə tipləri</string>

View File

@ -139,6 +139,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">সপ্তাহ</string> <string name="week">সপ্তাহ</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">ইভেন্ট টাইপগুলি</string> <string name="event_types">ইভেন্ট টাইপগুলি</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Sizhun</string> <string name="week">Sizhun</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Doareoù an darvoud</string> <string name="event_types">Doareoù an darvoud</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Týden</string> <string name="week">Týden</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Typy událostí</string> <string name="event_types">Typy událostí</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Uge</string> <string name="week">Uge</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Begivenhedstyper</string> <string name="event_types">Begivenhedstyper</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Woche</string> <string name="week">Woche</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Termintypen</string> <string name="event_types">Termintypen</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Εβδομάδα</string> <string name="week">Εβδομάδα</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Τύποι εκδηλώσεων</string> <string name="event_types">Τύποι εκδηλώσεων</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Semana</string> <string name="week">Semana</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Tipos de eventos</string> <string name="event_types">Tipos de eventos</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Astea</string> <string name="week">Astea</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Gertaera motak</string> <string name="event_types">Gertaera motak</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Viikko</string> <string name="week">Viikko</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Tapahtuma tyypit</string> <string name="event_types">Tapahtuma tyypit</string>

View File

@ -136,6 +136,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Semaine</string> <string name="week">Semaine</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Type d\événement</string> <string name="event_types">Type d\événement</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Semana</string> <string name="week">Semana</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Tipos de eventos</string> <string name="event_types">Tipos de eventos</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">שבוע</string> <string name="week">שבוע</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">סוגי אירוע</string> <string name="event_types">סוגי אירוע</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Week</string> <string name="week">Week</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Event types</string> <string name="event_types">Event types</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Tjedan</string> <string name="week">Tjedan</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Vrste događaja</string> <string name="event_types">Vrste događaja</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Week</string> <string name="week">Week</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Event types</string> <string name="event_types">Event types</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Minggu</string> <string name="week">Minggu</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Kategori acara</string> <string name="event_types">Kategori acara</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Minggu</string> <string name="week">Minggu</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Kategori acara</string> <string name="event_types">Kategori acara</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Settimana</string> <string name="week">Settimana</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Tipi di evento</string> <string name="event_types">Tipi di evento</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">שבוע</string> <string name="week">שבוע</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">סוגי אירוע</string> <string name="event_types">סוגי אירוע</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week"></string> <string name="week"></string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">予定の種類</string> <string name="event_types">予定の種類</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week"></string> <string name="week"></string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">일정 유형</string> <string name="event_types">일정 유형</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Savaitė</string> <string name="week">Savaitė</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Įvykių tipai</string> <string name="event_types">Įvykių tipai</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Nedēļa</string> <string name="week">Nedēļa</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Notikumu tipi</string> <string name="event_types">Notikumu tipi</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Uke</string> <string name="week">Uke</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Hendelsestyper</string> <string name="event_types">Hendelsestyper</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Week</string> <string name="week">Week</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Afspraaktypes</string> <string name="event_types">Afspraaktypes</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Uke</string> <string name="week">Uke</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Hendelsestyper</string> <string name="event_types">Hendelsestyper</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Tydzień</string> <string name="week">Tydzień</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Typy wydarzeń</string> <string name="event_types">Typy wydarzeń</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Semana</string> <string name="week">Semana</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Tipos de evento</string> <string name="event_types">Tipos de evento</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Semana</string> <string name="week">Semana</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Tipos de eventos</string> <string name="event_types">Tipos de eventos</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Săptămână</string> <string name="week">Săptămână</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Tipuri de eveniment</string> <string name="event_types">Tipuri de eveniment</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Неделя</string> <string name="week">Неделя</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Типы событий</string> <string name="event_types">Типы событий</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Týždeň</string> <string name="week">Týždeň</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Typy udalostí</string> <string name="event_types">Typy udalostí</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Vecka</string> <string name="week">Vecka</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Händelsetyper</string> <string name="event_types">Händelsetyper</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Hafta</string> <string name="week">Hafta</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Etkinlik türleri</string> <string name="event_types">Etkinlik türleri</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Тиждень</string> <string name="week">Тиждень</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Типи подій</string> <string name="event_types">Типи подій</string>

View File

@ -135,6 +135,7 @@
    <!-- Weekly view -->     <!-- Weekly view -->
    <string name="week">周数</string>     <string name="week">周数</string>
    <string name="start_week_with_current_day">Start week with the current day</string>
    <!-- Event types -->     <!-- Event types -->
    <string name="event_types">活动类型</string>     <string name="event_types">活动类型</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">週數</string> <string name="week">週數</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">活動類型</string> <string name="event_types">活動類型</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">週數</string> <string name="week">週數</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">活動類型</string> <string name="event_types">活動類型</string>

View File

@ -135,6 +135,7 @@
<!-- Weekly view --> <!-- Weekly view -->
<string name="week">Week</string> <string name="week">Week</string>
<string name="start_week_with_current_day">Start week with the current day</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Event types</string> <string name="event_types">Event types</string>