Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/main/java/com/tonic/launcher/ui/SplashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public SplashScreen() {
*/
public void setStageProgress(int progress, String text) {
this.stageProgress = Math.max(0, Math.min(100, progress));
this.stageText = text;
this.stageText = sanitizeStatusText(text);
SwingUtilities.invokeLater(splashPanel::repaint);
}

Expand All @@ -73,7 +73,7 @@ public void setOverallProgress(int progress) {
public void setProgress(int stageProgress, int overallProgress, String text) {
this.stageProgress = Math.max(0, Math.min(100, stageProgress));
this.overallProgress = Math.max(0, Math.min(100, overallProgress));
this.stageText = text;
this.stageText = sanitizeStatusText(text);
SwingUtilities.invokeLater(splashPanel::repaint);
}

Expand All @@ -84,7 +84,7 @@ public void setProgressAndStatus(int progress, String text) {
}

public void setError(String message) {
this.stageText = message;
this.stageText = sanitizeStatusText(message);
this.isError = true;
SwingUtilities.invokeLater(() -> {
closeButton.setVisible(true);
Expand All @@ -95,6 +95,24 @@ public void setError(String message) {
});
}

private String sanitizeStatusText(String text) {
if (text == null || text.isEmpty()) {
return "";
}

StringBuilder sanitized = new StringBuilder(text.length());
for (int i = 0; i < text.length(); i++) {
char currentChar = text.charAt(i);
if (currentChar >= 32 && currentChar <= 126) {
sanitized.append(currentChar);
} else {
sanitized.append(' ');
}
}

return sanitized.toString().replaceAll("\\s+", " ").trim();
}

public boolean isError() {
return isError;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonic/launcher/util/JDKManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private static void downloadFile(String url, Path destination, SplashScreen spla
}
}

lastSpeedEta = String.format(" %.1f MB/s %s left", speedMBps, etaStr);
lastSpeedEta = String.format(" | %.1f MB/s | %s left", speedMBps, etaStr);
lastSpeedUpdate = currentTime;
bytesAtLastSpeedUpdate = totalBytes;
}
Expand Down