Skip to content

Commit

Permalink
Release 1.9.3 (#1052)
Browse files Browse the repository at this point in the history
## Bug fixes
- Addresses the issue where WindowsSettings plugin results appear higher than other results #1020 

- Fixed an issue where full screen mode does not disable hotkey when enabled #1037 

- Fixed some potential issues when loading plugins that use shared assembly #1036 

- Sorted out a race condition issue causing image loading on some results to fail #1040 

- Revised ttf/otf support #935 

- Resolved the issue where WebSearch plugin would crash if not connected to internet #977 

- Fixed incorrect text for "New Tab" and "New Window" buttons under Settings' default browser section #951 

- Fixed typos in plugin title and WindowsSettings name inside the context menu #1056
  • Loading branch information
jjw24 authored Mar 3, 2022
1 parent 68101e0 commit 84a806b
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 86 deletions.
24 changes: 2 additions & 22 deletions Flow.Launcher.Core/Plugin/PluginAssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ internal class PluginAssemblyLoader : AssemblyLoadContext

private readonly AssemblyName assemblyName;

private static readonly ConcurrentDictionary<string, byte> loadedAssembly;

static PluginAssemblyLoader()
{
var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies();
loadedAssembly = new ConcurrentDictionary<string, byte>(
currentAssemblies.Select(x => new KeyValuePair<string, byte>(x.FullName, default)));

AppDomain.CurrentDomain.AssemblyLoad += (sender, args) =>
{
loadedAssembly[args.LoadedAssembly.FullName] = default;
};
}

internal PluginAssemblyLoader(string assemblyFilePath)
{
dependencyResolver = new AssemblyDependencyResolver(assemblyFilePath);
Expand All @@ -47,21 +33,15 @@ protected override Assembly Load(AssemblyName assemblyName)
// When resolving dependencies, ignore assembly depenedencies that already exits with Flow.Launcher
// Otherwise duplicate assembly will be loaded and some weird behavior will occur, such as WinRT.Runtime.dll
// will fail due to loading multiple versions in process, each with their own static instance of registration state
if (assemblyPath == null || ExistsInReferencedPackage(assemblyName))
return null;
var existAssembly = Default.Assemblies.FirstOrDefault(x => x.FullName == assemblyName.FullName);

return LoadFromAssemblyPath(assemblyPath);
return existAssembly ?? (assemblyPath == null ? null : LoadFromAssemblyPath(assemblyPath));
}

internal Type FromAssemblyGetTypeOfInterface(Assembly assembly, Type type)
{
var allTypes = assembly.ExportedTypes;
return allTypes.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Any(t => t == type));
}

internal bool ExistsInReferencedPackage(AssemblyName assemblyName)
{
return loadedAssembly.ContainsKey(assemblyName.FullName);
}
}
}
2 changes: 1 addition & 1 deletion Flow.Launcher.Infrastructure/Image/ImageCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async void SliceExtra()
// To delete the images from the data dictionary based on the resizing of the Usage Dictionary
// Double Check to avoid concurrent remove
if (Data.Count > permissibleFactor * MaxCached)
foreach (var key in Data.OrderBy(x => x.Value.usage).Take(Data.Count - MaxCached).Select(x => x.Key).ToArray())
foreach (var key in Data.OrderBy(x => x.Value.usage).Take(Data.Count - MaxCached).Select(x => x.Key))
Data.TryRemove(key, out _);
semaphore.Release();
}
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/Helper/HotKeyMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static void Initialize(MainViewModel mainVM)

internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
{
if (!mainViewModel.GameModeStatus)
if (!mainViewModel.ShouldIgnoreHotkeys() && !mainViewModel.GameModeStatus)
mainViewModel.ToggleFlowLauncher();
}

Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@
<system:String x:Key="defaultBrowser_name">Browser</system:String>
<system:String x:Key="defaultBrowser_profile_name">Browser Name</system:String>
<system:String x:Key="defaultBrowser_path">Browser Path</system:String>
<system:String x:Key="defaultBrowser_newtab">New Window</system:String>
<system:String x:Key="defaultBrowser_newWindow">New Tab</system:String>
<system:String x:Key="defaultBrowser_newWindow">New Window</system:String>
<system:String x:Key="defaultBrowser_newTab">New Tab</system:String>
<system:String x:Key="defaultBrowser_parameter">Private Mode</system:String>

