package w.soulofpluto.posstock;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

 /*
  Create by Ramesh Babu
 */

public class PreferenceManager {
    public static final String KEY_USER_ID      = "user_id";
    public static final String KEY_PASSWORD     = "password";
    public static final String KEY_EMAIL        = "email";
    public static final String CUST_TOKEN       = "CUSTOMER_TOKEN";
    public static final String STORE_ID         = "store_id";
    public static final String FIRST_NAME       = "first_name";
    public static final String LAST_NAME        = "last_name";
    public static final String MODULE           = "Module";
    public static final String PREFIX           = "ds_prefix";
    public static final String KEY_LOGGED       = "is_logged";
    public static final String ID               = "ID";
    public static final String BLUETOOTH        = "bluetooth";
    public static final String STORENAME        = "storeName";
    public static final String KEY_USER_LOGIN   = "userlogin";
    public static final String APP_SHARED_PREFS = PreferenceManager.class.getSimpleName();
    public static SharedPreferences _sharedPrefs;
    public static SharedPreferences.Editor _prefsEditor;

    @SuppressWarnings("static-access")
    public PreferenceManager(Context context){
        _sharedPrefs = context.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
        _prefsEditor = _sharedPrefs.edit();
    }
    public static PreferenceManager getInstance(){
        return (PreferenceManager) _sharedPrefs;
    }
    public void delete(){
        _prefsEditor.remove(KEY_USER_ID);
        _prefsEditor.apply();
    }
    public void setKeyUserLogin(String userLogin){
        _prefsEditor.putString(KEY_USER_LOGIN,userLogin);
        _prefsEditor.apply();
    }

    public String getKeyUserLogin(){
        return _sharedPrefs.getString(KEY_USER_LOGIN,"");
    }


    public void setFirstName(String firstName){
        _prefsEditor.putString(FIRST_NAME,firstName);
        _prefsEditor.apply();
    }
    public String getFirstName(){
        return _sharedPrefs.getString(FIRST_NAME,"");
    }
    public void setModule(String Mod){
        _prefsEditor.putString(MODULE,Mod);
        _prefsEditor.apply();
    }
    public String getModule(){
        return _sharedPrefs.getString(MODULE,"");

    } public void setBLUETOOTH(String Mod){
        _prefsEditor.putString(BLUETOOTH,Mod);
        _prefsEditor.apply();
    }
    public String getBLUETOOTH(){
        return _sharedPrefs.getString(BLUETOOTH,"");
    }
    public void setLastName(String lastName){
        _prefsEditor.putString(LAST_NAME,lastName);
        _prefsEditor.apply();
    }
    public String getLastName(){
        return _sharedPrefs.getString(LAST_NAME,"");
    }
    public void setStoreId(String quoteId){
        _prefsEditor.putString(STORE_ID,quoteId);
        _prefsEditor.apply();
    }
    public String getStoreId(){
        return _sharedPrefs.getString(STORE_ID,"");
    }
    public void setPrefix(String prefix){
        _prefsEditor.putString(PREFIX,prefix);
        _prefsEditor.apply();
    }
    public String getPrefix(){
        return _sharedPrefs.getString(PREFIX,"");
    }
    public  void setCustToken(String token){
        _prefsEditor.putString(CUST_TOKEN,token);
        _prefsEditor.apply();
    }
    public String getCustToken(){
        return _sharedPrefs.getString(CUST_TOKEN,"");
    }
    public void setID(String id){
        _prefsEditor.putString(ID, id);
        _prefsEditor.apply();
    }
    public String getID(){
        return _sharedPrefs.getString(ID, "");
    }
    public void setEmail(String email){
        _prefsEditor.putString(KEY_EMAIL, email);
        _prefsEditor.apply();
    }
    public String getEmail(){
        return _sharedPrefs.getString(KEY_EMAIL, "");
    }
    public void setPassword(String pass){
        _prefsEditor.putString(KEY_PASSWORD, pass);
        _prefsEditor.apply();
    }
    public String getPassword(){
        return _sharedPrefs.getString(KEY_PASSWORD, "");
    }
    public void setStoreName(String storename){
        _prefsEditor.putString(STORENAME, storename);
        _prefsEditor.apply();
    }
    public String getStoreName(){
        return _sharedPrefs.getString(STORENAME, "");
    }
    public void setUserId(String userId){
        _prefsEditor.putString(KEY_USER_ID, userId);
        _prefsEditor.apply();
    }
    public String getUserId(){
        return _sharedPrefs.getString(KEY_USER_ID, "");
    }
    public void setLogged(boolean key){
        _prefsEditor.putBoolean(KEY_LOGGED, key);
        _prefsEditor.apply();
    }
    public boolean isLogged(){
        return _sharedPrefs.getBoolean(KEY_LOGGED, false);
    }
}

