Skip to content

Commit

Permalink
refactor: Move SyncSettingsViewModel to it's own file
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Oct 4, 2024
1 parent 993dc00 commit 8151101
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.infomaniak.drive.views.SelectBottomSheetDialog

class SelectIntervalTypeBottomSheetDialog : SelectBottomSheetDialog() {

private val syncSettingsViewModel: SyncSettingsActivity.SyncSettingsViewModel by activityViewModels()
private val syncSettingsViewModel: SyncSettingsViewModel by activityViewModels()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(binding) {
super.onViewCreated(view, savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.infomaniak.drive.views.SelectBottomSheetDialog

class SelectSaveDateBottomSheetDialog : SelectBottomSheetDialog() {

private val syncSettingsViewModel: SyncSettingsActivity.SyncSettingsViewModel by activityViewModels()
private val syncSettingsViewModel: SyncSettingsViewModel by activityViewModels()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(binding) {
super.onViewCreated(view, savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,6 @@ class SyncSettingsActivity : BaseActivity() {
}
}

class SyncSettingsViewModel : ViewModel() {
val customDate = MutableLiveData<Date>()
val saveOldPictures = MutableLiveData<SavePicturesDate>()
val syncIntervalType = MutableLiveData<IntervalType>()
val syncFolder = MutableLiveData<Int?>()
}

private fun trackPhotoSyncEvent(name: String, value: Boolean? = null) {
trackEvent("photoSync", name, value = value?.toFloat())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Infomaniak kDrive - Android
* Copyright (C) 2022-2024 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.drive.ui.menu.settings

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.infomaniak.drive.data.models.SyncSettings.IntervalType
import com.infomaniak.drive.data.models.SyncSettings.SavePicturesDate
import java.util.Date

class SyncSettingsViewModel : ViewModel() {
val customDate = MutableLiveData<Date>()
val saveOldPictures = MutableLiveData<SavePicturesDate>()
val syncIntervalType = MutableLiveData<IntervalType>()
val syncFolder = MutableLiveData<Int?>()

fun init(intervalTypeValue: IntervalType, syncFolderId: Int?) {
syncIntervalType.value = intervalTypeValue
syncFolder.value = syncFolderId
saveOldPictures.value = SavePicturesDate.SINCE_NOW
}
}

0 comments on commit 8151101

Please sign in to comment.