From 4cf2f57f4427f7fe84e13dfde5c152d20591971c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 9 Oct 2021 20:47:18 +0200 Subject: [PATCH] tweaking some code related to starting weekly view with current day --- app/build.gradle | 4 ++-- .../calendar/pro/activities/MainActivity.kt | 8 ++++---- .../calendar/pro/activities/SettingsActivity.kt | 15 ++++++++------- .../calendar/pro/helpers/Config.kt | 6 +++--- .../calendar/pro/helpers/Constants.kt | 2 +- app/src/main/res/layout/activity_settings.xml | 4 ++-- app/src/main/res/values-sk/strings.xml | 2 +- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 932357760..25d8c1b14 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,10 +63,10 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:a74ec200da' + implementation 'com.github.SimpleMobileTools:Simple-Commons:ea206806fc' implementation 'joda-time:joda-time:2.10.3' implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation "androidx.print:print:1.0.0" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt index d41d392da..80e3d2b3e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt @@ -81,7 +81,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private var mStoredUse24HourFormat = false private var mStoredDimPastEvents = true private var mStoredHighlightWeekends = false - private var mStoredStartWeeklyViewWithCurrentDate = false + private var mStoredStartWeekWithCurrentDay = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -145,7 +145,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { if (config.storedView == WEEKLY_VIEW) { if (mStoredIsSundayFirst != config.isSundayFirst || mStoredUse24HourFormat != config.use24HourFormat - || mStoredMidnightSpan != config.showMidnightSpanningEventsAtTop || mStoredStartWeeklyViewWithCurrentDate != config.startWeeklyViewWithCurrentDate) { + || mStoredMidnightSpan != config.showMidnightSpanningEventsAtTop || mStoredStartWeekWithCurrentDay != config.startWeekWithCurrentDay) { updateViewPager() } } @@ -260,7 +260,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { mStoredDimPastEvents = dimPastEvents mStoredHighlightWeekends = highlightWeekends mStoredMidnightSpan = showMidnightSpanningEventsAtTop - mStoredStartWeeklyViewWithCurrentDate = startWeeklyViewWithCurrentDate + mStoredStartWeekWithCurrentDay = startWeekWithCurrentDay } mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor() mStoredDayCode = Formatter.getTodayCode() @@ -819,7 +819,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } private fun getThisWeekDateTime(): String { - return if(! config.startWeeklyViewWithCurrentDate) { + return if(! config.startWeekWithCurrentDay) { val currentOffsetHours = TimeZone.getDefault().rawOffset / 1000 / 60 / 60 // not great, not terrible diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt index 48adfb591..b3f3c8747 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt @@ -57,8 +57,8 @@ class SettingsActivity : SimpleActivity() { setupShowGrid() setupWeeklyStart() setupMidnightSpanEvents() - setupAllowCustomiseDayCount() - setupStartWeeklyViewWithCurrentDate() + setupAllowCustomizeDayCount() + setupStartWeekWithCurrentDay() setupVibrate() setupReminderSound() setupReminderAudioStream() @@ -351,7 +351,7 @@ class SettingsActivity : SimpleActivity() { } } - private fun setupAllowCustomiseDayCount() { + private fun setupAllowCustomizeDayCount() { settings_allow_customize_day_count.isChecked = config.allowCustomizeDayCount settings_allow_customize_day_count_holder.setOnClickListener { settings_allow_customize_day_count.toggle() @@ -359,10 +359,11 @@ 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 setupStartWeekWithCurrentDay() { + settings_start_week_with_current_day.isChecked = config.startWeekWithCurrentDay + settings_start_week_with_current_day_holder.setOnClickListener { + settings_start_week_with_current_day.toggle() + config.startWeekWithCurrentDay = settings_start_week_with_current_day.isChecked } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt index 7633ed0ec..97772de36 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt @@ -23,9 +23,9 @@ 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 startWeekWithCurrentDay: Boolean + get() = prefs.getBoolean(START_WEEK_WITH_CURRENT_DAY, false) + set(startWeekWithCurrentDay) = prefs.edit().putBoolean(START_WEEK_WITH_CURRENT_DAY, startWeekWithCurrentDay).apply() var showMidnightSpanningEventsAtTop: Boolean get() = prefs.getBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, true) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index b58e38bb0..f578c213e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -45,7 +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 START_WEEK_WITH_CURRENT_DAY = "start_week_with_current_day" 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" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 8377c3100..41fa3b2ef 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -745,7 +745,7 @@ Týždeň - Start week with the current day + Začať týždeň s aktuálnym dňom Typy udalostí