Files
rookie/Updater.cs
jp64k bbe4050b40 Completed comprehensive rookie redesign with extensive UI/UX modernization, new theme and architectural improvements
Implemented a custom theme with a new color scheme and extensively refined UI logic and architecture for improved modernity and consistency. Relocated and reworked numerous options (mount device, select device, share app, uninstall app, pull-to-desktop, filters, etc.), and updated all message boxes to use the new themed styling with enhanced visual polish. All message boxes now use custom themed styling with enhanced visual polish. Corrected grammatical or logical flaws across text, tooltips, and title updates throughout the application. Added smooth animations to left-side navigation / container elements. Fine-tuned sizing, positioning, and colors across numerous UI components. Enhanced GalleryView with proper favorites support including context menu integration, favorite border styling and favorite badge, as well as some bug fixes. Implemented custom modern ToggleSwitch component (iOS-like) with animations. Completely overhauled quest option and rookie option menus to utilize new toggle switches in modernized layouts. Refined sorting and installation status logic to streamline UX; rookie now also functions as an efficient installed-quest-app browser with easily accessible view/uninstall controls. Added WebView2.dll validation to ensure runtime dependencies exist. Re-implemented trailer option. GalleryView is now shown on very first launch, but rookie remembers your preferred view thereafter, so list-view users won't be bothered, while everyone still gets to see the new gallery view at least once. Gallery performance has also been validated on very-low-spec hardware and confirmed to run fine and fast there, due to numerous optimizations. Given the extensive scope of changes across this commit series for beta-2.35-yt, I believe this update represents a significant milestone warranting v3.0 designation. In my opinion these changes represent one of the most significant set of logical and visual changes and enhancements the rookie application has seen in years. Changes have been summarized in changelog.txt for update.
2025-12-07 19:57:09 +01:00

110 lines
4.2 KiB
C#

using System;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace AndroidSideloader
{
internal class Updater
{
public static string AppName { get; set; }
public static string Repository { get; set; }
private static readonly string RawGitHubUrl = "https://raw.githubusercontent.com/VRPirates/rookie";
private static readonly string GitHubUrl = "https://github.com/VRPirates/rookie";
public static readonly string LocalVersion = "3.0";
public static string currentVersion = string.Empty;
public static string changelog = string.Empty;
// Check if there is a new version of the sideloader
private static async Task<bool> IsUpdateAvailableAsync()
{
using (HttpClient client = new HttpClient())
{
try
{
currentVersion = await client.GetStringAsync($"{RawGitHubUrl}/master/version");
changelog = await client.GetStringAsync($"{RawGitHubUrl}/master/changelog.txt");
currentVersion = currentVersion.Trim();
}
catch (HttpRequestException)
{
return false;
}
}
// Compare versions - only return true if server version is greater than local version
return CompareVersions(currentVersion, LocalVersion.Trim()) > 0;
}
// Compares two semantic version strings (e.g., "2.35")
// returns: 1 if version1 > version2, -1 if version1 < version2, 0 if equal
private static int CompareVersions(string version1, string version2)
{
try
{
// Parse versions into parts
string[] parts1 = version1.Split('.');
string[] parts2 = version2.Split('.');
// Compare each part
int maxLength = Math.Max(parts1.Length, parts2.Length);
for (int i = 0; i < maxLength; i++)
{
int v1 = i < parts1.Length && int.TryParse(parts1[i], out int p1) ? p1 : 0;
int v2 = i < parts2.Length && int.TryParse(parts2[i], out int p2) ? p2 : 0;
if (v1 > v2) return 1;
if (v1 < v2) return -1;
}
return 0; // Versions are equal
}
catch
{
// Fallback to string comparison if parsing fails
return string.Compare(version1, version2, StringComparison.Ordinal);
}
}
// Ask the user if they want to update
public static async Task Update()
{
if (await IsUpdateAvailableAsync())
{
UpdateForm upForm = new UpdateForm();
_ = upForm.ShowDialog();
}
}
// If the user wants to update
public static void doUpdate()
{
try
{
ADB.RunAdbCommandToString("kill-server");
using (WebClient fileClient = new WebClient())
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Logger.Log($"Downloading update from {GitHubUrl}/releases/download/v{currentVersion}/{AppName}.exe to {AppName} v{currentVersion}.exe");
fileClient.DownloadFile($"{GitHubUrl}/releases/download/v{currentVersion}/{AppName}.exe", $"{AppName} v{currentVersion}.exe");
Logger.Log($"Starting {AppName} v{currentVersion}.exe");
Process.Start($"{AppName} v{currentVersion}.exe");
}
// Delete current version
AndroidSideloader.Utilities.GeneralUtilities.Melt();
}
catch (Exception ex)
{
// Handle specific exceptions that might occur during the update process
Logger.Log($"Update failed: {ex.Message}");
}
}
}
}