Skip to content

Commit

Permalink
Finalized new menu page
Browse files Browse the repository at this point in the history
  • Loading branch information
valnoxy committed Dec 25, 2024
1 parent 2069224 commit e6f6200
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 67 deletions.
Binary file not shown.
18 changes: 18 additions & 0 deletions GoAwayEdge.Helper.Package/GoAwayEdge.Helper.Package.wapproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Source>C:\Users\jonas\Pictures\GoAwayEdge.png</Source>
<SmallTileSource>C:\Users\jonas\Pictures\GoAwayEdge.png</SmallTileSource>
<MediumTileSource>C:\Users\jonas\Pictures\GoAwayEdge.png</MediumTileSource>
<WideTileSource>C:\Users\jonas\Pictures\GoAwayEdge.png</WideTileSource>
<LargeTileSource>C:\Users\jonas\Pictures\GoAwayEdge.png</LargeTileSource>
<AppIconSource>C:\Users\jonas\Pictures\GoAwayEdge.png</AppIconSource>
<SplashScreenSource>C:\Users\jonas\Pictures\GoAwayEdge.png</SplashScreenSource>
<PackageLogoSource>C:\Users\jonas\Pictures\GoAwayEdge.png</PackageLogoSource>
<BadgeLogoSource>C:\Users\jonas\Pictures\GoAwayEdge.png</BadgeLogoSource>
<UapAppxPackageBuildMode>SideloadOnly</UapAppxPackageBuildMode>
<AppxShowAllApps>False</AppxShowAllApps>
<AppxBuildConfigurationSelection>x64|arm64</AppxBuildConfigurationSelection>
<PackageOptionalProjectsInIdeBuilds>False</PackageOptionalProjectsInIdeBuilds>
</PropertyGroup>
</Project>
12 changes: 0 additions & 12 deletions GoAwayEdge.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,22 @@ Global
{95F3960E-372B-45F3-85D8-CD06F4D8B271}.Release|x86.ActiveCfg = Release|Any CPU
{95F3960E-372B-45F3-85D8-CD06F4D8B271}.Release|x86.Build.0 = Release|Any CPU
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Debug|ARM64.Build.0 = Debug|Any CPU
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Debug|x64.ActiveCfg = Debug|x64
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Debug|x64.Build.0 = Debug|x64
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Debug|x86.ActiveCfg = Debug|x86
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Debug|x86.Build.0 = Debug|x86
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Release|ARM64.ActiveCfg = Release|Any CPU
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Release|ARM64.Build.0 = Release|Any CPU
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Release|x64.ActiveCfg = Release|x64
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Release|x64.Build.0 = Release|x64
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Release|x86.ActiveCfg = Release|x86
{A1CB967D-9105-47AF-BBB1-F2BA694014F1}.Release|x86.Build.0 = Release|x86
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|ARM64.ActiveCfg = Debug|ARM64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|ARM64.Build.0 = Debug|ARM64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|ARM64.Deploy.0 = Debug|ARM64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|x64.ActiveCfg = Debug|x64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|x64.Build.0 = Debug|x64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|x64.Deploy.0 = Debug|x64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|x86.ActiveCfg = Debug|x86
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|x86.Build.0 = Debug|x86
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Debug|x86.Deploy.0 = Debug|x86
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|ARM64.ActiveCfg = Release|ARM64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|ARM64.Build.0 = Release|ARM64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|ARM64.Deploy.0 = Release|ARM64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|x64.ActiveCfg = Release|x64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|x64.Build.0 = Release|x64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|x64.Deploy.0 = Release|x64
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|x86.ActiveCfg = Release|x86
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|x86.Build.0 = Release|x86
{6B1C2331-6097-4559-9D50-62D3E906E2E6}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
Expand Down
12 changes: 6 additions & 6 deletions GoAwayEdge/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
IsDebug = true;
if (IsAdministrator() == false)
{
ElevateAsAdmin();
ElevateAsAdmin();
Environment.Exit(0);
return;
}
Expand All @@ -70,7 +70,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
{
if (IsAdministrator() == false)
{
ElevateAsAdmin(string.Join(" ", args));
ElevateAsAdmin(string.Join(" ", args));
Environment.Exit(0);
return;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public void Application_Startup(object sender, StartupEventArgs e)

if (IsAdministrator() == false)
{
ElevateAsAdmin(string.Join(" ", args));
ElevateAsAdmin(string.Join(" ", args));
Environment.Exit(0);
return;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
ifeoMessageUi.ShowDialog();

if (ifeoMessageUi.Summary == "Btn1")
ElevateAsAdmin("--update");
ElevateAsAdmin("--update");

Environment.Exit(0);
}
Expand All @@ -207,7 +207,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
ifeoMessageUi.ShowDialog();

if (ifeoMessageUi.Summary == "Btn1")
ElevateAsAdmin("--update");
ElevateAsAdmin("--update");

Environment.Exit(0);
}
Expand All @@ -226,7 +226,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
Environment.Exit(0);
}

