Check if the connection is metered and, if so, ask the user if they want to proceed

This commit is contained in:
Bugadinho 2025-01-05 23:22:27 -03:00
parent 5d1aa50753
commit 1c02c8c1b3
No known key found for this signature in database
GPG Key ID: B105A6D586EEBCFA
3 changed files with 31 additions and 0 deletions

View File

@ -18,6 +18,7 @@ using System.Windows.Forms;
using System.Windows.Shell;
using Microsoft.Win32;
using Windows.Networking.Connectivity;
using Bloxstrap.AppData;
using Bloxstrap.RobloxInterfaces;
@ -578,6 +579,24 @@ namespace Bloxstrap
string version = App.Version;
#endif
// check if we are on a metered connection, as updating Bloxstrap might incur additional costs
var profile = NetworkInformation.GetInternetConnectionProfile();
bool meteredConnection = (profile != null) && (profile.GetConnectionCost().NetworkCostType != NetworkCostType.Unrestricted);
if (meteredConnection)
{
App.Logger.WriteLine(LOG_IDENT, "Metered connection detected");
var result = Frontend.ShowMessageBox(
Strings.Bootstrapper_AutoUpdateMetered,
MessageBoxImage.Exclamation,
MessageBoxButton.YesNo
);
if (result != MessageBoxResult.Yes)
return false;
}
SetStatus(Strings.Bootstrapper_Status_UpgradingBloxstrap);
try

View File

@ -160,6 +160,15 @@ namespace Bloxstrap.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to An update for Bloxstrap is available, but it has been detected you are currently using a metered connection. Would you like to update now?.
/// </summary>
public static string Bootstrapper_AutoUpdateMetered {
get {
return ResourceManager.GetString("Bootstrapper.AutoUpdateMetered", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Roblox is currently running, and launching another instance will close it. Are you sure you want to continue launching?.
/// </summary>

View File

@ -1267,4 +1267,7 @@ Please close any applications that may be using Roblox's files, and relaunch.</v
<value>All Bloxstrap logs</value>
<comment>Label that appears next to a checkbox</comment>
</data>
<data name="Bootstrapper.AutoUpdateMetered" xml:space="preserve">
<value>An update for Bloxstrap is available, but it has been detected you are currently using a metered connection. Would you like to update now?</value>
</data>
</root>