package com.jkanetwork.st.calendariodefrases;

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

/**
 * Created by kprkpr on 21/03/17.
 */

public class Config {

    private final String SHARED_PREFS_FILE = "Prefs";
    private final String KEY_HOUR = "Hour";
    private final String KEY_MINUTE = "Minute";
    private final String KEY_NOTIFON = "Notify";
    private final String KEY_PERSISTNOTIFON = "PersistNotify";
    private final String KEY_FIRSTTIME = "FirstTime";

    private Context emContext;


    public Config(Context context){
        emContext = context;
    }


    private SharedPreferences getSettings(){
        return emContext.getSharedPreferences(SHARED_PREFS_FILE, 0);
    }

    public Integer getHour(){
        return getSettings().getInt(KEY_HOUR, 8);
    }
    public Integer getMinute(){
        return getSettings().getInt(KEY_MINUTE, 0);
    }
    public Boolean getNotifOn(){
        return getSettings().getBoolean(KEY_NOTIFON, true);
    }
    public Boolean getPersistNotifOn(){return getSettings().getBoolean(KEY_PERSISTNOTIFON, false);}
    public Boolean getFirstTime(){return getSettings().getBoolean(KEY_FIRSTTIME, true);}


    public void setHour(Integer hour){
        SharedPreferences.Editor editor = getSettings().edit();
        editor.putInt(KEY_HOUR, hour );
        editor.apply();
    }
    public void setMinute(Integer minute){
        SharedPreferences.Editor editor = getSettings().edit();
        editor.putInt(KEY_MINUTE, minute );
        editor.apply();
    }

    public void setNotifOn(Boolean notifon){
        SharedPreferences.Editor editor = getSettings().edit();
        editor.putBoolean(KEY_NOTIFON, notifon );
        editor.apply();
    }

    public void setPersistNotifOn(Boolean notifon){
        SharedPreferences.Editor editor = getSettings().edit();
        editor.putBoolean(KEY_PERSISTNOTIFON, notifon );
        editor.apply();
    }

    public void setFirstTime(Boolean notifon){
        SharedPreferences.Editor editor = getSettings().edit();
        editor.putBoolean(KEY_FIRSTTIME, notifon );
        editor.apply();
    }

}
