From d5d42d475fb56c835096f20d2e454101601b2932 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 3 Aug 2016 14:45:33 -0700 Subject: [PATCH] Made the app report that an update is required if the server says it is. --- AboutPage/CheckForUpdateWindow.cs | 24 +++++++++++++++++------- AboutPage/UpdateControlData.cs | 24 +++++++++++++++++++++++- AboutPage/UpdateControlView.cs | 12 +++++++++++- StaticData/Translations/Master.txt | 6 ++++++ Submodules/agg-sharp | 2 +- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/AboutPage/CheckForUpdateWindow.cs b/AboutPage/CheckForUpdateWindow.cs index 6464c6556..a9eb1d7d7 100644 --- a/AboutPage/CheckForUpdateWindow.cs +++ b/AboutPage/CheckForUpdateWindow.cs @@ -29,9 +29,7 @@ namespace MatterHackers.MatterControl.AboutPage private static CheckForUpdateWindow checkUpdate = null; TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); - string pathToStableBuildFeatures; DropDownList releaseOptionsDropList; - FlowLayoutWidget additionalInfoContainer; TextWidget stableInfoLabel; TextWidget alphaInfoLabel; TextWidget betaInfoLabel; @@ -59,9 +57,14 @@ namespace MatterHackers.MatterControl.AboutPage currentFeedAndDropDownContainer.HAnchor = HAnchor.ParentLeftRight; currentFeedAndDropDownContainer.Margin = new BorderDouble(0,5,0,0); currentFeedAndDropDownContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; - - TextWidget checkUpdateLabel = new TextWidget("Check for Update".Localize(), pointSize: 20); - checkUpdateLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; + + TextWidget checkUpdateLabel = new TextWidget("Check for Update".Localize(), pointSize: 20); + if (UpdateControlData.Instance.UpdateRequired) + { + checkUpdateLabel = new TextWidget("Update Required".Localize(), pointSize: 20); + } + + checkUpdateLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkUpdateLabel.Margin = new BorderDouble(2, 10, 10, 5); UpdateControlView updateStatusWidget = new UpdateControlView(); @@ -184,8 +187,15 @@ namespace MatterHackers.MatterControl.AboutPage this.AddChild(topToBottom); additionalInfoContainer.Visible = false; - this.Title = "Check for Update".Localize(); - this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + if (UpdateControlData.Instance.UpdateRequired) + { + this.Title = "Update Required".Localize(); + } + else + { + this.Title = "Check for Update".Localize(); + } + this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.ShowAsSystemWindow(); this.AlwaysOnTopOfMain = true; diff --git a/AboutPage/UpdateControlData.cs b/AboutPage/UpdateControlData.cs index 899b0f341..c2eb14a35 100644 --- a/AboutPage/UpdateControlData.cs +++ b/AboutPage/UpdateControlData.cs @@ -31,6 +31,9 @@ using MatterHackers.Agg; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; using MatterHackers.Localizations; +#if !__ANDROID__ +using MatterHackers.MatterControl.AboutPage; +#endif using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.SettingsManagement; using MatterHackers.MatterControl.VersionManagement; @@ -56,7 +59,7 @@ namespace MatterHackers.MatterControl private UpdateRequestType updateRequestType; - public enum UpdateStatusStates { MayBeAvailable, CheckingForUpdate, UpdateAvailable, UpdateDownloading, ReadyToInstall, UpToDate, UnableToConnectToServer }; + public enum UpdateStatusStates { MayBeAvailable, CheckingForUpdate, UpdateAvailable, UpdateDownloading, ReadyToInstall, UpToDate, UnableToConnectToServer, UpdateRequired }; private bool WaitingToCompleteTransaction() { @@ -111,12 +114,21 @@ namespace MatterHackers.MatterControl } } + static bool haveShowUpdateRequired = false; private void SetUpdateStatus(UpdateStatusStates updateStatus) { if (this.updateStatus != updateStatus) { this.updateStatus = updateStatus; OnUpdateStatusChanged(null); + + if (this.UpdateRequired && !haveShowUpdateRequired) + { + haveShowUpdateRequired = true; +#if !__ANDROID__ + UiThread.RunOnIdle(CheckForUpdateWindow.Show); +#endif + } } } @@ -158,6 +170,16 @@ namespace MatterHackers.MatterControl } } + public bool UpdateRequired + { + get + { + return updateStatus == UpdateStatusStates.UpdateAvailable && ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.UpdateRequired) == "True"; + } + + private set {} + } + public void CheckForUpdateUserRequested() { updateRequestType = UpdateRequestType.UserRequested; diff --git a/AboutPage/UpdateControlView.cs b/AboutPage/UpdateControlView.cs index 50a9b6184..b0f36ed9c 100644 --- a/AboutPage/UpdateControlView.cs +++ b/AboutPage/UpdateControlView.cs @@ -130,6 +130,9 @@ namespace MatterHackers.MatterControl UpdateControlData.Instance.InitiateUpdateDownload(); } + static string recommendedUpdateAvailable = "There is a recommended update available.".Localize(); + static string requiredUpdateAvailable = "There is a required update available.".Localize(); + private void UpdateStatusChanged(object sender, EventArgs e) { switch (UpdateControlData.Instance.UpdateStatus) @@ -152,7 +155,14 @@ namespace MatterHackers.MatterControl break; case UpdateControlData.UpdateStatusStates.UpdateAvailable: - updateStatusText.Text = string.Format("There is a recommended update available.".Localize()); + if (UpdateControlData.Instance.UpdateRequired) + { + updateStatusText.Text = requiredUpdateAvailable; + } + else + { + updateStatusText.Text = recommendedUpdateAvailable; + } downloadUpdateLink.Visible = true; installUpdateLink.Visible = false; checkUpdateLink.Visible = false; diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 92ffc4ba5..dea458f2d 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -5302,3 +5302,9 @@ Translated:Sync English:The position (X and Y coordinates) of the center of the print bed, in millimeters. Normally this is 1/2 the bed size for Cartesian printers and 0, 0 for Delta printers. Translated:The position (X and Y coordinates) of the center of the print bed, in millimeters. Normally this is 1/2 the bed size for Cartesian printers and 0, 0 for Delta printers. +English:Update Required +Translated:Update Required + +English:There is a required update available. +Translated:There is a required update available. + diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 0690f3c3d..618ed7057 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 0690f3c3de22f17f3a504dfb63ccd3b779e8e60d +Subproject commit 618ed7057c9ad8cd970f0fd9e0fe9121ee73b921