package com.wdkl.lcd_board.settings;

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


public class SettingConfig {


    private static final String SP_NAME = "SP_BED_FUNCTION";

    //白昼设置白天的初始时间设置
    private static final String KEY_SP_INITIAL_DAY_TIME = "KEY_SP_INITIAL_DAY_TIME";
    private static final String initial_day_time = "07:00";
    private static final String KEY_SP_INITIAL_DAY_TIME_LOCATION = "KEY_SP_INITIAL_DAY_TIME_LOCATION";
    private static final String initial_day_time_location = "12";


    //白昼设置白天的结束时间设置
    private static final String KEY_SP_END_OF_DAY = "KEY_SP_END_OF_DAY";
    private static final String end_of_day = "19:00";
    //白昼设置白天的结束时间设置
    private static final String KEY_SP_END_OF_DAY_LOCATION = "KEY_SP_END_OF_DAY_LOCATION";
    private static final String end_of_day_location = "38";


    //分机白天亮度
    private static final String KEY_SP_EXTENSION_DAYTIME_BRIGHTNESS = "KEY_SP_EXTENSION_DAYTIME_BRIGHTNESS";
    private static final int extension_daytime_brightness = 80;
    //分机晚上亮度
    private static final String KEY_SP_EXTENSION_NIGHT_BRIGHTNESS = "KEY_SP_EXTENSION_NIGHT_BRIGHTNESS";
    private static final int extension_night_brightness = 50;

    //分机LED白天亮度
    private static final String KEY_SP_EXTENSION_DAYTIME_LED_BRIGHTNESS = "KEY_SP_EXTENSION_DAYTIME_LED_BRIGHTNESS";
    private static final int extension_daytime_led_brightness = 80;
    //分机LED晚上亮度
    private static final String KEY_SP_EXTENSION_NIGHT_LED_BRIGHTNESS = "KEY_SP_EXTENSION_NIGHT_LED_BRIGHTNESS";
    private static final int extension_night_led_brightness = 50;

    //分机白天系统音量
    private static final String KEY_SP_EXTENSION_DAYTIME_SYSTEM_VOLUME = "KEY_SP_EXTENSION_DAYTIME_SYSTEM_VOLUME";
    private static final int extension_daytime_system_volume = 100;
    //分机晚上系统音量
    private static final String KEY_SP_EXTENSION_NIGHT_SYSTEM_VOLUME = "KEY_SP_EXTENSION_NIGHT_SYSTEM_VOLUME";
    private static final int extension_night_system_volume = 70;

    //分机手柄录入音量
    private static final String KEY_SP_THE_EXTENSION_HANDLR_RECORDS_THE_VOLUME = "KEY_SP_THE_EXTENSION_HANDLR_RECORDS_THE_VOLUME";
    private static final int the_extension_handle_records_the_volume = 50;

    //分机通话音量
    private static final String KEY_SP_EXTENSION_CALL_VOLUME = "KEY_SP_EXTENSION_CALL_VOLUME";
    private static final int extension_call_volume = 100;

    //呼叫超时时间
    private static final String KEY_SP_SIP_OVERTIME = "KEY_SP_SIP_OVERTIME";
    private static final int sip_over_time = 30;

    //息屏超时时间
    private static final String KEY_SP_SLEEP_TIME = "KEY_SP_SLEEP_TIME";
    private static final int sleep_time = 30;

    //传统转换盒白天系统音量
    private static final String KEY_SP_CONVERSION_BOX_DAYTIME_SYSTEM_VOLUME = "KEY_SP_CONVERSION_BOX_DAYTIME_SYSTEM_VOLUME";
    private static final int conversion_box_daytime_system_volume = 80;

    //传统转换盒白天系统音量
    private static final String KEY_SP_CONVERSION_BOX_NIGHT_SYSTEM_VOLUME = "KEY_SP_CONVERSION_BOX_NIGHT_SYSTEM_VOLUME";
    private static final int conversion_box_night_system_volume = 50;

    //网络异常重启次数
    private static final String KEY_SP_NET_ERR_RESET_COUNT = "KEY_SP_NET_ERR_RESET_COUNT";

    /**
     * 获取分机白天亮度
     *
     * @return
     */
    public static int getExtensionDaytimeBrightness(Context context) {
        return getSP(context).getInt(KEY_SP_EXTENSION_DAYTIME_BRIGHTNESS, extension_daytime_brightness);
    }

