Skip to content

Commit

Permalink
Further improvements to GUI Update Button logic
Browse files Browse the repository at this point in the history
  • Loading branch information
retiutut committed Sep 29, 2021
1 parent 94190a9 commit 2edced4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Improvements
* Show info in footer when a new version of the GUI is available #992
* Further improvements to GUI Update Button logic
* Add GUI-wide settings class to keep certain settings across sessions and app starts #997
* Remove 30 second window option from Focus widget

Expand Down
1 change: 1 addition & 0 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ String localGUIVersionString = "v5.0.7";
String localGUIVersionDate = "September 2021";
String guiLatestVersionGithubAPI = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases/latest";
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
Boolean guiIsUpToDate;

PApplet ourApplet;

Expand Down
15 changes: 10 additions & 5 deletions OpenBCI_GUI/TopNav.pde
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,20 @@ class TopNav {
updateGuiVersionButton = createTNButton("updateGuiVersionButton", text, _x, _y, _w, _h, font, _fontSize, _bg, _textColor);
//Attempt to compare local and remote GUI versions when TopNav is instantiated
//This will also set the description/help-text for this cp5 button
final Boolean upToDate = guiVersionIsUpToDate();
//Do this check on app start and store as a global variable
guiIsUpToDate = guiVersionIsUpToDate();

updateGuiVersionButton.onRelease(new CallbackListener() {
public void controlEvent(CallbackEvent theEvent) {
if (upToDate == null) {
//Perform check again when button is pressed. User may have connected to internet by now!
guiIsUpToDate = guiVersionIsUpToDate();

if (guiIsUpToDate == null) {
outputError("Update GUI: Unable to check for new version of GUI. Try again when connected to the internet.");
return;
}

if (!upToDate) {
if (!guiIsUpToDate) {
openURLInBrowser(guiLatestReleaseLocation);
outputInfo("Update GUI: Opening latest GUI release page using default browser");
} else {
Expand All @@ -550,11 +555,11 @@ class TopNav {
}
});

if (upToDate == null) {
if (guiIsUpToDate == null) {
return;
}

if (!upToDate) {
if (!guiIsUpToDate) {
outputWarn("Update Available! Press the \"Update\" button at the top of the GUI to download the latest version.");
}
}
Expand Down

0 comments on commit 2edced4

Please sign in to comment.