mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
WIP
This commit is contained in:
parent
d9d22198d5
commit
676a0e2772
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
|
@ -31,7 +31,6 @@
|
|||
app:labelVisibilityMode="selected"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:menu="@menu/bottom_nav_menu"/>
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -19,7 +19,7 @@
|
|||
<item
|
||||
android:id="@id/feature_debug_navigation"
|
||||
android:icon="@drawable/developer_mode_24px"
|
||||
android:title="@string/debug_menu_title"/>
|
||||
android:title="@string/debug_menu_title" />
|
||||
|
||||
<item
|
||||
android:id="@id/feature_setting_navigation"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/app_main_nav"
|
||||
app:startDestination="@id/feature_debug_navigation">
|
||||
app:startDestination="@id/feature_home_navigation">
|
||||
|
||||
<include app:graph="@navigation/feature_debug_navigation" />
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user