tweaking some code related to starting weekly view with current day

This commit is contained in:
tibbi 2021-10-09 20:47:18 +02:00
parent f0b4a0a029
commit 4cf2f57f44
7 changed files with 21 additions and 20 deletions

View File

@ -63,10 +63,10 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:a74ec200da' implementation 'com.github.SimpleMobileTools:Simple-Commons:ea206806fc'
implementation 'joda-time:joda-time:2.10.3' implementation 'joda-time:joda-time:2.10.3'
implementation 'androidx.multidex:multidex:2.0.1' 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.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation "androidx.print:print:1.0.0" implementation "androidx.print:print:1.0.0"

View File

@ -81,7 +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 private var mStoredStartWeekWithCurrentDay = false
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -145,7 +145,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
if (config.storedView == WEEKLY_VIEW) { if (config.storedView == WEEKLY_VIEW) {
if (mStoredIsSundayFirst != config.isSundayFirst || mStoredUse24HourFormat != config.use24HourFormat if (mStoredIsSundayFirst != config.isSundayFirst || mStoredUse24HourFormat != config.use24HourFormat
|| mStoredMidnightSpan != config.showMidnightSpanningEventsAtTop || mStoredStartWeeklyViewWithCurrentDate != config.startWeeklyViewWithCurrentDate) { || mStoredMidnightSpan != config.showMidnightSpanningEventsAtTop || mStoredStartWeekWithCurrentDay != config.startWeekWithCurrentDay) {
updateViewPager() updateViewPager()
} }
} }
@ -260,7 +260,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
mStoredDimPastEvents = dimPastEvents mStoredDimPastEvents = dimPastEvents
mStoredHighlightWeekends = highlightWeekends mStoredHighlightWeekends = highlightWeekends
mStoredMidnightSpan = showMidnightSpanningEventsAtTop mStoredMidnightSpan = showMidnightSpanningEventsAtTop
mStoredStartWeeklyViewWithCurrentDate = startWeeklyViewWithCurrentDate mStoredStartWeekWithCurrentDay = startWeekWithCurrentDay
} }
mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor() mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor()
mStoredDayCode = Formatter.getTodayCode() mStoredDayCode = Formatter.getTodayCode()
@ -819,7 +819,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
} }
private fun getThisWeekDateTime(): String { private fun getThisWeekDateTime(): String {
return if(! config.startWeeklyViewWithCurrentDate) { return if(! config.startWeekWithCurrentDay) {
val currentOffsetHours = TimeZone.getDefault().rawOffset / 1000 / 60 / 60 val currentOffsetHours = TimeZone.getDefault().rawOffset / 1000 / 60 / 60
// not great, not terrible // not great, not terrible

View File

@ -57,8 +57,8 @@ class SettingsActivity : SimpleActivity() {
setupShowGrid() setupShowGrid()
setupWeeklyStart() setupWeeklyStart()
setupMidnightSpanEvents() setupMidnightSpanEvents()
setupAllowCustomiseDayCount() setupAllowCustomizeDayCount()
setupStartWeeklyViewWithCurrentDate() setupStartWeekWithCurrentDay()
setupVibrate() setupVibrate()
setupReminderSound() setupReminderSound()
setupReminderAudioStream() 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.isChecked = config.allowCustomizeDayCount
settings_allow_customize_day_count_holder.setOnClickListener { settings_allow_customize_day_count_holder.setOnClickListener {
settings_allow_customize_day_count.toggle() settings_allow_customize_day_count.toggle()
@ -359,10 +359,11 @@ class SettingsActivity : SimpleActivity() {
} }
} }
private fun setupStartWeeklyViewWithCurrentDate() { private fun setupStartWeekWithCurrentDay() {
settings_start_weekly_view_with_current_date.isChecked = config.startWeeklyViewWithCurrentDate settings_start_week_with_current_day.isChecked = config.startWeekWithCurrentDay
settings_start_weekly_view_with_current_date.setOnClickListener { settings_start_week_with_current_day_holder.setOnClickListener {
config.startWeeklyViewWithCurrentDate = settings_start_weekly_view_with_current_date.isChecked settings_start_week_with_current_day.toggle()
config.startWeekWithCurrentDay = settings_start_week_with_current_day.isChecked
} }
} }

View File

@ -23,9 +23,9 @@ 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 var startWeekWithCurrentDay: Boolean
get() = prefs.getBoolean(START_WEEKLY_VIEW_WITH_CURRENT_DATE, false) get() = prefs.getBoolean(START_WEEK_WITH_CURRENT_DAY, false)
set(startWeeklyViewWithCurrentDate) = prefs.edit().putBoolean(START_WEEKLY_VIEW_WITH_CURRENT_DATE, startWeeklyViewWithCurrentDate).apply() set(startWeekWithCurrentDay) = prefs.edit().putBoolean(START_WEEK_WITH_CURRENT_DAY, startWeekWithCurrentDay).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)

View File

@ -45,7 +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 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 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

@ -745,7 +745,7 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/settings_start_weekly_view_with_current_date_holder" android:id="@+id/settings_start_week_with_current_day_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin" android:layout_marginTop="@dimen/medium_margin"
@ -756,7 +756,7 @@
android:paddingBottom="@dimen/activity_margin"> android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat <com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_start_weekly_view_with_current_date" android:id="@+id/settings_start_week_with_current_day"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@null" android:background="@null"

View File

@ -135,7 +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> <string name="start_week_with_current_day">Začať týždeň s aktuálnym dňom</string>
<!-- Event types --> <!-- Event types -->
<string name="event_types">Typy udalostí</string> <string name="event_types">Typy udalostí</string>