shared: Add missing settings implementation
This seems to have gotten missed during moving settings to different modules Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
0f2bbf11ff
commit
01e3742521
4 changed files with 73 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||||
|
* 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)
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||||
|
* 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
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||||
|
* 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())
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||||
|
* 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())
|
||||||
Loading…
Add table
Add a link
Reference in a new issue