FeatureSwitch実装WIP

This commit is contained in:
r-ca 2024-01-21 19:18:43 +09:00
parent 2dc3407217
commit d9d22198d5
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -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);
}
}