Skip to content

Commit

Permalink
ButtonToModeAction: removed non-parameterless constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
bwRavencl committed Aug 16, 2023
1 parent fba4fc9 commit 42d0f1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,15 @@ private IAction<?> getActionClassInstance(final Class<?> actionClass)
throw new IllegalArgumentException(
"Class '" + actionClass.getName() + "' does not implement '" + IAction.class.getSimpleName() + "'");

if (actionClass == ButtonToModeAction.class)
return new ButtonToModeAction(input);
return (IAction<?>) actionClass.getConstructor().newInstance();
final var action = (IAction<?>) actionClass.getConstructor().newInstance();

if (action instanceof final ButtonToModeAction buttonToModeAction) {
final var modes = input.getProfile().getModes();
final var defaultMode = modes.size() > 1 ? modes.get(1) : OnScreenKeyboard.onScreenKeyboardMode;
buttonToModeAction.setMode(defaultMode);
}

return action;
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public static LinkedList<ButtonToModeAction> getButtonToModeActionStack() {

private transient boolean up = true;

public ButtonToModeAction(final Input input) {
final var modes = input.getProfile().getModes();
setMode(modes.size() > 1 ? modes.get(1) : OnScreenKeyboard.onScreenKeyboardMode);
}

private void activateMode(final Input input, final Profile profile) {
if (!buttonToModeActionStack.contains(this)) {
buttonToModeActionStack.push(this);
Expand Down

0 comments on commit 42d0f1b

Please sign in to comment.