package com.omixlab.lckcontrol.cortex

import android.content.Context
import android.content.SharedPreferences
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class CortexPreferences @Inject constructor(
    @ApplicationContext context: Context,
) {
    private val prefs: SharedPreferences =
        context.getSharedPreferences("lck_cortex_prefs", Context.MODE_PRIVATE)

    fun isEnabled(): Boolean = prefs.getBoolean(KEY_ENABLED, false)

    fun setEnabled(enabled: Boolean) {
        prefs.edit().putBoolean(KEY_ENABLED, enabled).apply()
    }

    fun getMaxMinutes(): Int = prefs.getInt(KEY_MAX_MINUTES, 10)

    fun setMaxMinutes(minutes: Int) {
        prefs.edit().putInt(KEY_MAX_MINUTES, minutes).apply()
    }

    private companion object {
        const val KEY_ENABLED = "cortex_enabled"
        const val KEY_MAX_MINUTES = "cortex_max_minutes"
    }
}
