package xyz.myachin.saveto.settings

import android.content.Context
import android.content.SharedPreferences
import androidx.preference.PreferenceManager

object Settings {
    private const val use_downloader = "use_downloader"
    private const val text_length = "text_file_name_length"
    private lateinit var prefs: SharedPreferences

    fun setup(context: Context) {
        prefs = PreferenceManager.getDefaultSharedPreferences(context)
    }

    var textLength: Int
        get() = prefs.getInt(text_length, 5)
        set(value) {
            val editor = prefs.edit()
            editor.putInt(text_length, value)
            editor.apply()
        }

    var useDownloader: Boolean
        get() {
            return prefs.getBoolean(use_downloader, true)
        }
        set(value) {
            val editor = prefs.edit()
            editor.putBoolean(use_downloader, value)
            editor.apply()
        }
}
