Skip to content

Commit

Permalink
Closes #270 add preference to opt out of new version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
angryziber committed Jan 19, 2021
1 parent 43161d1 commit af76b0f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,7 @@ Unreleased:
- Cleanup some GUI resource leaks
- Allow changing of MAC address separator (many tools use "-" instead of ":")
- Comments for hosts on LAN (tied to MAC address) will now display even if MAC fetcher is not selected, or is after the Comments fetcher #124
- Preference added to opt-out of checking for new versions #270

Changes in 3.7.3:
- Local IP address popup will now list IPv6 addresses and support IPv6 netmasks
Expand Down
1 change: 1 addition & 0 deletions resources/messages.properties
Expand Up @@ -285,6 +285,7 @@ preferences.display.confirmation=Confirmation
preferences.display.confirmation.newScan=Ask for confirmation before starting a new scan
preferences.display.confirmation.showInfo=Show info dialog after each scan
preferences.allowReports=Send anonymous error reports
preferences.versionCheck=Check for new versions
exporter.txt=Text file (txt)
exporter.txt.generated=Generated by
exporter.txt.scanned=Scanned
Expand Down
8 changes: 3 additions & 5 deletions src/net/azib/ipscan/config/GUIConfig.java
Expand Up @@ -13,15 +13,11 @@

import java.util.prefs.Preferences;

/**
* DimensionsConfig
*
* @author Anton Keks
*/
public class GUIConfig {
private Preferences preferences;

public boolean isFirstRun;
public boolean versionCheckEnabled;
public String lastRunVersion;
public long lastVersionCheck;
public int activeFeeder;
Expand All @@ -43,6 +39,7 @@ public enum DisplayMethod {ALL, ALIVE, PORTS}

private void load() {
isFirstRun = preferences.getBoolean("firstRun", true);
versionCheckEnabled = preferences.getBoolean("versionCheckEnabled", true);
lastRunVersion = preferences.get("lastRunVersion", "Unknown");
lastVersionCheck = preferences.getLong("lastVersionCheck", System.currentTimeMillis());
activeFeeder = preferences.getInt("activeFeeder", 0);
Expand All @@ -57,6 +54,7 @@ private void load() {

public void store() {
preferences.putBoolean("firstRun", isFirstRun);
preferences.putBoolean("versionCheckEnabled", versionCheckEnabled);
preferences.put("lastRunVersion", lastRunVersion);
preferences.putLong("lastVersionCheck", lastVersionCheck);
preferences.putInt("activeFeeder", activeFeeder);
Expand Down
9 changes: 7 additions & 2 deletions src/net/azib/ipscan/gui/PreferencesDialog.java
Expand Up @@ -62,6 +62,7 @@ public class PreferencesDialog extends AbstractModalDialog {
private Button[] displayMethod;
private Button showInfoCheckbox;
private Button askConfirmationCheckbox;
private Button versionCheckCheckbox;
private Combo languageCombo;

public PreferencesDialog(PingerRegistry pingerRegistry, Config globalConfig, ScannerConfig scannerConfig, GUIConfig guiConfig) {
Expand All @@ -77,7 +78,6 @@ public PreferencesDialog(PingerRegistry pingerRegistry, Config globalConfig, Sca

/**
* Opens the specified tab of preferences dialog
* @param tabIndex
*/
public void openTab(int tabIndex) {
// widgets are created on demand
Expand Down Expand Up @@ -276,7 +276,7 @@ private void createDisplayTab() {
askConfirmationCheckbox.setText(Labels.getLabel("preferences.display.confirmation.newScan"));
showInfoCheckbox = new Button(showStatsGroup, SWT.CHECK);
showInfoCheckbox.setText(Labels.getLabel("preferences.display.confirmation.showInfo"));

groupLayout = new GridLayout();
groupLayout.numColumns = 2;

Expand All @@ -292,6 +292,9 @@ private void createDisplayTab() {

label = new Label(languageGroup, SWT.NONE);
label.setText(Labels.getLabel("preferences.language.someIncomplete"));

versionCheckCheckbox = new Button(displayTab, SWT.CHECK);
versionCheckCheckbox.setText(Labels.getLabel("preferences.versionCheck"));
}

/**
Expand Down Expand Up @@ -386,6 +389,7 @@ private void loadPreferences() {
displayMethod[guiConfig.displayMethod.ordinal()].setSelection(true);
showInfoCheckbox.setSelection(guiConfig.showScanStats);
askConfirmationCheckbox.setSelection(guiConfig.askScanConfirmation);
versionCheckCheckbox.setSelection(guiConfig.versionCheckEnabled);
for (int i = 0; i < Labels.LANGUAGES.length; i++) {
if (globalConfig.language.equals(Labels.LANGUAGES[i])) {
languageCombo.select(i);
Expand Down Expand Up @@ -430,6 +434,7 @@ private void savePreferences() {
}
guiConfig.showScanStats = showInfoCheckbox.getSelection();
guiConfig.askScanConfirmation = askConfirmationCheckbox.getSelection();
guiConfig.versionCheckEnabled = versionCheckCheckbox.getSelection();
String newLanguage = Labels.LANGUAGES[languageCombo.getSelectionIndex()];
if (!newLanguage.equals(globalConfig.language)) {
globalConfig.language = newLanguage;
Expand Down
2 changes: 1 addition & 1 deletion src/net/azib/ipscan/gui/Startup.java
Expand Up @@ -38,7 +38,7 @@ else if (!Version.getVersion().equals(guiConfig.lastRunVersion)) {
new GoogleAnalytics().asyncReport("Update " + guiConfig.lastRunVersion + " to " + Version.getVersion());
guiConfig.lastRunVersion = Version.getVersion();
}
else if (System.currentTimeMillis() - guiConfig.lastVersionCheck > 30L * 24 * 3600 * 1000) {
else if (guiConfig.versionCheckEnabled && System.currentTimeMillis() - guiConfig.lastVersionCheck > 30L * 24 * 3600 * 1000) {
new GoogleAnalytics().asyncReport("Version check " + Version.getVersion());
checkForLatestVersion();
}
Expand Down

0 comments on commit af76b0f

Please sign in to comment.