Skip to content

Commit

Permalink
adapted logging statements to be more accurate. reverted pom version …
Browse files Browse the repository at this point in the history
…property to be set again via CI
  • Loading branch information
Death111 committed Jan 8, 2025
1 parent 9fb21c4 commit a40c11f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ You should put the .jar in an extra folder as a *logs* and a *db* folder will be
7. To see the changes just start the new KeepTime again

## Requirements

* Windows 7, 10
* Linux (tested on Ubuntu 18.04)
* Java 11
* Operating System
* Windows 7, 10, 11
* Linux (tested on Ubuntu 18.04)
* Mac (tested on MacBook M2 Pro (ARM based CPU))
* Java 17
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</parent>
<groupId>de.doubleslash</groupId>
<artifactId>keeptime</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>${project.version}</version>

<packaging>jar</packaging>
<name>KeepTime</name>
Expand All @@ -33,6 +33,7 @@
</licenses>

<properties>
<project.version>2.0.0-SNAPSHOT</project.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static void openURL(final String url) {
} else if (OS.isLinux()) {
openUrlLinux(rt, url);
} else {
LOG.warn("OS is not supported");
// TODO implement for MAC
LOG.warn("OS '{}' is not supported", OS.getOSName());
}
}

Expand All @@ -45,7 +46,7 @@ private static void openUrlWindows(final Runtime rt, final String url) {
LOG.debug("Executing command: {}", command);
rt.exec(command);
} catch (final Exception e) {
LOG.error("Could not open url '" + url + "' with command '" + command + "'.", e);
LOG.error("Could not open url '{}' with command '{}'.", url, command, e);
}
}

Expand All @@ -57,7 +58,7 @@ private static void openUrlLinux(final Runtime rt, final String url) {
LOG.debug("Executing command: {}", Arrays.toString(command));
rt.exec(command);
} catch (final Exception e) {
LOG.error("Could not open url '" + url + "' with command '" + Arrays.toString(command) + "'.", e);
LOG.error("Could not open url '{}' with command '{}'.", url, Arrays.toString(command), e);
}
}
}
27 changes: 15 additions & 12 deletions src/main/java/de/doubleslash/keeptime/common/FileOpenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ public static boolean openFile(final String filePath) {
final File file = new File(filePath);
final Runtime rt = Runtime.getRuntime();

if (file.exists() && file.isFile()) {
if (OS.isWindows()) {
openFileWindows(rt, file);
} else if (OS.isLinux()) {
openFileLinux(rt, filePath);
} else {
LOG.warn("OS is not supported");
}
return true;
} else {
if (!file.exists() || file.isFile()) {
LOG.warn("Filepath does not seem to exist or does not point to a file: '{}'.", filePath);
return false;
}

if (OS.isWindows()) {
openFileWindows(rt, file);
} else if (OS.isLinux()) {
openFileLinux(rt, filePath);
} else {
// TODO implement for MAC
LOG.warn("OS '{}' is not supported", OS.getOSName());
}
return true;
}

private static void openFileWindows(final Runtime rt, final File file) {
Expand All @@ -52,7 +54,7 @@ private static void openFileWindows(final Runtime rt, final File file) {
LOG.debug("executing command: {}", command);
rt.exec(command);
} catch (final Exception e) {
LOG.error("Could not open file '" + file + "' with command '" + command + "'.", e);
LOG.error("Could not open file '{}' with command '{}'.", file, command, e);
}
}

Expand All @@ -64,7 +66,8 @@ private static void openFileLinux(final Runtime rt, final String filePath) {
LOG.debug("executing command: {}", Arrays.toString(command));
rt.exec(command);
} catch (final Exception e) {
LOG.error("Could not open file '" + filePath + "' with command '" + Arrays.toString(command) + "'.", e);
LOG.error("Could not open file '{}' with command '{}'.", filePath, Arrays.toString(command),
e);
}
}
}
14 changes: 3 additions & 11 deletions src/main/java/de/doubleslash/keeptime/common/OS.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,14 @@ private OS() {
}

public static boolean isWindows() {
if (System.getProperty(OS_PROPERTY).toLowerCase().contains("windows")) {
return true;
}

return false;
return System.getProperty(OS_PROPERTY).toLowerCase().contains("windows");
}

public static boolean isLinux() {
if (System.getProperty(OS_PROPERTY).toLowerCase().contains("linux")) {
return true;
}

return false;
return System.getProperty(OS_PROPERTY).toLowerCase().contains("linux");
}

public static String getOSname() {
public static String getOSName() {
return System.getProperty(OS_PROPERTY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ public SettingsController(final Model model, final Controller controller,
@FXML
private void initialize() {
LOG.debug("start init");
LOG.info("OS: {}", OS.getOSname());
LOG.info("OS: {}", OS.getOSName());
LOG.debug("set versionLabel text");
LOG.debug("load substages");
LOG.debug("set version label text");

if (!OS.isWindows()) {
LOG.info("Disabling unsupported settings for Linux.");
LOG.info("Disabling unsupported settings (hotkey) for non windows feature.");
useHotkeyCheckBox.setDisable(true);
hotkeyLabel.setDisable(true);
globalKeyloggerLabel.setDisable(true);
Expand Down Expand Up @@ -217,7 +217,7 @@ private void initialize() {
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setHeaderText("Color setting not supported!");
alert.setContentText(
"The level of opacity on your hover background is to high for Linux. Resetting it.");
"The level of opacity on your hover background is to low (<0.5) for non Windows system. Resetting it.");

alert.showAndWait();
}
Expand All @@ -230,7 +230,7 @@ private void initialize() {
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setHeaderText("Color settings not supported!");
alert.setContentText(
"The level of opacity on your hover background is to high for Linux. Resetting it.");
"The level of opacity on your default background is to low (<0.5) for non Windows system. Resetting it.");

alert.showAndWait();
}
Expand Down

0 comments on commit a40c11f

Please sign in to comment.