1package com.peachpasswords.vault23import android.content.Context4import androidx.security.crypto.EncryptedSharedPreferences5import androidx.security.crypto.MasterKey6import dagger.hilt.android.qualifiers.ApplicationContext7import javax.inject.Inject8import javax.inject.Singleton9101112131415161718192021@Singleton22class LastViewedEntryStore @Inject constructor(23 @ApplicationContext context: Context,24) {25 private val masterKey = MasterKey.Builder(context)26 .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)27 .build()2829 private val prefs = EncryptedSharedPreferences.create(30 context,31 PREFS_FILE,32 masterKey,33 EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,34 EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,35 )3637 fun get(): String? = prefs.getString(KEY_LAST_VIEWED, null)3839 fun set(id: String) { prefs.edit().putString(KEY_LAST_VIEWED, id).apply() }4041 fun clear() { prefs.edit().remove(KEY_LAST_VIEWED).apply() }4243 companion object {44 private const val PREFS_FILE = "peach_nav_prefs"45 private const val KEY_LAST_VIEWED = "last_viewed_entry_id"46 }47}