diff --git a/.idea/misc.xml b/.idea/misc.xml index 0ad17cbd..8978d23d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 397921c7..1d42d4b1 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -11,6 +11,7 @@ import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.Menu; +import android.view.MenuItem; import android.widget.Toast; import one.nem.lacerta.utils.FeatureSwitch; @@ -36,13 +37,14 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); + // Init navigation try { FragmentManager supportFragmentManager = getSupportFragmentManager(); NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment); assert navHostFragment != null; NavController navController = navHostFragment.getNavController(); - BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); NavigationUI.setupWithNavController(bottomNavigationView, navController); } catch (Exception e) { @@ -52,34 +54,13 @@ public class MainActivity extends AppCompatActivity { finish(); // Exit app } + // bottomNavigation FeatureSwitch + Menu menu = bottomNavigationView.getMenu(); + // Set navigation bar color getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); // 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); - } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3305b5e2..cc3f088c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -18,7 +18,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:navGraph="@navigation/main_nav" - tools:layout="@layout/fragment_debug_menu_container" /> + tools:layout="@layout/fragment_home_top" /> + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml index 87e98113..12a0311d 100644 --- a/app/src/main/res/menu/bottom_nav_menu.xml +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -19,7 +19,7 @@ + android:title="@string/debug_menu_title" /> + app:startDestination="@id/feature_home_navigation"> diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 92b09262..9e53abfb 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -2,8 +2,13 @@ package one.nem.lacerta.utils; public class FeatureSwitch { + public static class Meta { + public static boolean canOverrideSwitch = true; + } + public static class FeatureMaster { public static boolean enableSearch = true; + public static boolean enableDebugMenu = true; } public static class Setting { 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 b991839e..82301a64 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 @@ -4,6 +4,8 @@ package one.nem.lacerta.utils.impl; import android.content.Context; import android.content.SharedPreferences; +import javax.inject.Inject; + import dagger.hilt.android.qualifiers.ApplicationContext; import one.nem.lacerta.model.pref.FeatureSwitchOverride; import one.nem.lacerta.utils.repository.SharedPrefUtils; @@ -12,6 +14,7 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{ private final Context applicationContext; + @Inject public SharedPrefUtilsImpl(@ApplicationContext Context applicationContext) { this.applicationContext = applicationContext; }