private void ElevateAsAdmin(string arguments = null)
private static void ElevateAsAdmin(string? arguments = null)
{
// Restart program and run as admin
var exeName = Process.GetCurrentProcess().MainModule?.FileName;
Expand Down
10 changes: 4 additions & 6 deletions GoAwayEdge/Common/Debugging/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ public static void Initialize()

// Fetching the current log file
_logFile = Path.Combine(LogPath, $"log_{DateTime.Now:yyyy-MM-dd}.txt");
if (!File.Exists(_logFile))
{
var version = Assembly.GetExecutingAssembly().GetName().Version!;
Log($"GoAwayEdge {version.Major}.{version.Minor}.{version.Build} (Build {version.Revision})");
Log("Logging system initialized");
}

var version = Assembly.GetExecutingAssembly().GetName().Version!;
Log($"GoAwayEdge {version.Major}.{version.Minor}.{version.Build} (Build {version.Revision})");
Log("Logging system initialized");

// Delete old log files
DeleteOldLogFiles();
Expand Down
20 changes: 19 additions & 1 deletion GoAwayEdge/Common/Installation/Removal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public static bool RemoveMsEdge()
}
var edgeUpdateDevKey = Registry.LocalMachine.CreateSubKey($@"SOFTWARE{node}\Microsoft\EdgeUpdateDev");
edgeUpdateDevKey.SetValue("AllowUninstall", 1, RegistryValueKind.DWord);
var edgeUpdateKey = Registry.LocalMachine.CreateSubKey($@"SOFTWARE{node}\Microsoft\EdgeUpdate");
edgeUpdateKey.SetValue("AllowUninstall", 1, RegistryValueKind.DWord);
}
}
}
Expand Down Expand Up @@ -233,19 +235,28 @@ public static bool RemoveMsEdge()

timeoutStopwatch.Stop();
if (timeoutStopwatch.Elapsed.TotalSeconds >= 60)
{
Logging.Log("Removal of Edge Updater failed: Timeout after 60 seconds.");
return false; // Timeout
}

if (proc.ExitCode != 0 && proc.ExitCode != 19)
{
Logging.Log($"Removal of Edge Updater failed: Unknown error has occurred (exited with error code {proc.ExitCode})");
return false; // Unknown error?
}
}

