Skip to content

Commit 1675a48

Browse files
committed
Fix UWP apps loading
1 parent fbeed59 commit 1675a48

File tree

1 file changed

+14
-17
lines changed
  • Plugins/Flow.Launcher.Plugin.Program/Programs

1 file changed

+14
-17
lines changed

Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -363,34 +363,37 @@ public Application(IAppxManifestApplication manifestApp, UWP package)
363363
BackgroundColor = manifestApp.GetStringValue("BackgroundColor");
364364
Package = package;
365365

366-
DisplayName = ResourceFromPri(package.FullName, DisplayName);
367-
Description = ResourceFromPri(package.FullName, Description);
366+
DisplayName = ResourceFromPri(package.FullName, package.Name, DisplayName);
367+
Description = ResourceFromPri(package.FullName, package.Name, Description);
368368
LogoUri = LogoUriFromManifest(manifestApp);
369369
LogoPath = LogoPathFromUri(LogoUri);
370370

371371
Enabled = true;
372372
}
373373

374-
internal string ResourceFromPri(string packageFullName, string resourceReference)
374+
internal string ResourceFromPri(string packageFullName, string packageName, string resourceReference)
375375
{
376376
const string prefix = "ms-resource:";
377377
if (!string.IsNullOrWhiteSpace(resourceReference) && resourceReference.StartsWith(prefix))
378378
{
379-
// magic comes from @talynone
380-
// https://github.com/talynone/Wox.Plugin.WindowsUniversalAppLauncher/blob/master/StoreAppLauncher/Helpers/NativeApiHelper.cs#L139-L153
381379
string key = resourceReference.Substring(prefix.Length);
382380
string parsed;
383381
if (key.StartsWith("//"))
384382
{
385-
parsed = prefix + key;
386-
}
387-
else if (key.StartsWith("/"))
388-
{
389-
parsed = prefix + "//" + key;
383+
parsed = $"{prefix}{key}";
390384
}
391385
else
392386
{
393-
parsed = prefix + "///resources/" + key;
387+
if (!key.StartsWith("/"))
388+
{
389+
key = $"/{key}";
390+
}
391+
392+
if (!key.ToLower().Contains("resources"))
393+
{
394+
key = $"/Resources{key}";
395+
}
396+
parsed = $"{prefix}//{packageName}{key}";
394397
}
395398

396399
var outBuffer = new StringBuilder(128);
@@ -413,12 +416,6 @@ internal string ResourceFromPri(string packageFullName, string resourceReference
413416
}
414417
else
415418
{
416-
// https://github.com/Wox-launcher/Wox/issues/964
417-
// known hresult 2147942522:
418-
// 'Microsoft Corporation' violates pattern constraint of '\bms-resource:.{1,256}'.
419-
// for
420-
// Microsoft.MicrosoftOfficeHub_17.7608.23501.0_x64__8wekyb3d8bbwe: ms-resource://Microsoft.MicrosoftOfficeHub/officehubintl/AppManifest_GetOffice_Description
421-
// Microsoft.BingFoodAndDrink_3.0.4.336_x64__8wekyb3d8bbwe: ms-resource:AppDescription
422419
var e = Marshal.GetExceptionForHR((int)hResult);
423420
ProgramLogger.LogException($"|UWP|ResourceFromPri|{Package.Location}|Load pri failed {source} with HResult {hResult} and location {Package.Location}", e);
424421
return string.Empty;

0 commit comments

Comments
 (0)