mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
FeatureSwitch実装WIP
This commit is contained in:
parent
2dc3407217
commit
d9d22198d5
|
@ -10,19 +10,27 @@ import androidx.navigation.ui.NavigationUI;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import one.nem.lacerta.utils.FeatureSwitch;
|
||||||
|
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
SharedPrefUtils sharedPrefUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -50,4 +58,28 @@ public class MainActivity extends AppCompatActivity {
|
||||||
// Set status bar color
|
// Set status bar color
|
||||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user