Merge pull request #1491 from 0x8664b2/issue/1212
Start the weekly view with the current date
This commit is contained in:
commit
f0b4a0a029
|
@ -81,6 +81,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
private var mStoredUse24HourFormat = false
|
||||
private var mStoredDimPastEvents = true
|
||||
private var mStoredHighlightWeekends = false
|
||||
private var mStoredStartWeeklyViewWithCurrentDate = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -122,7 +123,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +144,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
@ -258,6 +260,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
mStoredDimPastEvents = dimPastEvents
|
||||
mStoredHighlightWeekends = highlightWeekends
|
||||
mStoredMidnightSpan = showMidnightSpanningEventsAtTop
|
||||
mStoredStartWeeklyViewWithCurrentDate = startWeeklyViewWithCurrentDate
|
||||
}
|
||||
mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
mStoredDayCode = Formatter.getTodayCode()
|
||||
|
@ -816,15 +819,19 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
}
|
||||
|
||||
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
|
||||
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)
|
||||
if (DateTime().minusDays(7).seconds() > thisweek.seconds()) {
|
||||
thisweek = thisweek.plusDays(7)
|
||||
// not great, not terrible
|
||||
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)
|
||||
if (DateTime().minusDays(7).seconds() > thisweek.seconds()) {
|
||||
thisweek = thisweek.plusDays(7)
|
||||
}
|
||||
thisweek.toString()
|
||||
} else {
|
||||
DateTime().withZone(DateTimeZone.UTC).toString()
|
||||
}
|
||||
return thisweek.toString()
|
||||
}
|
||||
|
||||
private fun getFragmentsHolder() = when (config.storedView) {
|
||||
|
|
|
@ -58,6 +58,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupWeeklyStart()
|
||||
setupMidnightSpanEvents()
|
||||
setupAllowCustomiseDayCount()
|
||||
setupStartWeeklyViewWithCurrentDate()
|
||||
setupVibrate()
|
||||
setupReminderSound()
|
||||
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() {
|
||||
settings_week_numbers.isChecked = config.showWeekNumbers
|
||||
settings_week_numbers_holder.setOnClickListener {
|
||||
|
|
|
@ -23,6 +23,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getInt(START_WEEKLY_AT, 7)
|
||||
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
|
||||
get() = prefs.getBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, true)
|
||||
set(midnightSpanning) = prefs.edit().putBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, midnightSpanning).apply()
|
||||
|
|
|
@ -45,6 +45,7 @@ const val YEAR = 31536000
|
|||
// Shared Preferences
|
||||
const val WEEK_NUMBERS = "week_numbers"
|
||||
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 ALLOW_CUSTOMIZE_DAY_COUNT = "allow_customise_day_count"
|
||||
const val VIBRATE = "vibrate"
|
||||
|
|
|
@ -744,6 +744,28 @@
|
|||
|
||||
</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
|
||||
android:id="@+id/monthly_view_label"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">أسبوع</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">أنواع الأحداث</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Həftə</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Hadisə tipləri</string>
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">সপ্তাহ</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">ইভেন্ট টাইপগুলি</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Sizhun</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Doareoù an darvoud</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Týden</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Typy událostí</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Uge</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Begivenhedstyper</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Woche</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Termintypen</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Εβδομάδα</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Τύποι εκδηλώσεων</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Semana</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Tipos de eventos</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Astea</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Gertaera motak</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Viikko</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Tapahtuma tyypit</string>
|
||||
|
|
|
@ -136,6 +136,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Semaine</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Type d\’événement</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Semana</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Tipos de eventos</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">שבוע</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">סוגי אירוע</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Event types</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Tjedan</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Vrste događaja</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Event types</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Minggu</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Kategori acara</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Minggu</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Kategori acara</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Settimana</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Tipi di evento</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">שבוע</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">סוגי אירוע</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">週</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">予定の種類</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">주</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">일정 유형</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Savaitė</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Įvykių tipai</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Nedēļa</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Notikumu tipi</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Uke</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Hendelsestyper</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Afspraaktypes</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Uke</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Hendelsestyper</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Tydzień</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Typy wydarzeń</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Semana</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Tipos de evento</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Semana</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Tipos de eventos</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Săptămână</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Tipuri de eveniment</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Неделя</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Типы событий</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Týždeň</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Typy udalostí</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Vecka</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Händelsetyper</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Hafta</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Etkinlik türleri</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Тиждень</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Типи подій</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">周数</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">活动类型</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">週數</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">活動類型</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">週數</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">活動類型</string>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
<!-- Weekly view -->
|
||||
<string name="week">Week</string>
|
||||
<string name="start_week_with_current_day">Start week with the current day</string>
|
||||
|
||||
<!-- Event types -->
|
||||
<string name="event_types">Event types</string>
|
||||
|
|
Loading…
Reference in New Issue