Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7f46a5d authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

add local settings repository

parent fb5292e6
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 E FOUNDATION
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.privacycentralapp.data.repositories

import android.content.Context

class LocalStateRepository(context: Context) {
    companion object {
        private const val SHARED_PREFS_FILE = "localState"
        private const val KEY_QUICK_PRIVACY = "quickPrivacy"
    }

    val sharedPref = context.getSharedPreferences(SHARED_PREFS_FILE, Context.MODE_PRIVATE)

    var isQuickPrivacyEnabled: Boolean
        get() = sharedPref.getBoolean(KEY_QUICK_PRIVACY, false)
        set(value) = set(KEY_QUICK_PRIVACY, value)


    private fun set(key: String, value: Boolean) {
        sharedPref.edit().putBoolean(key, value).apply()
    }


}
 No newline at end of file
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 E FOUNDATION
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.privacycentralapp.domain.usecases

import foundation.e.privacycentralapp.data.repositories.LocalStateRepository

class GetQuickPrivacyStateUseCase(localStateRepository: LocalStateRepository) {
    val isQuickPrivacyEnabled = localStateRepository.isQuickPrivacyEnabled
}