From fd850651b3108d23c8e94dfaad74277d540c632a Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:28:33 +0900 Subject: [PATCH] =?UTF-8?q?=E5=AE=9F=E8=A3=85=E3=82=92=E5=8D=98=E7=B4=94?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/MainActivity.java | 45 ++++--------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 2ca5f720..349e87c1 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -56,43 +56,9 @@ public class MainActivity extends AppCompatActivity { } // Apply feature switch - if (FeatureSwitch.Meta.canOverrideSwitch) { - Log.d("FeatureSwitch", "Feature switch override is enabled"); - if (!FeatureSwitch.FeatureMaster.enableDebugMenu) { - if (sharedPrefUtils.getFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU)) { - Log.d("FeatureSwitch", "Debug menu is enabled"); - } else { - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); - Log.d("FeatureSwitch", "Debug menu is disabled"); - } - } else { - Log.d("FeatureSwitch", "Debug menu is enabled"); - } - if (!FeatureSwitch.FeatureMaster.enableSearch) { - if (sharedPrefUtils.getFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH)) { - Log.d("FeatureSwitch", "Search is enabled"); - } else { - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); - Log.d("FeatureSwitch", "Search is disabled"); - } - } else { - Log.d("FeatureSwitch", "Search is enabled"); - } - } else { - Log.d("FeatureSwitch", "Feature switch override is disabled"); - if (FeatureSwitch.FeatureMaster.enableDebugMenu) { - Log.d("FeatureSwitch", "Debug menu is enabled"); - } else { - Log.d("FeatureSwitch", "Debug menu is disabled"); - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); - } - if (FeatureSwitch.FeatureMaster.enableSearch) { - Log.d("FeatureSwitch", "Search is enabled"); - } else { - Log.d("FeatureSwitch", "Search is disabled"); - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); - } - } + applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch, one.nem.lacerta.feature.search.R.id.feature_search_navigation); + applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu, one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + // Set navigation bar color getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); @@ -100,4 +66,9 @@ public class MainActivity extends AppCompatActivity { // Set status bar color getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); } + + 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); + } }