Skip to content

Commit

Permalink
Merge pull request #218 from raeleus/Fix-iOS-Java-version-validation
Browse files Browse the repository at this point in the history
Fix iOS Java version validation
  • Loading branch information
tommyettinger authored Jan 19, 2025
2 parents 49e3d2f + a5d8460 commit e31fa4c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/main/java/gdx/liftoff/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ public static boolean validateUserProjectData() {
return false;
}

if (UserData.platforms.contains("ios") && !"7".equals(UserData.javaVersion) && !"8".equals(UserData.javaVersion)) {
return false;
}

return true;
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gdx/liftoff/ui/panels/PathsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ private void updateDeleteProjectPathButton() {
}

public void updateError() {
if (UserData.platforms.contains("ios") && !"7".equals(UserData.javaVersion) && !"8".equals(UserData.javaVersion)) {
errorLabel.restart(prop.getProperty("iosWrongJavaVersion"));
errorLabel.skipToTheEnd();
return;
}

if (UserData.projectPath == null || UserData.projectPath.isEmpty()) {
errorLabel.restart(prop.getProperty("nullDirectory"));
errorLabel.skipToTheEnd();
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/gdx/liftoff/ui/panels/SettingsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ray3k.stripe.PopTable;
import com.ray3k.stripe.PopTable.TableShowHideListener;
import gdx.liftoff.ui.UserData;
import gdx.liftoff.ui.dialogs.FullscreenDialog;
import gdx.liftoff.ui.dialogs.GradleDialog;

import static gdx.liftoff.Main.*;
Expand Down Expand Up @@ -40,14 +41,18 @@ public void populate(boolean fullscreen) {
onChange(libgdxTextField, () -> UserData.libgdxVersion = libgdxTextField.getText());

//java version
if(UserData.platforms.contains("ios") && !"7".equals(UserData.javaVersion))
UserData.javaVersion = "8";
TextField javaTextField = addField(prop.getProperty("javaVersion"),
prop.getProperty("javaVersionTip"), UserData.javaVersion, table);
onChange(javaTextField, () -> {
if(UserData.platforms.contains("ios") && !"7".equals(javaTextField.getText()))
javaTextField.setText("8");
UserData.javaVersion = javaTextField.getText();
if (FullscreenDialog.fullscreenDialog != null) {
FullscreenDialog.fullscreenDialog.updatePathsError();
FullscreenDialog.fullscreenDialog.updateGenerateButtons();
}
if (root.settingsTable != null) {
root.settingsTable.updateError();
root.settingsTable.updateGenerateButton();
}
});

//application version
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/ui-data/nls.properties
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ notEmpty={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}%s name cannot be em
nameNotValid={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}Project name must contain at least one alphanumeric char, and cannot contain a colon ( : ).{ENDGRADIENT}{ENDSICK}
classNotValid={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}Main class name is not a valid Java identifier.{ENDGRADIENT}{ENDSICK}
packageNotValid={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}Package name is not a valid Java package, or lacks a dot ( . ).{ENDGRADIENT}{ENDSICK}
iosWrongJavaVersion={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}Java version must be 7 or 8 for iOS compatibility.{ENDGRADIENT}{ENDSICK}
nullDirectory={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}A project path must be selected.{ENDGRADIENT}{ENDSICK}
notDirectory={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}Selected destination is not a directory.{ENDGRADIENT}{ENDSICK}
sdkNullDirectory={SICK=0.35;0.4}{GRADIENT=FIREBRICK;SCARLET;1.1;7.0}An Android SDK path must be selected for Android projects.{ENDGRADIENT}{ENDSICK}
Expand Down

0 comments on commit e31fa4c

Please sign in to comment.