    /**
     * 设置分机白天亮度
     *
     * @param value
     */
    public static void setExtensionDaytimeBrightness(Context context, int value) {
        getEditor(context).putInt(KEY_SP_EXTENSION_DAYTIME_BRIGHTNESS, value).apply();
    }

    /**
     * 获取分机晚上亮度
     *
     * @return
     */
    public static int getExtensionNightBrightness(Context context) {
        return getSP(context).getInt(KEY_SP_EXTENSION_NIGHT_BRIGHTNESS, extension_night_brightness);
    }

    /**
     * 设置分机晚上亮度
     *
     * @param value
     */
    public static void setExtensionNightBrightness(Context context, int value) {
        getEditor(context).putInt(KEY_SP_EXTENSION_NIGHT_BRIGHTNESS, value).apply();
    }

    /**
     * 获取分机LED白天亮度
     *
     * @return
     */
    public static int getExtensionDaytimeLEDBrightness(Context context) {
        return getSP(context).getInt(KEY_SP_EXTENSION_DAYTIME_LED_BRIGHTNESS, extension_daytime_led_brightness);
    }

    /**
     * 设置分机LED白天亮度
     *
     * @param value
     */
    public static void setExtensionDaytimeLEDBrightness(Context context, int value) {
        getEditor(context).putInt(KEY_SP_EXTENSION_DAYTIME_LED_BRIGHTNESS, value).apply();
    }

    /**
     * 获取分机LED晚上亮度
     *
     * @return
     */
    public static int getExtensionNightLEDBrightness(Context context) {
        return getSP(context).getInt(KEY_SP_EXTENSION_NIGHT_LED_BRIGHTNESS, extension_night_led_brightness);
    }

    /**
     * 设置分机LED晚上亮度
     *
     * @param value
     */
    public static void setExtensionNightLEDBrightness(Context context, int value) {
        getEditor(context).putInt(KEY_SP_EXTENSION_NIGHT_LED_BRIGHTNESS, value).apply();
    }


    /**
     * 获取分机白天系统音量
     *
     * @return
     */
    public static int getExtensionDaytimeSystemVolume(Context context) {
        return getSP(context).getInt(KEY_SP_EXTENSION_DAYTIME_SYSTEM_VOLUME, extension_daytime_system_volume);
    }

    /**
     * 设置分机白天系统音量
     *
     * @param value
     */
    public static void setExtensionDaytimeSystemVolume(Context context, int value) {
        getEditor(context).putInt(KEY_SP_EXTENSION_DAYTIME_SYSTEM_VOLUME, value).apply();
    }

    /**
     * 获取分机晚上系统音量
     *
     * @return
     */
    public static int getExtensionNightSystemVolume(Context context) {
        return getSP(context).getInt(KEY_SP_EXTENSION_NIGHT_SYSTEM_VOLUME, extension_night_system_volume);
    }

    /**
     * 设置分机晚上系统音量
     *
     * @param value
     */
    public static void setExtensionNightSystemVolume(Context context, int value) {
        getEditor(context).putInt(KEY_SP_EXTENSION_NIGHT_SYSTEM_VOLUME, value).apply();
    }


    public static int getConversionBoxDaytimeSystemVolume(Context context) {
        return getSP(context).getInt(KEY_SP_CONVERSION_BOX_DAYTIME_SYSTEM_VOLUME, conversion_box_daytime_system_volume);
    }

    public static void setConversionBoxDaytimeSystemVolume(Context context, int value) {
        getEditor(context).putInt(KEY_SP_CONVERSION_BOX_DAYTIME_SYSTEM_VOLUME, value).apply();
    }

    public static int getConversionBoxNightSystemVolume(Context context) {
        return getSP(context).getInt(KEY_SP_CONVERSION_BOX_NIGHT_SYSTEM_VOLUME, conversion_box_night_system_volume);
    }

    public static void setConversionBoxNightSystemVolume(Context context, int value) {
        getEditor(context).putInt(KEY_SP_CONVERSION_BOX_NIGHT_SYSTEM_VOLUME, value).apply();
    }


    /**
     * 获取分机手柄录入音量
     *
     * @return
     */
    public static int getTheExtensionHandleRecordsTheVolume(Context context) {
        return getSP(context).getInt(KEY_SP_THE_EXTENSION_HANDLR_RECORDS_THE_VOLUME, the_extension_handle_records_the_volume);
    }

