private static Context getThemedContext() {
        final Context ctx = CgeoApplication.getInstance();
        final Resources res = ctx.getResources();
        final Configuration configuration = new Configuration(ctx.getResources().getConfiguration());
        final int nightNode = AppCompatDelegate.getDefaultNightMode();
        if (nightNode == AppCompatDelegate.MODE_NIGHT_NO) {
            configuration.uiMode = Configuration.UI_MODE_NIGHT_NO | (res.getConfiguration().uiMode & ~Configuration.UI_MODE_NIGHT_MASK);
        } else if (nightNode == AppCompatDelegate.MODE_NIGHT_YES) {
            configuration.uiMode = Configuration.UI_MODE_NIGHT_YES | (res.getConfiguration().uiMode & ~Configuration.UI_MODE_NIGHT_MASK);
        } else {
            configuration.uiMode = res.getConfiguration().uiMode;
        }
        return ctx.createConfigurationContext(configuration);
    }
Sets enabled state for given menu item (without crashing on null item)
main/src/main/java/cgeo/geocaching/utils/MenuUtils.java