package com.fn.useries.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.stm.asset.base.StmApplication;

/**
 * 类名称：U8Property
 * 类描述：U8本地存储信息
 * 创建人：story
 * 创建时间：2021-12-17 14:02
 */
public class U8Property {

    private static final String PREFERENCES_SYSTEM = "preferences_u8";
    private static final String KEY_SESSION = "_session";
    private static final String KEY_FLAG = "_flag";
    private static final String KEY_STATE = "_state";
    private static final String KEY_SOFTWARE_SOUND = "_software_sound";

    static public int getSessionState(){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        return spf.getInt(KEY_SESSION, 0);
    }

    static public void saveSessionState(int state){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = spf.edit();
        editor.putInt(KEY_SESSION, state);
        editor.apply();
    }

    static public int getFlagState(){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        int state = spf.getInt(KEY_FLAG, 0);
        return state;
    }

    static public void saveFlagState(int state){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = spf.edit();
        editor.putInt(KEY_FLAG, state);
        editor.apply();
    }

    static public int getVeeperState(){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        return spf.getInt(KEY_STATE, 0);
    }

    static public void saveBeeperState(int state){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = spf.edit();
        editor.putInt(KEY_STATE, state);
        editor.apply();
    }

    static public int getSoftSound(){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf =context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        return spf.getInt(KEY_SOFTWARE_SOUND, 1);
    }

    static public void saveSoftSound(int state){
        Context context = StmApplication.getInstance().getApplicationContext();
        SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = spf.edit();
        editor.putInt(KEY_SOFTWARE_SOUND, state);
        editor.apply();
    }







}
