diff --git a/shared/src/androidMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt b/shared/src/androidMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt index e69de29bb..8c2f7b4ed 100644 --- a/shared/src/androidMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt +++ b/shared/src/androidMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.di.settings + +import android.content.Context +import androidx.preference.PreferenceManager +import com.russhwolf.settings.Settings +import com.russhwolf.settings.SharedPreferencesSettings +import org.koin.core.annotation.Singleton + +/** + * Settings for Android based on SharedPreferences + */ +@Singleton +fun provideSettings(context: Context): Settings = SharedPreferencesSettings( + PreferenceManager.getDefaultSharedPreferences(context) +) diff --git a/shared/src/commonMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt b/shared/src/commonMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt index e69de29bb..698b29f29 100644 --- a/shared/src/commonMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt +++ b/shared/src/commonMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.di.settings + +import org.koin.core.annotation.ComponentScan +import org.koin.core.annotation.Configuration +import org.koin.core.annotation.Module + +/** + * Settings module to access key-value pairs across different platforms. + * See individual platform packages for the declarations included in this module. + */ +@Module +@ComponentScan +@Configuration +class SettingsModule diff --git a/shared/src/iosMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt b/shared/src/iosMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt index e69de29bb..b5f7ef3e3 100644 --- a/shared/src/iosMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt +++ b/shared/src/iosMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.di.settings + +import com.russhwolf.settings.NSUserDefaultsSettings +import com.russhwolf.settings.Settings +import org.koin.core.annotation.Singleton +import platform.Foundation.NSUserDefaults + +/** + * Settings for iOS based on UserDefaultsSettings + */ +@Singleton +fun provideSettings(): Settings = NSUserDefaultsSettings(NSUserDefaults()) diff --git a/shared/src/jvmMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt b/shared/src/jvmMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt index e69de29bb..82a7d426f 100644 --- a/shared/src/jvmMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt +++ b/shared/src/jvmMain/kotlin/net/newpipe/app/di/settings/SettingsModule.kt @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.di.settings + +import com.russhwolf.settings.PreferencesSettings +import com.russhwolf.settings.Settings +import java.util.prefs.Preferences +import org.koin.core.annotation.Singleton + +/** + * Settings for JVM devices based on Java Preferences + */ +@Singleton +fun provideSettings(): Settings = PreferencesSettings(Preferences.userRoot())