33 lines
949 B
Kotlin
33 lines
949 B
Kotlin
package com.groove.audio
|
|
|
|
import android.content.Context
|
|
import androidx.media3.common.util.UnstableApi
|
|
|
|
@UnstableApi
|
|
class AppSettings(private val context: Context) {
|
|
private val prefs = context.getSharedPreferences("groove", Context.MODE_PRIVATE)
|
|
|
|
var host: String
|
|
get() = prefs.getString("host", "192.168.178.100") ?: "192.168.178.100"
|
|
set(value) {
|
|
prefs.edit().putString("host", value).apply()
|
|
}
|
|
|
|
var password: String
|
|
get() = prefs.getString("password", "groove_listen") ?: "groove_listen"
|
|
set(value) {
|
|
prefs.edit().putString("password", value).apply()
|
|
}
|
|
|
|
companion object {
|
|
@Volatile
|
|
private var instance: AppSettings? = null
|
|
|
|
fun getInstance(context: Context): AppSettings {
|
|
return instance ?: synchronized(this) {
|
|
instance ?: AppSettings(context).also { instance = it }
|
|
}
|
|
}
|
|
}
|
|
}
|