<!-- Priority Setting Dialog -->
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/Languages/ko.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
<system:String x:Key="defaultBrowser_name">브라우저</system:String>
<system:String x:Key="defaultBrowser_profile_name">브라우저 이름</system:String>
<system:String x:Key="defaultBrowser_path">브라우저 경로</system:String>
<system:String x:Key="defaultBrowser_newtab">새 창</system:String>
<system:String x:Key="defaultBrowser_newWindow">새 탭</system:String>
<system:String x:Key="defaultBrowser_newWindow">새 창</system:String>
<system:String x:Key="defaultBrowser_newTab">새 탭</system:String>
<system:String x:Key="defaultBrowser_parameter">프라이빗 모드</system:String>

<!-- Priority Setting Dialog -->
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/Languages/pt-pt.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@
<system:String x:Key="defaultBrowser_name">Navegador</system:String>
<system:String x:Key="defaultBrowser_profile_name">Nome do navegador</system:String>
<system:String x:Key="defaultBrowser_path">Caminho do navegador</system:String>
<system:String x:Key="defaultBrowser_newtab">Nova janela</system:String>
<system:String x:Key="defaultBrowser_newWindow">Novo separador</system:String>
<system:String x:Key="defaultBrowser_newWindow">Nova janela</system:String>
<system:String x:Key="defaultBrowser_newTab">Novo separador</system:String>
<system:String x:Key="defaultBrowser_parameter">Modo privado</system:String>

<!-- Priority Setting Dialog -->
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/Languages/sk.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
<system:String x:Key="defaultBrowser_name">Prehliadač</system:String>
<system:String x:Key="defaultBrowser_profile_name">Názov prehliadača</system:String>
<system:String x:Key="defaultBrowser_path">Cesta k prehliadaču</system:String>
<system:String x:Key="defaultBrowser_newtab">Nové okno</system:String>
<system:String x:Key="defaultBrowser_newWindow">Nová karta</system:String>
<system:String x:Key="defaultBrowser_newWindow">Nové okno</system:String>
<system:String x:Key="defaultBrowser_newTab">Nová karta</system:String>
<system:String x:Key="defaultBrowser_parameter">Privátny režim</system:String>

<!-- Priority Setting Dialog -->
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/ReportWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ private Paragraph Hyperlink(string textBeforeUrl, string url)
var link = new Hyperlink { IsEnabled = true };
link.Inlines.Add(url);
link.NavigateUri = new Uri(url);
link.RequestNavigate += (s, e) => SearchWeb.NewTabInBrowser(e.Uri.ToString());
link.Click += (s, e) => SearchWeb.NewTabInBrowser(url);
link.RequestNavigate += (s, e) => SearchWeb.OpenInBrowserTab(e.Uri.ToString());
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);

paragraph.Inlines.Add(textBeforeUrl);
paragraph.Inlines.Add(link);
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/SelectBrowserWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
VerticalAlignment="Center"
Orientation="Horizontal">
<RadioButton IsChecked="{Binding OpenInTab}"
Content="{DynamicResource defaultBrowser_newWindow}"></RadioButton>
Content="{DynamicResource defaultBrowser_newTab}"></RadioButton>
<RadioButton IsChecked="{Binding OpenInNewWindow, Mode=OneTime}"
Content="{DynamicResource defaultBrowser_newWindow}"></RadioButton>
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void OnPluginNameClick(object sender, MouseButtonEventArgs e)
var uri = new Uri(website);
if (Uri.CheckSchemeName(uri.Scheme))
{
website.NewTabInBrowser();
website.OpenInBrowserTab();
}
}
}
Expand Down
31 changes: 26 additions & 5 deletions Flow.Launcher/ViewModel/ResultViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using System.IO;
using System.Drawing.Text;
using System.Collections.Generic;

