Commit b29df00
Respect system "First day of week" setting in week calculations (#2352)
* Respect system "first day of week" setting
The first day of the week was derived solely from the language/region
locale via WeekFields.of(Locale.getDefault()).firstDayOfWeek. This
ignored Android 13+'s "Regional preferences -> First day of week"
system setting, so e.g. an en-US device with the setting set to Monday
still showed Sunday as the first day.
Use androidx LocalePreferences.getFirstDayOfWeek(), which reads that
setting through the locale's "-u-fw-" unicode extension and falls back
to the locale's default when unset. This is applied to the recurrence
weekday order, the week calendar view, and week-number grouping.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyppcLmiTZZ4xMedBYoysx
* Replace isLocalizedWeekstartMonday with ordered weekday list
isLocalizedWeekstartMonday() was only used to order the recurrence
weekday buttons, and it collapsed the first day of the week to a
Monday/Sunday choice. Replace it with getLocalizedDaysOfWeek(), which
returns the seven days ordered from the device's first day of the week,
so any first day (e.g. Saturday) is honoured. The recur card maps this
to ical4j WeekDay via a small reusable helper.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyppcLmiTZZ4xMedBYoysx
* Make DatePicker respect system first day of week
Material3's DatePicker and DateRangePicker derive their first day of the
week from WeekFields.of(locale), which only considers the language/region
of the locale and ignores the "Regional preferences -> First day of week"
system setting (the locale's "-u-fw-" unicode extension). The composables
expose no way to set the first day of the week directly, and the locale is
baked into the picker state at rememberDatePickerState() time via the
active LocalConfiguration.
Add DateTimeUtils.getLocaleForLocalizedFirstDayOfWeek(), which returns a
locale whose region makes WeekFields.of(...) resolve to the device's
first day of the week (getLocalizedFirstDayOfWeek()) while keeping the
language so month/weekday names are unchanged. Create the picker states
under a CompositionLocalProvider that supplies this locale so the
calendars start on the correct day.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyppcLmiTZZ4xMedBYoysx
* Use DatePickerState locale parameter instead of config override
Material3 exposes an explicit `locale` parameter via the DatePickerState
and DateRangePickerState factory functions. Use it to pass the
first-day-of-week-aware locale directly, replacing the more verbose
CompositionLocalProvider workaround. Note that the underlying library
still derives the first day of the week from WeekFields.of(locale), so
the region-adjusting getLocaleForLocalizedFirstDayOfWeek() is still
required.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyppcLmiTZZ4xMedBYoysx
* Document DatePicker first-day-of-week limitation
Material3's DatePicker derives its first day of the week from
WeekFields.of(locale), which can only ever yield a day that some region
uses (Monday, Friday, Saturday or Sunday). Tuesday/Wednesday/Thursday
cannot be represented, so the workaround falls back to the locale
default for those. Make this explicit in the documentation so it is not
mistaken for a bug.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyppcLmiTZZ4xMedBYoysx
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 96399a5 commit b29df00
7 files changed
Lines changed: 234 additions & 35 deletions
File tree
- app/src
- androidTest/java/at/techbee/jtx/util
- main/java/at/techbee/jtx
- database/relations
- ui
- detail
- list
- reusable/dialogs
- util
Lines changed: 104 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
24 | 35 | | |
25 | 36 | | |
26 | | - | |
| 37 | + | |
27 | 38 | | |
28 | | - | |
| 39 | + | |
29 | 40 | | |
30 | 41 | | |
31 | 42 | | |
32 | | - | |
| 43 | + | |
33 | 44 | | |
34 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
35 | 133 | | |
36 | 134 | | |
37 | | - | |
| 135 | + | |
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
197 | | - | |
| 196 | + | |
198 | 197 | | |
199 | 198 | | |
200 | 199 | | |
| |||
229 | 228 | | |
230 | 229 | | |
231 | 230 | | |
232 | | - | |
| 231 | + | |
233 | 232 | | |
234 | 233 | | |
235 | 234 | | |
| |||
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
83 | 97 | | |
84 | 98 | | |
85 | 99 | | |
| |||
128 | 142 | | |
129 | 143 | | |
130 | 144 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 145 | + | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
Lines changed: 21 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
117 | 125 | | |
118 | | - | |
119 | | - | |
| 126 | + | |
| 127 | + | |
120 | 128 | | |
121 | 129 | | |
122 | 130 | | |
| |||
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
46 | 57 | | |
47 | 58 | | |
48 | 59 | | |
| |||
0 commit comments