package com.ledgrab.android

import android.content.Context

/**
 * Thin SharedPreferences wrapper for the boot-autostart toggle.
 *
 * Default is `true`: [BootReceiver] still bails out when the device
 * isn't rooted, so a true default is safe — it only takes effect on
 * boxes where we can actually honor it silently.
 */
class AutostartPrefs(context: Context) {

    private val prefs = context.applicationContext
        .getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)

    var isEnabled: Boolean
        get() = prefs.getBoolean(KEY_ENABLED, DEFAULT_ENABLED)
        set(value) { prefs.edit().putBoolean(KEY_ENABLED, value).apply() }

    companion object {
        private const val PREFS_NAME = "ledgrab_autostart"
        private const val KEY_ENABLED = "autostart_enabled"
        private const val DEFAULT_ENABLED = true
    }
}
