@@ -30,8 +30,8 @@ import javax.inject.Inject
30
30
31
31
@HiltViewModel
32
32
class SettingsViewModel @Inject constructor(
33
- val mainDelegate : SettingsMainViewModelDelegate ,
34
- val displayDelegate : SettingsDisplayViewModelDelegate ,
33
+ private val mainDelegate : SettingsMainViewModelDelegate ,
34
+ private val displayDelegate : SettingsDisplayViewModelDelegate ,
35
35
private val router : Router ,
36
36
private val settingsMapper : SettingsMapper ,
37
37
private val ratingDelegate : SettingsRatingViewModelDelegate ,
@@ -46,6 +46,8 @@ class SettingsViewModel @Inject constructor(
46
46
47
47
val content: LiveData <List <ViewHolderType >> by lazySuspend { loadContent() }
48
48
val resetScreen: SingleLiveEvent <Unit > = SingleLiveEvent ()
49
+ val keepScreenOnCheckbox: LiveData <Boolean > by additionalDelegate::keepScreenOnCheckbox
50
+ val themeChanged: SingleLiveEvent <Boolean > by mainDelegate::themeChanged
49
51
50
52
init {
51
53
mainDelegate.init (this )
@@ -86,206 +88,47 @@ class SettingsViewModel @Inject constructor(
86
88
viewModelScope.launch { updateContent() }
87
89
}
88
90
89
- // TODO move to delegates
91
+ // TODO move data edit to additional
90
92
fun onBlockClicked (block : SettingsBlock ) {
91
- when (block) {
92
- SettingsBlock .NotificationsCollapse ->
93
- notificationsDelegate.onCollapseClick()
94
- SettingsBlock .DisplayCollapse ->
95
- displayDelegate.onCollapseClick()
96
- SettingsBlock .AdditionalCollapse ->
97
- additionalDelegate.onCollapseClick()
98
- SettingsBlock .BackupCollapse ->
99
- backupDelegate.onCollapseClick()
100
- SettingsBlock .ExportCollapse ->
101
- exportDelegate.onCollapseClick()
102
- SettingsBlock .NotificationsInactivity ->
103
- notificationsDelegate.onInactivityReminderClicked()
104
- SettingsBlock .NotificationsActivity ->
105
- notificationsDelegate.onActivityReminderClicked()
106
- SettingsBlock .DisplayUntrackedIgnoreShort ->
107
- displayDelegate.onIgnoreShortUntrackedClicked()
108
- SettingsBlock .AdditionalIgnoreShort ->
109
- additionalDelegate.onIgnoreShortRecordsClicked()
110
- SettingsBlock .AdditionalShiftStartOfDay ->
111
- additionalDelegate.onStartOfDayClicked()
112
- SettingsBlock .NotificationsInactivityDoNotDisturbStart ->
113
- notificationsDelegate.onInactivityReminderDoNotDisturbStartClicked()
114
- SettingsBlock .NotificationsInactivityDoNotDisturbEnd ->
115
- notificationsDelegate.onInactivityReminderDoNotDisturbEndClicked()
116
- SettingsBlock .NotificationsActivityDoNotDisturbStart ->
117
- notificationsDelegate.onActivityReminderDoNotDisturbStartClicked()
118
- SettingsBlock .NotificationsActivityDoNotDisturbEnd ->
119
- notificationsDelegate.onActivityReminderDoNotDisturbEndClicked()
120
- SettingsBlock .NotificationsSystemSettings ->
121
- notificationsDelegate.onSystemSettingsClicked()
122
- SettingsBlock .DisplayUntrackedRangeStart ->
123
- displayDelegate.onUntrackedRangeStartClicked()
124
- SettingsBlock .DisplayUntrackedRangeEnd ->
125
- displayDelegate.onUntrackedRangeEndClicked()
126
- SettingsBlock .Categories ->
127
- mainDelegate.onEditCategoriesClick()
128
- SettingsBlock .Archive ->
129
- mainDelegate.onArchiveClick()
130
- SettingsBlock .DataEdit ->
131
- mainDelegate.onDataEditClick()
132
- SettingsBlock .RateUs ->
133
- ratingDelegate.onRateClick()
134
- SettingsBlock .Feedback ->
135
- ratingDelegate.onFeedbackClick()
136
- SettingsBlock .Version ->
137
- ratingDelegate.onVersionClick()
138
- SettingsBlock .DebugMenu ->
139
- ratingDelegate.onDebugMenuClick()
140
- SettingsBlock .DisplayCardSize ->
141
- displayDelegate.onChangeCardSizeClick()
142
- SettingsBlock .DisplaySortActivities ->
143
- displayDelegate.onCardOrderManualClick()
144
- SettingsBlock .DisplaySortCategories ->
145
- displayDelegate.onCategoryOrderManualClick()
146
- SettingsBlock .DisplaySortTags ->
147
- displayDelegate.onTagOrderManualClick()
148
- SettingsBlock .AdditionalShiftStartOfDayButton ->
149
- additionalDelegate.onStartOfDaySignClicked()
150
- SettingsBlock .AdditionalAutomatedTracking ->
151
- additionalDelegate.onAutomatedTrackingHelpClick()
152
- SettingsBlock .AllowMultitasking ->
153
- mainDelegate.onAllowMultitaskingClicked()
154
- SettingsBlock .NotificationsShow ->
155
- notificationsDelegate.onShowNotificationsClicked()
156
- SettingsBlock .NotificationsShowControls ->
157
- notificationsDelegate.onShowNotificationsControlsClicked()
158
- SettingsBlock .NotificationsInactivityRecurrent ->
159
- notificationsDelegate.onInactivityReminderRecurrentClicked()
160
- SettingsBlock .NotificationsActivityRecurrent ->
161
- notificationsDelegate.onActivityReminderRecurrentClicked()
162
- SettingsBlock .DisplayUntrackedInRecords ->
163
- displayDelegate.onShowUntrackedInRecordsClicked()
164
- SettingsBlock .DisplayUntrackedInStatistics ->
165
- displayDelegate.onShowUntrackedInStatisticsClicked()
166
- SettingsBlock .DisplayUntrackedRangeCheckbox ->
167
- displayDelegate.onUntrackedRangeClicked()
168
- SettingsBlock .DisplayCalendarView ->
169
- displayDelegate.onShowRecordsCalendarClicked()
170
- SettingsBlock .DisplayCalendarButtonOnRecordsTab ->
171
- displayDelegate.onShowCalendarButtonOnRecordsTabClicked()
172
- SettingsBlock .DisplayReverseOrder ->
173
- displayDelegate.onReverseOrderInCalendarClicked()
174
- SettingsBlock .DisplayShowActivityFilters ->
175
- displayDelegate.onShowActivityFiltersClicked()
176
- SettingsBlock .DisplayEnablePomodoroMode ->
177
- displayDelegate.onEnablePomodoroModeClicked()
178
- SettingsBlock .DisplayEnableRepeatButton ->
179
- displayDelegate.onEnableRepeatButtonClicked()
180
- SettingsBlock .DisplayPomodoroModeActivities ->
181
- displayDelegate.onPomodoroModeActivitiesClicked()
182
- SettingsBlock .DisplayAllowMultipleActivityFilters ->
183
- displayDelegate.onAllowMultipleActivityFiltersClicked()
184
- SettingsBlock .DisplayGoalsOnSeparateTabs ->
185
- displayDelegate.onShowGoalsSeparatelyClicked()
186
- SettingsBlock .DisplayNavBarAtTheBottom ->
187
- displayDelegate.onShowNavBarAtTheBottomClicked()
188
- SettingsBlock .AdditionalKeepScreenOn ->
189
- displayDelegate.onKeepScreenOnClicked()
190
- SettingsBlock .DisplayMilitaryFormat ->
191
- displayDelegate.onUseMilitaryTimeClicked()
192
- SettingsBlock .DisplayMonthDayFormat ->
193
- displayDelegate.onUseMonthDayTimeClicked()
194
- SettingsBlock .DisplayProportionalFormat ->
195
- displayDelegate.onUseProportionalMinutesClicked()
196
- SettingsBlock .DisplayShowSeconds ->
197
- displayDelegate.onShowSecondsClicked()
198
- SettingsBlock .AdditionalShowTagSelection ->
199
- additionalDelegate.onShowRecordTagSelectionClicked()
200
- SettingsBlock .AdditionalCloseAfterOneTag ->
201
- additionalDelegate.onRecordTagSelectionCloseClicked()
202
- SettingsBlock .AdditionalTagSelectionExcludeActivities ->
203
- additionalDelegate.onRecordTagSelectionExcludeActivitiesClicked()
204
- SettingsBlock .AdditionalKeepStatisticsRange ->
205
- additionalDelegate.onKeepStatisticsRangeClicked()
206
- SettingsBlock .AdditionalSendEvents ->
207
- additionalDelegate.onAutomatedTrackingSendEventsClicked()
208
- else -> {
209
- // Do nothing
210
- }
211
- }
93
+ mainDelegate.onBlockClicked(block)
94
+ notificationsDelegate.onBlockClicked(block)
95
+ displayDelegate.onBlockClicked(block)
96
+ additionalDelegate.onBlockClicked(block)
97
+ backupDelegate.onBlockClicked(block)
98
+ exportDelegate.onBlockClicked(block)
99
+ ratingDelegate.onBlockClicked(block)
212
100
}
213
101
214
102
fun onSpinnerPositionSelected (block : SettingsBlock , position : Int ) {
215
- when (block) {
216
- SettingsBlock .DarkMode ->
217
- mainDelegate.onDarkModeSelected(position)
218
- SettingsBlock .Language ->
219
- mainDelegate.onLanguageSelected(position)
220
- SettingsBlock .DisplayDaysInCalendar ->
221
- displayDelegate.onDaysInCalendarSelected(position)
222
- SettingsBlock .DisplayWidgetBackground ->
223
- displayDelegate.onWidgetTransparencySelected(position)
224
- SettingsBlock .DisplaySortActivities ->
225
- displayDelegate.onRecordTypeOrderSelected(position)
226
- SettingsBlock .DisplaySortCategories ->
227
- displayDelegate.onCategoryOrderSelected(position)
228
- SettingsBlock .DisplaySortTags ->
229
- displayDelegate.onTagOrderSelected(position)
230
- SettingsBlock .DisplayRepeatButtonMode ->
231
- additionalDelegate.onRepeatButtonSelected(position)
232
- SettingsBlock .AdditionalFirstDayOfWeek ->
233
- additionalDelegate.onFirstDayOfWeekSelected(position)
234
- else -> {
235
- // Do nothing
236
- }
237
- }
103
+ displayDelegate.onSpinnerPositionSelected(block, position)
104
+ additionalDelegate.onSpinnerPositionSelected(block, position)
105
+ mainDelegate.onSpinnerPositionSelected(block, position)
238
106
}
239
107
240
108
fun onDurationSet (tag : String? , duration : Long ) {
241
- when (tag) {
242
- INACTIVITY_DURATION_DIALOG_TAG ,
243
- ACTIVITY_DURATION_DIALOG_TAG ,
244
- -> notificationsDelegate.onDurationSet(tag, duration)
245
- IGNORE_SHORT_RECORDS_DIALOG_TAG ,
246
- -> additionalDelegate.onDurationSet(tag, duration)
247
- IGNORE_SHORT_UNTRACKED_DIALOG_TAG ,
248
- -> displayDelegate.onDurationSet(tag, duration)
249
- }
109
+ notificationsDelegate.onDurationSet(tag, duration)
110
+ displayDelegate.onDurationSet(tag, duration)
111
+ additionalDelegate.onDurationSet(tag, duration)
250
112
}
251
113
252
114
fun onDurationDisabled (tag : String? ) {
253
- when (tag) {
254
- INACTIVITY_DURATION_DIALOG_TAG ,
255
- ACTIVITY_DURATION_DIALOG_TAG ,
256
- -> notificationsDelegate.onDurationDisabled(tag)
257
- IGNORE_SHORT_RECORDS_DIALOG_TAG ,
258
- -> additionalDelegate.onDurationDisabled(tag)
259
- IGNORE_SHORT_UNTRACKED_DIALOG_TAG ,
260
- -> displayDelegate.onDurationDisabled(tag)
261
- }
115
+ notificationsDelegate.onDurationDisabled(tag)
116
+ displayDelegate.onDurationDisabled(tag)
117
+ additionalDelegate.onDurationDisabled(tag)
262
118
}
263
119
264
120
fun onDateTimeSet (timestamp : Long , tag : String? ) {
265
- when (tag) {
266
- START_OF_DAY_DIALOG_TAG ,
267
- -> additionalDelegate.onDateTimeSet(timestamp, tag)
268
- INACTIVITY_REMINDER_DND_START_DIALOG_TAG ,
269
- INACTIVITY_REMINDER_DND_END_DIALOG_TAG ,
270
- ACTIVITY_REMINDER_DND_START_DIALOG_TAG ,
271
- ACTIVITY_REMINDER_DND_END_DIALOG_TAG ,
272
- -> notificationsDelegate.onDateTimeSet(timestamp, tag)
273
- UNTRACKED_RANGE_START_DIALOG_TAG ,
274
- UNTRACKED_RANGE_END_DIALOG_TAG ,
275
- -> displayDelegate.onDateTimeSet(timestamp, tag)
276
- }
121
+ notificationsDelegate.onDateTimeSet(timestamp, tag)
122
+ displayDelegate.onDateTimeSet(timestamp, tag)
123
+ additionalDelegate.onDateTimeSet(timestamp, tag)
277
124
}
278
125
279
126
fun onTypesSelected (
280
127
typeIds : List <Long >,
281
128
tag : String? ,
282
129
) {
283
- when (tag) {
284
- EXCLUDE_ACTIVITIES_TYPES_SELECTION ,
285
- -> additionalDelegate.onTypesSelected(typeIds)
286
- SELECT_ACTIVITIES_TO_AUTOSTART_POMODORO ,
287
- -> displayDelegate.onTypesSelected(typeIds)
288
- }
130
+ displayDelegate.onTypesSelected(typeIds, tag)
131
+ additionalDelegate.onTypesSelected(typeIds, tag)
289
132
}
290
133
291
134
fun onTabReselected (tab : NavigationTab ? ) {
0 commit comments