From 1675a482029d5889aa154a08fd559ff4e2990bdb Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 25 Apr 2020 15:07:40 +1000 Subject: [PATCH] Fix UWP apps loading --- .../Programs/UWP.cs | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 927c8784c..e2d90b1e0 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -363,34 +363,37 @@ namespace Flow.Launcher.Plugin.Program.Programs BackgroundColor = manifestApp.GetStringValue("BackgroundColor"); Package = package; - DisplayName = ResourceFromPri(package.FullName, DisplayName); - Description = ResourceFromPri(package.FullName, Description); + DisplayName = ResourceFromPri(package.FullName, package.Name, DisplayName); + Description = ResourceFromPri(package.FullName, package.Name, Description); LogoUri = LogoUriFromManifest(manifestApp); LogoPath = LogoPathFromUri(LogoUri); Enabled = true; } - internal string ResourceFromPri(string packageFullName, string resourceReference) + internal string ResourceFromPri(string packageFullName, string packageName, string resourceReference) { const string prefix = "ms-resource:"; if (!string.IsNullOrWhiteSpace(resourceReference) && resourceReference.StartsWith(prefix)) { - // magic comes from @talynone - // https://github.com/talynone/Wox.Plugin.WindowsUniversalAppLauncher/blob/master/StoreAppLauncher/Helpers/NativeApiHelper.cs#L139-L153 string key = resourceReference.Substring(prefix.Length); string parsed; if (key.StartsWith("//")) { - parsed = prefix + key; - } - else if (key.StartsWith("/")) - { - parsed = prefix + "//" + key; + parsed = $"{prefix}{key}"; } else { - parsed = prefix + "///resources/" + key; + if (!key.StartsWith("/")) + { + key = $"/{key}"; + } + + if (!key.ToLower().Contains("resources")) + { + key = $"/Resources{key}"; + } + parsed = $"{prefix}//{packageName}{key}"; } var outBuffer = new StringBuilder(128); @@ -413,12 +416,6 @@ namespace Flow.Launcher.Plugin.Program.Programs } else { - // https://github.com/Wox-launcher/Wox/issues/964 - // known hresult 2147942522: - // 'Microsoft Corporation' violates pattern constraint of '\bms-resource:.{1,256}'. - // for - // Microsoft.MicrosoftOfficeHub_17.7608.23501.0_x64__8wekyb3d8bbwe: ms-resource://Microsoft.MicrosoftOfficeHub/officehubintl/AppManifest_GetOffice_Description - // Microsoft.BingFoodAndDrink_3.0.4.336_x64__8wekyb3d8bbwe: ms-resource:AppDescription var e = Marshal.GetExceptionForHR((int)hResult); ProgramLogger.LogException($"|UWP|ResourceFromPri|{Package.Location}|Load pri failed {source} with HResult {hResult} and location {Package.Location}", e); return string.Empty;