diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt index 60d0ece9..6c0fbdf5 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt @@ -57,6 +57,7 @@ class KoinInstrumentationTestApp : App() { iconManager = get(), storageBackup = get(), pluginManager = get(), + fileSelectionManager = get(), ) ) currentRestoreViewModel!! diff --git a/app/src/main/java/com/stevesoltys/seedvault/App.kt b/app/src/main/java/com/stevesoltys/seedvault/App.kt index 9389eb05..0189cbe7 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/App.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/App.kt @@ -28,8 +28,8 @@ import com.stevesoltys.seedvault.metadata.metadataModule import com.stevesoltys.seedvault.plugins.StoragePluginManager import com.stevesoltys.seedvault.plugins.saf.storagePluginModuleSaf import com.stevesoltys.seedvault.plugins.webdav.storagePluginModuleWebDav -import com.stevesoltys.seedvault.restore.RestoreViewModel import com.stevesoltys.seedvault.restore.install.installModule +import com.stevesoltys.seedvault.restore.restoreUiModule import com.stevesoltys.seedvault.settings.AppListRetriever import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.settings.SettingsViewModel @@ -37,7 +37,6 @@ import com.stevesoltys.seedvault.storage.storageModule import com.stevesoltys.seedvault.transport.TRANSPORT_ID import com.stevesoltys.seedvault.transport.backup.backupModule import com.stevesoltys.seedvault.transport.restore.restoreModule -import com.stevesoltys.seedvault.ui.files.FileSelectionViewModel import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.recoverycode.RecoveryCodeViewModel import com.stevesoltys.seedvault.ui.storage.BackupStorageViewModel @@ -97,20 +96,6 @@ open class App : Application() { ) } viewModel { RestoreStorageViewModel(this@App, get(), get(), get(), get()) } - viewModel { - RestoreViewModel( - app = this@App, - settingsManager = get(), - keyManager = get(), - backupManager = get(), - restoreCoordinator = get(), - apkRestore = get(), - iconManager = get(), - storageBackup = get(), - pluginManager = get(), - ) - } - viewModel { FileSelectionViewModel(this@App, get()) } } override fun onCreate() { @@ -155,6 +140,7 @@ open class App : Application() { installModule, storageModule, workerModule, + restoreUiModule, appModule ) diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreUiModule.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreUiModule.kt new file mode 100644 index 00000000..41abcddf --- /dev/null +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreUiModule.kt @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2020 The Calyx Institute + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.stevesoltys.seedvault.restore + +import com.stevesoltys.seedvault.ui.files.FileSelectionViewModel +import org.calyxos.backup.storage.ui.restore.FileSelectionManager +import org.koin.android.ext.koin.androidApplication +import org.koin.androidx.viewmodel.dsl.viewModel +import org.koin.dsl.module + +val restoreUiModule = module { + single { FileSelectionManager() } + viewModel { + RestoreViewModel( + app = androidApplication(), + settingsManager = get(), + keyManager = get(), + backupManager = get(), + restoreCoordinator = get(), + apkRestore = get(), + iconManager = get(), + storageBackup = get(), + pluginManager = get(), + fileSelectionManager = get(), + ) + } + viewModel { FileSelectionViewModel(androidApplication(), get()) } +} diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt index 6a838828..8e7989f5 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt @@ -64,6 +64,7 @@ internal class RestoreViewModel( private val iconManager: IconManager, storageBackup: StorageBackup, pluginManager: StoragePluginManager, + override val fileSelectionManager: FileSelectionManager, private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO, ) : RequireProvisioningViewModel(app, settingsManager, keyManager, pluginManager), RestorableBackupClickListener, SnapshotViewModel { @@ -99,8 +100,6 @@ internal class RestoreViewModel( get() = appDataRestoreManager.restoreBackupResult override val snapshots = storageBackup.getBackupSnapshots().asLiveData(ioDispatcher) - override val fileSelectionManager: FileSelectionManager - get() = TODO("Not yet implemented") internal fun loadRestoreSets() = viewModelScope.launch(ioDispatcher) { val backups = restoreCoordinator.getAvailableMetadata()?.mapNotNull { (token, metadata) -> diff --git a/app/src/main/java/com/stevesoltys/seedvault/storage/Services.kt b/app/src/main/java/com/stevesoltys/seedvault/storage/Services.kt index ae32f4b2..8675483a 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/storage/Services.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/storage/Services.kt @@ -18,6 +18,7 @@ import org.calyxos.backup.storage.backup.BackupService import org.calyxos.backup.storage.backup.NotificationBackupObserver import org.calyxos.backup.storage.restore.NotificationRestoreObserver import org.calyxos.backup.storage.restore.RestoreService +import org.calyxos.backup.storage.ui.restore.FileSelectionManager import org.koin.android.ext.android.inject /* @@ -70,6 +71,7 @@ internal class StorageBackupService : BackupService() { internal class StorageRestoreService : RestoreService() { override val storageBackup: StorageBackup by inject() + override val fileSelectionManager: FileSelectionManager by inject() // use lazy delegate because context isn't available during construction time override val restoreObserver: RestoreObserver by lazy { diff --git a/app/src/main/res/layout/fragment_restore_app_selection.xml b/app/src/main/res/layout/fragment_restore_app_selection.xml index 07f215d3..0d627ed8 100644 --- a/app/src/main/res/layout/fragment_restore_app_selection.xml +++ b/app/src/main/res/layout/fragment_restore_app_selection.xml @@ -108,10 +108,6 @@ android:layout_marginTop="0dp" android:layout_marginEnd="0dp" app:layout_behavior="@string/appbar_scrolling_view_behavior" - app:layout_constraintBottom_toTopOf="@+id/button" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/backupNameView" tools:listitem="@layout/list_item_app_status" />