diff --git a/Readme.md b/Readme.md index f35ad6b..bf01aea 100644 --- a/Readme.md +++ b/Readme.md @@ -6,7 +6,8 @@ Time Calc is a desktop application used to track the remaining time until the en _Time Calc is written in Java programming language and uses the Swing framework._ -![Tux, the Linux mascot](images/screenshot.png) +![Screenshot of application "Time Calc"](images/screenshot.png) + ## Usage ### Start of application @@ -82,28 +83,64 @@ If file test.txt exists, then user is not asked for start time and overtime. Ins ### Smileys -Progress in square, circle or batteries is represented also by smileys (only, if the widget is hovered by mouse cursor): - * smileys can be colored or white-black (can be set in configuration) +### Smileys + +Progress in square, circle or batteries is represented also by smileys (only, if the widget is hovered by mouse cursor): + +Smileys can be colored or white-black (can be set in configuration) + +
😱
... face screaming in fear ... less than 6.25% + +
😡
... pouting face ... less than 12.5% + +
😠
... angry face ... less than 18.75% + +
😭
... loudly crying face ... less than 25% + +
😢
... crying face ... less than 31.25% + +
😞
... disappointed face ... less than 37.5% + +
😫
... tired face ... less than 43.75% + +
😨
... fearful face ... less than 50% + +
😲
... astonished face ... less than 56.25% + +
😦
... frowning face with open mouth ... less than 62.5% + +
😊
... smiling face with smiling eyes ... less than 68.75% + +
😃
... smiling face with open mouth ... less than 75% + +
😁
... grinning face with smiling eyes ... less than 81.25% + +
😎
... smiling face with sunglasses ... less than 87.5% + +
😍
... smiling face with heart-shaped eyes ... less than 93.75% + +
😈
... smiling face with horns ... more or equal to 93.75% -* ? ... face screaming in fear ... less than 6.25% -* ? ... pouting face ... less than 12.5% -* ? ... angry face ... less than 18.75% -* ? ... loudly crying face ... less than 25% -* ? ... crying face ... less than 31.25% -* ? ... disappointed face ... less than 37.5% -* ? ... tired face ... less than 43.75% -* ? ... fearful face ... less than 50% -* ? ... astonished face ... less than 56.25% -* ? ... frowning face with open mouth ... less than 62.5% -* ? ... smiling face with smiling eyes ... less than 68.75% -* ? ... smiling face with open mouth ... less than 75% -* ? ... grinning face with smiling eyes ... less than 81.25% -* ? ... smiling face with sunglasses ... less than 87.5% -* ? ... smiling face with heart-shaped eyes ... less than 93.75% -* ? ... smiling face with horns ... more or equal to 93.75% ## Key shortcuts +* UP - Show widgets again, if they were hidden +* DOWN - Hide all widgets and buttons +* H - Show all hide everything +* G - switch between coloured and no-coloured visibility mode +* C - switch between strongly coloured and weakly coloured visibility mode +* V - switch visibility mode NONE and STRONGLY_COLOURED +* SPACE - switch visibility mode: NONE, GREY, WEAKLY_COLOURED, STRONGLY_COLOURED +* F2 - run commands +* R - restart app +* T - enable or disable notifications +* W - open work days window +* A - open activity window +* S - open config window +* P or F1 - open help window +* X - exit application +* J - show random Joke + ## Command button ## Todos diff --git a/modules/time-calc-app/pom.xml b/modules/time-calc-app/pom.xml index 6cf5a98..3e7e886 100644 --- a/modules/time-calc-app/pom.xml +++ b/modules/time-calc-app/pom.xml @@ -50,5 +50,12 @@ + + + com.github.rjeschke + txtmark + 0.13 + + \ No newline at end of file diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java index 4f9c8bc..f6a08ce 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java @@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.app; import org.nanoboot.utils.timecalc.entity.Visibility; import org.nanoboot.utils.timecalc.swing.common.MainWindow; +import org.nanoboot.utils.timecalc.utils.common.Jokes; import org.nanoboot.utils.timecalc.utils.common.Utils; import java.awt.event.KeyAdapter; @@ -129,8 +130,15 @@ public class TimeCalcKeyAdapter extends KeyAdapter { window.openConfigWindow(); } + if (e.getKeyCode() == KeyEvent.VK_J) { + if(timeCalcConfiguration.jokesVisibleProperty.isEnabled()) { + Jokes.showRandom(); + } - if (e.getKeyCode() == KeyEvent.VK_P) { + } + + + if (e.getKeyCode() == KeyEvent.VK_P || e.getKeyCode() == KeyEvent.VK_F1) { window.openHelpWindow(); } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java index f135aa2..1abfee7 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java @@ -262,7 +262,6 @@ public class ConfigWindow extends TWindow { } }); - } private void addToNextRow(JComponent jComponent) { diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java index 559f67b..17020b4 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java @@ -1,5 +1,14 @@ package org.nanoboot.utils.timecalc.swing.common; +import org.nanoboot.utils.timecalc.utils.common.ProgressSmiley; +import org.nanoboot.utils.timecalc.utils.common.Utils; + +import javax.swing.JEditorPane; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import java.io.File; +import java.io.IOException; + /** * @author Robert Vokac * @since 16.02.2024 @@ -9,5 +18,32 @@ public class HelpWindow extends TWindow { public HelpWindow() { setSize(800, 600); setTitle("Help"); + String helpHtml = ""; + try { + String helpMd = + Utils.readTextFromTextResourceInJar("help/Readme.md"); + + helpHtml = com.github.rjeschke.txtmark.Processor.process( + helpMd); + } catch (IOException e) { + JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(), + e.getMessage(), JOptionPane.ERROR_MESSAGE); + return; + } + + helpHtml = "
" + helpHtml + "
"; + System.out.println(helpHtml); + this.setLayout(null); + JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.setBounds(1,1, + getWidth() - SwingUtils.MARGIN, + getHeight() - SwingUtils.MARGIN); + add(scrollPane); + + JEditorPane editor = new JEditorPane(); + scrollPane.setViewportView(editor); + + editor.setContentType("text/html"); + editor.setText(helpHtml); } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Jokes.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Jokes.java index 8872605..7a14a54 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Jokes.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Jokes.java @@ -72,7 +72,7 @@ public class Jokes { Toaster t = new Toaster(); t.setToasterWidth(800); t.setToasterHeight(800); - t.setDisplayTime(60000 * 5); + t.setDisplayTime(60000 * 1); t.setToasterColor(Color.GRAY); Font font = new Font("sans", Font.PLAIN, 16); t.setToasterMessageFont(font); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/ProgressSmiley.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/ProgressSmiley.java index d30eb19..71f143b 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/ProgressSmiley.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/ProgressSmiley.java @@ -60,4 +60,14 @@ public enum ProgressSmiley { } return SMILEY_16; } + + public static void main(String[] args) { + Arrays.stream(values()).forEach(s-> { + s.getCharacter().codePoints().mapToObj(Integer::toHexString).forEach(System.out::println); + + }); + } + private static String toUnicode(char ch) { + return String.format("\\u%04x", (int) ch); + } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java index 01d388b..fc26bbb 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java @@ -47,7 +47,7 @@ public class Utils { FileOutputStream outputStream; try { outputStream = new FileOutputStream(file.getAbsolutePath()); - byte[] strToBytes = text.getBytes(); + byte[] strToBytes = text.getBytes(StandardCharsets.UTF_8); outputStream.write(strToBytes); outputStream.close(); diff --git a/modules/time-calc-app/src/main/resources/help/Readme.md b/modules/time-calc-app/src/main/resources/help/Readme.md new file mode 100644 index 0000000..5d56876 --- /dev/null +++ b/modules/time-calc-app/src/main/resources/help/Readme.md @@ -0,0 +1,165 @@ +# Time Calc + +## Introduction + +Time Calc is a desktop application used to track the remaining time until the end of some activity - like working hours. + +_Time Calc is written in Java programming language and uses the Swing framework._ + +![Tux, the Linux mascot](images/screenshot.png) +## Usage + +### Start of application + +When "Time Calc" is started", user is asked for: +- start time ... like 7:30 +- overtime ... like 0:45 ... overtime is optional and the default value is 0:00 + +### Restart of application + +You can restart the app, if you press the **"Restart"** button. +- Then you are asked again for start time and overtime. + +### End of application + +You can stop the app, if you press the **"Exit"** button or click on the exit window button. +- Then application is stopped. + + +## Special files + +If these files are present, something special happens. + +### starttime.txt + +This file contains the default start time - used during the previous run of the app. +If file starttime.txt does not exist, then the default start time is 7:00. + +### overtime.txt + +This file contains the default overtime - used during the previous run of the app. +If file overtime.txt does not exist, then the default overtime is 0:00. + +### test.txt +If file test.txt exists, then user is not asked for start time and overtime. Instead, the values in files starttime.txt and overtime.txt are used. + +## Features + +### 3 Visibility modes + +* STRONGLY_COLORED - many colors +* WEAKLY_COLORED - darkened colors +* GRAY - gray colors +* NONE - widgets are hidden + +### Widgets + +* +#### Analog Clock + +* hour hand +* minute hand (can be disabled in configuration) +* second hand (can be disabled in configuration) +* millisecond hand (can be disabled in configuration) +* shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED +* shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED +* hands can be long or shorter (can be set in configuration) + +#### Progress Square +* Show graphically day progress + +#### Progress Circle + +* Show graphically day progress + +#### Hour Battery + +#### Day Battery + +#### Week Battery + +#### Month Battery + +### Smileys + +Progress in square, circle or batteries is represented also by smileys (only, if the widget is hovered by mouse cursor): + +Smileys can be colored or white-black (can be set in configuration) + +
😱
... face screaming in fear ... less than 6.25% + +
😡
... pouting face ... less than 12.5% + +
😠
... angry face ... less than 18.75% + +
😭
... loudly crying face ... less than 25% + +
😢
... crying face ... less than 31.25% + +
😞
... disappointed face ... less than 37.5% + +
😫
... tired face ... less than 43.75% + +
😨
... fearful face ... less than 50% + +
😲
... astonished face ... less than 56.25% + +
😦
... frowning face with open mouth ... less than 62.5% + +
😊
... smiling face with smiling eyes ... less than 68.75% + +
😃
... smiling face with open mouth ... less than 75% + +
😁
... grinning face with smiling eyes ... less than 81.25% + +
😎
... smiling face with sunglasses ... less than 87.5% + +
😍
... smiling face with heart-shaped eyes ... less than 93.75% + +
😈
... smiling face with horns ... more or equal to 93.75% + +## Key shortcuts + +* UP - Show widgets again, if they were hidden +* DOWN - Hide all widgets and buttons +* H - Show all hide everything +* G - switch between coloured and no-coloured visibility mode +* C - switch between strongly coloured and weakly coloured visibility mode +* V - switch visibility mode NONE and STRONGLY_COLOURED +* SPACE - switch visibility mode: NONE, GREY, WEAKLY_COLOURED, STRONGLY_COLOURED +* F2 - run commands +* R - restart app +* T - enable or disable notifications +* W - open work days window +* A - open activity window +* S - open config window +* P or F1 - open help window +* X - exit application +* J - show random Joke + +## Command button + +## Todos + +* Config window +* Split to Maven modules +* Junit, Mockito, etc. +* Checkstyle +* Sonarlint +* Sonarqube +* Add SQLite support and store times of arrivals and departures and time of activities + +## For Developers + +### How to add new property + +**Change these places:** + +* timecalc-default.conf +* timecalc-template.conf +* TimeCalcProperty +* TimeCalcConfiguration +* ConfigWindow +* Widget class +* MainWindow - bind + diff --git a/modules/time-calc-app/src/main/resources/images/screenshot.png b/modules/time-calc-app/src/main/resources/images/screenshot.png new file mode 100644 index 0000000..2aebaf5 Binary files /dev/null and b/modules/time-calc-app/src/main/resources/images/screenshot.png differ