FeatureSwitch実装仮

This commit is contained in:
r-ca 2024-01-21 20:16:38 +09:00
parent e10207959b
commit ec633a7238
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -14,12 +14,13 @@ import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
import one.nem.lacerta.utils.FeatureSwitch;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.io.NotActiveException;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.utils.repository.SharedPrefUtils;
@ -54,8 +55,44 @@ public class MainActivity extends AppCompatActivity {
finish(); // Exit app
}
// bottomNavigation FeatureSwitch
Menu menu = bottomNavigationView.getMenu();
// 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);
}
}
// Set navigation bar color
getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));