Android: Don't include autofire settings without controller set

This commit is contained in:
Connor McLaughlin 2021-06-01 22:33:05 +10:00
parent 584427e33c
commit b2447e2270
1 changed files with 25 additions and 23 deletions

View File

@ -323,31 +323,33 @@ public class ControllerSettingsCollectionFragment extends Fragment {
R.string.settings_use_analog_sticks_for_dpad, R.string.settings_summary_use_analog_sticks_for_dpad, true)); R.string.settings_use_analog_sticks_for_dpad, R.string.settings_summary_use_analog_sticks_for_dpad, true));
} }
for (int autoFireSlot = 1; autoFireSlot <= NUM_AUTO_FIRE_BUTTONS; autoFireSlot++) { if (buttonNames != null) {
final ListPreference autoFirePreference = new ListPreference(getContext()); for (int autoFireSlot = 1; autoFireSlot <= NUM_AUTO_FIRE_BUTTONS; autoFireSlot++) {
autoFirePreference.setEntries(buttonNames); final ListPreference autoFirePreference = new ListPreference(getContext());
autoFirePreference.setEntryValues(buttonNames); autoFirePreference.setEntries(buttonNames);
autoFirePreference.setKey(String.format("Controller%d/AutoFire%dButton", controllerIndex, autoFireSlot)); autoFirePreference.setEntryValues(buttonNames);
autoFirePreference.setTitle(getContext().getString(R.string.controller_settings_auto_fire_n_button, autoFireSlot)); autoFirePreference.setKey(String.format("Controller%d/AutoFire%dButton", controllerIndex, autoFireSlot));
autoFirePreference.setSummaryProvider(ListPreference.SimpleSummaryProvider.getInstance()); autoFirePreference.setTitle(getContext().getString(R.string.controller_settings_auto_fire_n_button, autoFireSlot));
autoFirePreference.setIconSpaceReserved(false); autoFirePreference.setSummaryProvider(ListPreference.SimpleSummaryProvider.getInstance());
mAutoFireCategory.addPreference(autoFirePreference); autoFirePreference.setIconSpaceReserved(false);
mAutoFireCategory.addPreference(autoFirePreference);
final SeekBarPreference frequencyPreference = new SeekBarPreference(getContext()); final SeekBarPreference frequencyPreference = new SeekBarPreference(getContext());
frequencyPreference.setMin(1); frequencyPreference.setMin(1);
frequencyPreference.setMax(60); frequencyPreference.setMax(60);
frequencyPreference.setKey(String.format("Controller%d/AutoFire%dFrequency", controllerIndex, autoFireSlot)); frequencyPreference.setKey(String.format("Controller%d/AutoFire%dFrequency", controllerIndex, autoFireSlot));
frequencyPreference.setDefaultValue(2); frequencyPreference.setDefaultValue(2);
frequencyPreference.setTitle(getContext().getString(R.string.controller_settings_auto_fire_n_frequency, autoFireSlot)); frequencyPreference.setTitle(getContext().getString(R.string.controller_settings_auto_fire_n_frequency, autoFireSlot));
frequencyPreference.setIconSpaceReserved(false); frequencyPreference.setIconSpaceReserved(false);
frequencyPreference.setShowSeekBarValue(true); frequencyPreference.setShowSeekBarValue(true);
mAutoFireCategory.addPreference(frequencyPreference); mAutoFireCategory.addPreference(frequencyPreference);
} }
for (int autoFireSlot = 1; autoFireSlot <= NUM_AUTO_FIRE_BUTTONS; autoFireSlot++) { for (int autoFireSlot = 1; autoFireSlot <= NUM_AUTO_FIRE_BUTTONS; autoFireSlot++) {
final ControllerBindingPreference bindingPreference = new ControllerBindingPreference(getContext(), null); final ControllerBindingPreference bindingPreference = new ControllerBindingPreference(getContext(), null);
bindingPreference.initAutoFireButton(controllerIndex, autoFireSlot); bindingPreference.initAutoFireButton(controllerIndex, autoFireSlot);
mAutoFireBindingsCategory.addPreference(bindingPreference); mAutoFireBindingsCategory.addPreference(bindingPreference);
}
} }
} }