初回起動の場合に初期化処理としてデフォルト値を書き込むように

This commit is contained in:
r-ca 2024-01-21 20:34:47 +09:00
parent 4cfc87a40b
commit ea0b1a7665
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -40,6 +40,10 @@ public class MainActivity extends AppCompatActivity {
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
if (sharedPrefUtils.getIsFirstLaunch()) {
initializeApp();
}
// Init navigation
try {
FragmentManager supportFragmentManager = getSupportFragmentManager();
@ -67,6 +71,15 @@ public class MainActivity extends AppCompatActivity {
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
}
private void initializeApp() {
// Set feature switch override to default value
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch);
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu);
// Set isFirstLaunch to false
sharedPrefUtils.setIsFirstLaunch(false);
}
private void applyFeatureSwitch(BottomNavigationView bottomNavigationView, FeatureSwitchOverride featureSwitchOverride, boolean defaultValue, int menuId) {
boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue;
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);