package com.fastest.pass.helpers

import android.app.Activity
import android.content.Context

open class PreferencesHelper {
    companion object {

         fun putStringPreference(
            context: Context,
            prefsName: String?,
            key: String?,
            value: String?
        ) {
            val preferences = context.getSharedPreferences(prefsName, Activity.MODE_PRIVATE)
            val editor = preferences.edit()

            editor.putString(key, value)
            editor.commit()
        }

         fun getStringPreference(context: Context, prefsName: String?, key: String?): String? {
            val preferences = context.getSharedPreferences(prefsName, Activity.MODE_PRIVATE)
            val value = preferences.getString(key, "")
            return value
        }

         fun putBooleanPreference(
            context: Context,
            prefsName: String?,
            key: String?,
            value: Boolean
         ) {
            val preferences = context.getSharedPreferences(prefsName, Activity.MODE_PRIVATE)
            val editor = preferences.edit()

            editor.putBoolean(key, value)
            editor.commit()
        }

         fun getBooleanPreference(
            context: Context,
            prefsName: String?,
            key: String?
        ): Boolean {
            val preferences = context.getSharedPreferences(prefsName, Activity.MODE_PRIVATE)
            val value = preferences.getBoolean(key, false)
            return value
        }

         fun putIntegerPreference(
            context: Context,
            prefsName: String?,
            key: String?,
            value: Int
        ) {
            val preferences = context.getSharedPreferences(prefsName, Activity.MODE_PRIVATE)
            val editor = preferences.edit()

            editor.putInt(key, value)
            editor.commit()
        }

         fun getIntegerPreference(context: Context, prefsName: String?, key: String?): Int {
            val preferences = context.getSharedPreferences(prefsName, Activity.MODE_PRIVATE)
            val value = preferences.getInt(key, 0)
            return value
        }

         fun removePreference(context: Context, prefsName: String?, key: String?) {
            val preferences = context.getSharedPreferences(prefsName, Activity.MODE_PRIVATE)
            val editor = preferences.edit()

            editor.remove(key)
            editor.commit()
        }
    }
}