FeatureSwitchのOverrideができるように

This commit is contained in:
r-ca 2024-01-21 19:11:25 +09:00
parent d40f61928c
commit 2dc3407217
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import dagger.hilt.android.qualifiers.ApplicationContext;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
import one.nem.lacerta.utils.repository.SharedPrefUtils;
public class SharedPrefUtilsImpl implements SharedPrefUtils{
@ -36,4 +37,14 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{
public SharedPreferences getSharedPreferences() {
return applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE); // TODO-rca: 決め打ちやめる?
}
@Override
public boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride) {
return getSharedPreferences().getBoolean(featureSwitchOverride.getKey(), false);
}
@Override
public void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value) {
getEditor().putBoolean(featureSwitchOverride.getKey(), value).apply();
}
}

View File

@ -2,6 +2,8 @@ package one.nem.lacerta.utils.repository;
import android.content.SharedPreferences;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
public interface SharedPrefUtils {
// Shared preferences editorの取得
@ -14,4 +16,7 @@ public interface SharedPrefUtils {
SharedPreferences getSharedPreferences();
boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride);
void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value);
}