using (var proc = new Process()) // Remove Edge via setup file
{
const string removalArgs = "--uninstall --msedge --system-level --verbose-logging --force-uninstall";
var psi = new ProcessStartInfo
{
FileName = edgeSetupPath,
Arguments = "--uninstall --msedge --system-level --verbose-logging --force-uninstall",
Arguments = removalArgs,
RedirectStandardOutput = true
};
Logging.Log($"Executing \"{edgeSetupPath}\" {removalArgs}");
proc.StartInfo = psi;
proc.Start();
proc.WaitForExit();
Expand All @@ -259,9 +270,16 @@ public static bool RemoveMsEdge()

timeoutStopwatch.Stop();
if (timeoutStopwatch.Elapsed.TotalSeconds >= 60)
{
Logging.Log("Removal of Edge failed: Timeout after 60 seconds.");
return false; // Timeout
}

if (proc.ExitCode != 0 && proc.ExitCode != 19)
{
Logging.Log($"Removal of Edge via Setup file failed: Unknown error has occurred (exited with error code {proc.ExitCode})");
return false; // Unknown error?
}
}
}
}
Expand Down
57 changes: 38 additions & 19 deletions GoAwayEdge/Common/Installation/Updater.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Security.Cryptography;
using Microsoft.Toolkit.Uwp.Notifications;
Expand All @@ -13,14 +14,14 @@ internal class Updater
{
public class GitHubRelease
{
public string tag_name { get; set; }
public List<GitHubAsset> assets { get; set; }
public string? tag_name { get; set; }
public List<GitHubAsset>? assets { get; set; }
}

public class GitHubAsset
{
public string browser_download_url { get; set; }
public string name { get; set; }
public string? browser_download_url { get; set; }
public string? name { get; set; }
}


Expand Down Expand Up @@ -143,15 +144,18 @@ public static void ModifyIfeoBinary(ModifyAction action)
var appVersion = Assembly.GetExecutingAssembly().GetName().Version!;
var currentVersion = new Version(appVersion.Major, appVersion.Minor, appVersion.Build);

using var client = new WebClient();
client.Headers.Add("User-Agent", $"GoAwayEdge/{currentVersion} valnoxy.dev");
var json = client.DownloadString(url);
using var client = new HttpClient();
client.DefaultRequestHeaders.UserAgent.ParseAdd($"GoAwayEdge/{currentVersion} valnoxy.dev");

var response = client.GetAsync(url).Result;
response.EnsureSuccessStatusCode();
var json = response.Content.ReadAsStringAsync().Result;

var releases = JsonConvert.DeserializeObject<GitHubRelease[]>(json);
if (releases is { Length: > 0 })
{
var tagName = Convert.ToString(releases[0].tag_name);
var tagVersion = tagName[1..];
var tagVersion = tagName![1..];
var latestVersion = new Version(tagVersion);

if (currentVersion < latestVersion)
Expand All @@ -165,7 +169,7 @@ public static void ModifyIfeoBinary(ModifyAction action)
return null;
}
}

/// <summary>
/// Download and run the new version of GoAwayEdge.
/// </summary>
Expand All @@ -178,39 +182,54 @@ public static bool UpdateClient()
var appVersion = Assembly.GetExecutingAssembly().GetName().Version!;
var currentVersion = new Version(appVersion.Major, appVersion.Minor, appVersion.Build);

using var client = new WebClient();
client.Headers.Add("User-Agent", $"GoAwayEdge/{currentVersion} valnoxy.dev");
var json = client.DownloadString(url);
using var client = new HttpClient();
client.DefaultRequestHeaders.UserAgent.ParseAdd($"GoAwayEdge/{currentVersion} valnoxy.dev");

var response = client.GetAsync(url).Result;
response.EnsureSuccessStatusCode();
var json = response.Content.ReadAsStringAsync().Result;

var releases = JsonConvert.DeserializeObject<GitHubRelease[]>(json);
if (releases is { Length: > 0 })
{
var assetUrl = string.Empty;
foreach (var asset in releases[0].assets.Where(asset => asset.name == "GoAwayEdge.exe"))
foreach (var asset in releases[0].assets!.Where(asset => asset.name == "GoAwayEdge.exe"))
{
assetUrl = asset.browser_download_url;
}

var tempFolder = Path.GetTempPath();

if (string.IsNullOrEmpty(assetUrl))
{
return false;
}

if (File.Exists(Path.Combine(tempFolder, "GoAwayEdge.exe")))
File.Delete(Path.Combine(tempFolder, "GoAwayEdge.exe"));
client.DownloadFile(assetUrl, Path.Combine(tempFolder, "GoAwayEdge.exe"));
Process.Start(Path.Combine(tempFolder, "GoAwayEdge.exe"));
var tempFolder = Path.GetTempPath();
var tempFilePath = Path.Combine(tempFolder, "GoAwayEdge.exe");

if (File.Exists(tempFilePath))
{
File.Delete(tempFilePath);
}

using (var downloadStream = client.GetStreamAsync(assetUrl).Result)
using (var fileStream = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
downloadStream.CopyTo(fileStream);
}

Process.Start(new ProcessStartInfo(tempFilePath) { UseShellExecute = true });
return true;
}
}
catch
{
return false;
}