namespace Flow.Launcher.ViewModel
{
public class ResultViewModel : BaseModel
{
private static PrivateFontCollection fontCollection = new();
private static Dictionary<string, string> fonts = new();

public ResultViewModel(Result result, Settings settings)
{
if (result != null)
Expand All @@ -23,13 +28,29 @@ public ResultViewModel(Result result, Settings settings)
// Checks if it's a system installed font, which does not require path to be provided.
if (glyph.FontFamily.EndsWith(".ttf") || glyph.FontFamily.EndsWith(".otf"))
{
var fontPath = Result.Glyph.FontFamily;
Glyph = Path.IsPathRooted(fontPath)
? Result.Glyph
: Result.Glyph with
string fontFamilyPath = glyph.FontFamily;

if (!Path.IsPathRooted(fontFamilyPath))
{
fontFamilyPath = Path.Combine(Result.PluginDirectory, fontFamilyPath);
}

if (fonts.ContainsKey(fontFamilyPath))
{
Glyph = glyph with
{
FontFamily = fonts[fontFamilyPath]
};
}
else
{
fontCollection.AddFontFile(fontFamilyPath);
fonts[fontFamilyPath] = $"{Path.GetDirectoryName(fontFamilyPath)}/#{fontCollection.Families[^1].Name}";
Glyph = glyph with
{
FontFamily = Path.Combine(Result.PluginDirectory, fontPath)
FontFamily = fonts[fontFamilyPath]
};
}
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ internal List<Result> InstallFromWeb(string url)
{
if (e.SpecialKeyState.CtrlPressed)
{
SearchWeb.NewTabInBrowser(plugin.UrlDownload);
SearchWeb.OpenInBrowserTab(plugin.UrlDownload);
return ShouldHideWindow;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ internal async ValueTask<List<Result>> RequestInstallOrUpdate(string searchName,
{
if (e.SpecialKeyState.CtrlPressed)
{
SearchWeb.NewTabInBrowser(x.Website);
SearchWeb.OpenInBrowserTab(x.Website);
return ShouldHideWindow;
}
Expand Down
54 changes: 27 additions & 27 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
var results = new List<Result>();

foreach (SearchSource searchSource in _settings.SearchSources.Where(o => (o.ActionKeyword == query.ActionKeyword ||
o.ActionKeyword == SearchSourceGlobalPluginWildCardSign)
&& o.Enabled))
o.ActionKeyword == SearchSourceGlobalPluginWildCardSign)
&& o.Enabled))
{
string keyword = string.Empty;
keyword = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? query.ToString() : query.Search;
Expand Down Expand Up @@ -105,11 +105,11 @@ private async Task UpdateResultsFromSuggestionAsync(List<Result> results, string
if (_settings.EnableSuggestion)
{
var suggestions = await SuggestionsAsync(keyword, subtitle, searchSource, token).ConfigureAwait(false);
if (token.IsCancellationRequested || !suggestions.Any())
var enumerable = suggestions?.ToList();
if (token.IsCancellationRequested || enumerable is not { Count: > 0 })
return;


results.AddRange(suggestions);

results.AddRange(enumerable);

token.ThrowIfCancellationRequested();
}
Expand All @@ -118,32 +118,32 @@ private async Task UpdateResultsFromSuggestionAsync(List<Result> results, string
private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string subtitle, SearchSource searchSource, CancellationToken token)
{
var source = _settings.SelectedSuggestion;
if (source != null)
if (source == null)
{
//Suggestions appear below actual result, and appear above global action keyword match if non-global;
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1;
return new List<Result>();
}
//Suggestions appear below actual result, and appear above global action keyword match if non-global;
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1;

var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false);
var suggestions = await source.SuggestionsAsync(keyword, token).ConfigureAwait(false);

token.ThrowIfCancellationRequested();
token.ThrowIfCancellationRequested();

var resultsFromSuggestion = suggestions?.Select(o => new Result
var resultsFromSuggestion = suggestions?.Select(o => new Result
{
Title = o,
SubTitle = subtitle,
Score = score,
IcoPath = searchSource.IconPath,
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
Action = c =>
{
Title = o,
SubTitle = subtitle,
Score = score,
IcoPath = searchSource.IconPath,
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
Action = c =>
{
_context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
_context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
return true;
}
});
return resultsFromSuggestion;
}
return new List<Result>();
return true;
}
});
return resultsFromSuggestion;
}

public Task InitAsync(PluginInitContext context)
Expand Down Expand Up @@ -191,4 +191,4 @@ public string GetTranslatedPluginDescription()

public event ResultUpdatedEventHandler ResultsUpdated;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Baidu : SuggestionSource
{
private readonly Regex _reg = new Regex("window.baidu.sug\\((.*)\\)");

public override async Task<List<string>> Suggestions(string query, CancellationToken token)
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
{
string result;

Expand All @@ -25,7 +25,7 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
const string api = "http://suggestion.baidu.com/su?json=1&wd=";
result = await Http.GetAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false);
}
catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException)
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
{
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
{
class Bing : SuggestionSource
{
public override async Task<List<string>> Suggestions(string query, CancellationToken token)
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
{

try
Expand All @@ -40,7 +40,7 @@ public override async Task<List<string>> Suggestions(string query, CancellationT


}
catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException)
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
{
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
{
public class Google : SuggestionSource
{
public override async Task<List<string>> Suggestions(string query, CancellationToken token)
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
{
try
{
Expand All @@ -32,7 +32,7 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
return results.EnumerateArray().Select(o => o.GetString()).ToList();

}
catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException)
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
{
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
{
public abstract class SuggestionSource
{
public abstract Task<List<string>> Suggestions(string query, CancellationToken token);
public abstract Task<List<string>> SuggestionsAsync(string query, CancellationToken token);
}
}
Loading

0 comments on commit 84a806b

Please sign in to comment.