package com.ray650128.gstreamer_demo_app

import android.content.Context
import com.ray650128.gstreamer_demo_app.ui.mainScreen.MainViewModel

/**
 * Shared Preferences 工具類別
 * @author Raymond Yang
 */
object PreferenceUtil {
    private const val MAIN_KEY = "GST_DEMO_APP"
    private const val IS_FIRST_OPEN_KEY = "IS_FIRST_OPEN_KEY"
    private const val LAST_SPLIT_MODE = "LAST_SPLIT_MODE"

    private val sharedPreferences = MyApplication.getAppContext().getSharedPreferences(MAIN_KEY, Context.MODE_PRIVATE)

    var isFirstOpen: Boolean
        get() = sharedPreferences.getBoolean(IS_FIRST_OPEN_KEY, true)
        set(value) = sharedPreferences.edit().putBoolean(IS_FIRST_OPEN_KEY, value).apply()

    var lastSplitMode: Int
        get() = sharedPreferences.getInt(LAST_SPLIT_MODE, Constants.SPLIT_MODE_SINGLE)
        set(value) = sharedPreferences.edit().putInt(LAST_SPLIT_MODE, value).apply()
}