return false;
}


private static string CalculateMd5(string filename)
{
using var md5 = MD5.Create();
Expand Down
22 changes: 19 additions & 3 deletions GoAwayEdge/Common/Localization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ public static string LocalizeValue(string value)
try
{
var localizedValue = (string)Application.Current.Resources[value]!;
return string.IsNullOrEmpty(localizedValue) ? value : localizedValue;

if (string.IsNullOrEmpty(localizedValue))
return value;

if (localizedValue.Contains("\\n"))
{
return localizedValue.Replace("\\n", "\n");
}

return localizedValue;
}
catch (Exception ex)
{
Expand All @@ -70,11 +79,17 @@ public static string LocalizeValue(string value, params object[]? args)
{
var localizedValue = LocalizeValue(value);

if (args is not { Length: > 0 }) return localizedValue;

if (args is not { Length: > 0 })
return localizedValue;

try
{
localizedValue = string.Format(localizedValue, args);

if (localizedValue.Contains("\\n"))
{
localizedValue = localizedValue.Replace("\\n", "\n");
}
}
catch (FormatException ex)
{
Expand All @@ -84,5 +99,6 @@ public static string LocalizeValue(string value, params object[]? args)

return localizedValue;
}

}
}
2 changes: 1 addition & 1 deletion GoAwayEdge/Common/Runtime/ArgumentParse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void Parse(string[] args)
{
var appId = match.Groups[1].Value;
Logging.Log($"Opening PWA App with ID {appId}");
if (appId == copilotAppId)
if (appId == copilotAppId && Common.Configuration.AiProvider != AiProvider.Default)
{
DebugMessage.DisplayDebugMessage("GoAwayEdge", $"Opening AI Provider '{Configuration.AiProvider}' (PWA) ...");
UserInterface.CopilotDock.InterfaceManager.ShowDock();
Expand Down
12 changes: 6 additions & 6 deletions GoAwayEdge/Common/Runtime/Weather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public class Weather
{
public class GeoData
{
public string L { get; set; } // City
public string R { get; set; } // Region
public string C { get; set; } // Country
public string I { get; set; } // Short Country code
public string G { get; set; } // Country code (lowercase)
public string? L { get; set; } // City
public string? R { get; set; } // Region
public string? C { get; set; } // Country
public string? I { get; set; } // Short Country code
public string? G { get; set; } // Country code (lowercase)
public double X { get; set; } // longitude
public double Y { get; set; } // latitude
}
Expand Down Expand Up @@ -42,7 +42,7 @@ public class GeoData
var placeholders = new Dictionary<string, string>
{
{ "country-code", language },
{ "short-country-code", locObject.I },
{ "short-country-code", locObject.I! },
{ "latitude", lat },
{ "longitude", lon }
};
Expand Down
2 changes: 1 addition & 1 deletion GoAwayEdge/GoAwayEdge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<AssemblyName>GoAwayEdge</AssemblyName>
<Company>Exploitox</Company>
<Authors>valnoxy</Authors>
<Version>2.0.0.257</Version>
<Version>2.0.0.258</Version>
<Copyright>Copyright © 2018 - 2025 Exploitox. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/valnoxy/GoAwayEdge</PackageProjectUrl>
<RepositoryUrl>https://github.com/valnoxy/GoAwayEdge</RepositoryUrl>
Expand Down
Loading

0 comments on commit e6f6200

Please sign in to comment.