Skip to content

Commit

Permalink
Add SysTray notification for DB backup. More translations.
Browse files Browse the repository at this point in the history
Added a setting "showBackupNotification", which is false by default,
that shows a tray notification when a repository backup occurs.

Above notification, and the auto-update notification, now refer to
the SysTray i18n translation lookup resources.
  • Loading branch information
catbref committed Mar 24, 2020
1 parent 0b42a7a commit 72c299a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/qortal/controller/AutoUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.qortal.api.ApiRequest;
import org.qortal.data.transaction.ArbitraryTransactionData;
import org.qortal.data.transaction.TransactionData;
import org.qortal.globalization.Translator;
import org.qortal.gui.SysTray;
import org.qortal.repository.DataException;
import org.qortal.repository.Repository;
Expand Down Expand Up @@ -245,7 +246,9 @@ private static boolean attemptUpdate(byte[] commitHash, byte[] downloadHash, Str

LOGGER.info(String.format("Applying update with: %s", String.join(" ", javaCmd)));

SysTray.getInstance().showMessage("Auto Update", "Applying automatic update and restarting...", MessageType.INFO);
SysTray.getInstance().showMessage(Translator.INSTANCE.translate("SysTray", "AUTO_UPDATE"),
Translator.INSTANCE.translate("SysTray", "APPLYING_UPDATE_AND_RESTARTING"),
MessageType.INFO);

new ProcessBuilder(javaCmd).start();

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/qortal/controller/Controller.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.qortal.controller;

import java.awt.TrayIcon.MessageType;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -430,6 +431,12 @@ public void run() {
// Give repository a chance to backup
if (now >= repositoryBackupTimestamp) {
repositoryBackupTimestamp = now + REPOSITORY_BACKUP_PERIOD;

if (Settings.getInstance().getShowBackupNotification())
SysTray.getInstance().showMessage(Translator.INSTANCE.translate("SysTray", "DB_BACKUP"),
Translator.INSTANCE.translate("SysTray", "CREATING_BACKUP_OF_DB_FILES"),
MessageType.INFO);

RepositoryManager.backup(true);
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/qortal/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class Settings {
private int maxTransactionTimestampFuture = 24 * 60 * 60 * 1000; // milliseconds
/** Whether we check, fetch and install auto-updates */
private boolean autoUpdateEnabled = true;
/** Whether to show a notification when we backup repository. */
private boolean showBackupNotification = false;

// Peer-to-peer related
private boolean isTestNet = false;
Expand Down Expand Up @@ -369,4 +371,8 @@ public Long getTestNtpOffset() {
return this.testNtpOffset;
}

public boolean getShowBackupNotification() {
return this.showBackupNotification;
}

}
8 changes: 8 additions & 0 deletions src/main/resources/i18n/SysTray_en.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
# SysTray pop-up menu

APPLYING_UPDATE_AND_RESTARTING = Applying automatic update and restarting...

AUTO_UPDATE = Auto Update

BLOCK_HEIGHT = height

CHECK_TIME_ACCURACY = Check time accuracy
Expand All @@ -9,6 +13,10 @@ CONNECTION = connection

CONNECTIONS = connections

CREATING_BACKUP_OF_DB_FILES = Creating backup of database files...

DB_BACKUP = Database Backup

EXIT = Exit

MINTING_DISABLED = NOT minting
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/org/qortal/test/apps/CheckTranslations.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
public class CheckTranslations {

private static final String[] SUPPORTED_LANGS = new String[] { "en", "de", "zh", "ru" };
private static final Set<String> SYSTRAY_KEYS = Set.of("BLOCK_HEIGHT", "CHECK_TIME_ACCURACY", "CONNECTION", "CONNECTIONS",
"EXIT", "MINTING_DISABLED", "MINTING_ENABLED", "NTP_NAG_CAPTION", "NTP_NAG_TEXT_UNIX", "NTP_NAG_TEXT_WINDOWS",
private static final Set<String> SYSTRAY_KEYS = Set.of("AUTO_UPDATE", "APPLYING_UPDATE_AND_RESTARTING", "BLOCK_HEIGHT",
"CHECK_TIME_ACCURACY", "CONNECTION", "CONNECTIONS", "CREATING_BACKUP_OF_DB_FILES", "DB_BACKUP", "EXIT",
"MINTING_DISABLED", "MINTING_ENABLED", "NTP_NAG_CAPTION", "NTP_NAG_TEXT_UNIX", "NTP_NAG_TEXT_WINDOWS",
"OPEN_UI", "SYNCHRONIZE_CLOCK", "SYNCHRONIZING_BLOCKCHAIN", "SYNCHRONIZING_CLOCK");

private static String failurePrefix;
Expand Down

0 comments on commit 72c299a

Please sign in to comment.