diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 6dec2e80..397921c7 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -10,19 +10,27 @@ import androidx.navigation.ui.NavigationUI; import android.graphics.Color; import android.os.Bundle; import android.util.Log; +import android.view.Menu; import android.widget.Toast; +import one.nem.lacerta.utils.FeatureSwitch; + import com.google.android.material.bottomnavigation.BottomNavigationView; import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.utils.repository.SharedPrefUtils; + import javax.inject.Inject; @AndroidEntryPoint public class MainActivity extends AppCompatActivity { + @Inject + SharedPrefUtils sharedPrefUtils; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -50,4 +58,28 @@ public class MainActivity extends AppCompatActivity { // Set status bar color getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + if (!FeatureSwitch.Meta.canOverrideSwitch) { + Log.d("FeatureSwitch", "Switch override is disabled"); + if (!FeatureSwitch.FeatureMaster.enableDebugMenu) { + menu.removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + + } + if (!FeatureSwitch.FeatureMaster.enableSearch) { + menu.removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); + } + } else { + Log.d("FeatureSwitch", "Switch override is enabled"); + if (!FeatureSwitch.FeatureMaster.enableDebugMenu && !sharedPrefUtils.getFeatureSwitchOverride(one.nem.lacerta.model.pref.FeatureSwitchOverride.ENABLE_DEBUG_MENU)) { + menu.removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + } + if (!FeatureSwitch.FeatureMaster.enableSearch && !sharedPrefUtils.getFeatureSwitchOverride(one.nem.lacerta.model.pref.FeatureSwitchOverride.ENABLE_SEARCH)) { + menu.removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); + } + } + + return super.onPrepareOptionsMenu(menu); + } }