    /**
     * 设置分机手柄录入音量
     *
     * @param value
     */
    public static void setTheExtensionHandleRecordsTheVolume(Context context, int value) {
        getEditor(context).putInt(KEY_SP_THE_EXTENSION_HANDLR_RECORDS_THE_VOLUME, value).apply();
    }


    /**
     * 获取分机通话音量
     *
     * @return
     */
    public static int getExtensionCallVolume(Context context) {
        return getSP(context).getInt(KEY_SP_EXTENSION_CALL_VOLUME, extension_call_volume);
    }

    /**
     * 设置分机通话音量
     *
     * @param value
     */
    public static void setExtensionCallVolume(Context context, int value) {
        getEditor(context).putInt(KEY_SP_EXTENSION_CALL_VOLUME, value).apply();
    }


    /**
     * 获取白昼设置白天的初始时间
     *
     * @return
     */
    public static String getInitialDayTime(Context context) {
        return getSP(context).getString(KEY_SP_INITIAL_DAY_TIME, initial_day_time);
    }

    /**
     * 设置白昼白天的初始时间
     *
     * @param value
     */
    public static void setInitialDayTime(Context context, String value) {
        getEditor(context).putString(KEY_SP_INITIAL_DAY_TIME, value).apply();
    }

    /**
     * 获取白昼设置白天的初始时间位置
     *
     * @return
     */
    public static String getInitialDayTimeLocation(Context context) {
        return getSP(context).getString(KEY_SP_INITIAL_DAY_TIME_LOCATION, initial_day_time_location);
    }

    /**
     * 设置白昼白天的初始时间位置
     *
     * @param value
     */
    public static void setInitialDayTimeLocation(Context context, String value) {
        getEditor(context).putString(KEY_SP_INITIAL_DAY_TIME_LOCATION, value).apply();
    }



    /**
     * 设置白昼白天的结束时间
     *
     * @param value
     */
    public static void setEndOfDay(Context context, String value) {
        getEditor(context).putString(KEY_SP_END_OF_DAY, value).apply();
    }

    /**
     * 获取白昼设置白天的结束时间
     *
     * @return
     */
    public static String getEndOfDay(Context context) {
        return getSP(context).getString(KEY_SP_END_OF_DAY, end_of_day);
    }

    /**
     * 设置白昼白天的结束时间位置
     *
     * @param value
     */
    public static void setEndOfDayLocation(Context context, String value) {
        getEditor(context).putString(KEY_SP_END_OF_DAY_LOCATION, value).apply();
    }

    /**
     * 获取白昼设置白天的结束时间位置
     *
     * @return
     */
    public static String getEndOfDayLocation(Context context) {
        return getSP(context).getString(KEY_SP_END_OF_DAY_LOCATION, end_of_day_location);
    }

    /**
     * 设置呼叫超时时间
     *
     * @param value
     */
    public static void setSipOverTime(Context context, int value) {
        getEditor(context).putInt(KEY_SP_SIP_OVERTIME, value).apply();
    }

    /**
     * 获取呼叫超时时间
     *
     * @return
     */
    public static int getSipOverTime(Context context) {
        return getSP(context).getInt(KEY_SP_SIP_OVERTIME, sip_over_time);
    }

    /**
     * 设置息屏时间
     *
     * @param value
     */
    public static void setSleepTime(Context context, int value) {
        getEditor(context).putInt(KEY_SP_SLEEP_TIME, value).apply();
    }

    /**
     * 获取息屏时间
     *
     * @return
     */
    public static int getSleepTime(Context context) {
        return getSP(context).getInt(KEY_SP_SLEEP_TIME, sleep_time);
    }

    /**
     * 获取网络异常重启次数
     *
     * @return
     */
    public static int getNetErrResetCount(Context context) {
        return getSP(context).getInt(KEY_SP_NET_ERR_RESET_COUNT, 0);
    }

    /**
     * 设置网络异常重启次数
     *
     * @param value
     */
    public static void setNetErrResetCount(Context context, int value) {
        getEditor(context).putInt(KEY_SP_NET_ERR_RESET_COUNT, value).apply();
    }


    private static SharedPreferences getSP(Context context) {
        return context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    }

    private static SharedPreferences.Editor getEditor(Context context) {
        return getSP(context).edit();
    }


}
