From 2dc3407217bf25659330794873abe9e9e12a79c9 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:11:25 +0900 Subject: [PATCH] =?UTF-8?q?FeatureSwitch=E3=81=AEOverride=E3=81=8C?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/utils/impl/SharedPrefUtilsImpl.java | 11 +++++++++++ .../nem/lacerta/utils/repository/SharedPrefUtils.java | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java index 14f493a5..b991839e 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java +++ b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java @@ -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(); + } } diff --git a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java index 0be1859b..36a0c49c 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java +++ b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java @@ -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); }