Refactor checks

This commit is contained in:
crschnick 2024-03-22 06:03:30 +00:00
parent f84c06dd8c
commit 3b6ad291a8
7 changed files with 40 additions and 7 deletions

View file

@ -1,4 +1,4 @@
package io.xpipe.app.core;
package io.xpipe.app.core.check;
import io.xpipe.core.process.OsType;
import io.xpipe.core.util.XPipeInstallation;
@ -6,7 +6,7 @@ import javafx.scene.text.Font;
import java.util.concurrent.TimeUnit;
public class AppBundledFonts {
public class AppBundledFontCheck {
public static void init() {
if (OsType.getLocal() != OsType.LINUX) {

View file

@ -1,9 +1,10 @@
package io.xpipe.app.core;
package io.xpipe.app.core.check;
import io.xpipe.app.core.AppLogs;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.util.ModuleHelper;
public class AppDebugModeNotice {
public class AppDebugModeCheck {
public static void printIfNeeded() {
if (!ModuleHelper.isImage() || !AppLogs.get().getLogLevel().equals("trace")) {

View file

@ -0,0 +1,28 @@
package io.xpipe.app.core.check;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppWindowHelper;
import javafx.scene.control.Alert;
public class AppPtbCheck {
public static void check() {
if (!AppProperties.get().isStaging()) {
return;
}
AppWindowHelper.showBlockingAlert(
alert -> {
alert.setAlertType(Alert.AlertType.INFORMATION);
alert.setHeaderText("Notice for the public test build");
alert.getDialogPane()
.setContent(
AppWindowHelper.alertContentText(
"You are running a PTB build of XPipe." +
" This version is unstable and might contain bugs." +
" You should not use it as a daily driver." +
" It will also not receive regular updates." +
" You will have to install and launch the normal XPipe release for that."));
});
}
}

View file

@ -21,6 +21,7 @@ public class AppTempCheck {
ErrorEvent.fromThrowable(new IOException("Specified temporary directory " + tmpdir
+ ", set via the environment variable %TEMP% is invalid."))
.term()
.expected()
.handle();
}
}

View file

@ -3,6 +3,7 @@ package io.xpipe.app.core.mode;
import io.xpipe.app.core.App;
import io.xpipe.app.core.AppGreetings;
import io.xpipe.app.core.AppMainWindow;
import io.xpipe.app.core.check.AppPtbCheck;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
@ -31,6 +32,7 @@ public class GuiMode extends PlatformMode {
super.onSwitchTo();
AppGreetings.showIfNeeded();
AppPtbCheck.check();
TrackEvent.info("Waiting for window setup completion ...");
PlatformThread.runLaterIfNeededBlocking(() -> {

View file

@ -2,6 +2,7 @@ package io.xpipe.app.core.mode;
import io.xpipe.app.Main;
import io.xpipe.app.core.*;
import io.xpipe.app.core.check.AppDebugModeCheck;
import io.xpipe.app.core.check.AppTempCheck;
import io.xpipe.app.core.check.AppUserDirectoryCheck;
import io.xpipe.app.ext.DataStoreProviders;
@ -111,7 +112,7 @@ public abstract class OperationMode {
AppUserDirectoryCheck.check();
AppTempCheck.check();
AppLogs.init();
AppDebugModeNotice.printIfNeeded();
AppDebugModeCheck.printIfNeeded();
AppProperties.logArguments(args);
AppProperties.logSystemProperties();
AppProperties.logPassedProperties();

View file

@ -1,6 +1,6 @@
package io.xpipe.app.util;
import io.xpipe.app.core.AppBundledFonts;
import io.xpipe.app.core.check.AppBundledFontCheck;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
@ -81,7 +81,7 @@ public enum PlatformState {
}
// Check if we have no fonts and set properties to load bundled ones
AppBundledFonts.init();
AppBundledFontCheck.init();
if (AppPrefs.get() != null) {
var s = AppPrefs.get().uiScale().getValue();