Made the app report that an update is required if the server says it is.

This commit is contained in:
Lars Brubaker 2016-08-03 14:45:33 -07:00
parent 64b6eb0f18
commit d5d42d475f
5 changed files with 58 additions and 10 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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.

@ -1 +1 @@
Subproject commit 0690f3c3de22f17f3a504dfb63ccd3b779e8e60d
Subproject commit 618ed7057c9ad8cd970f0fd9e0fe9121ee73b921