Merge branch 'dev' into RenderImprovement

This commit is contained in:
Jeremy Wu 2021-01-10 13:25:04 +11:00
commit 08e163c235
27 changed files with 171 additions and 140 deletions

View file

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json;
using Flow.Launcher.Infrastructure.Exception; using Flow.Launcher.Infrastructure.Exception;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
@ -65,7 +65,7 @@ namespace Flow.Launcher.Core.Plugin
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject<JsonRPCQueryResponseModel>(output); JsonRPCQueryResponseModel queryResponseModel = JsonSerializer.Deserialize<JsonRPCQueryResponseModel>(output);
if (queryResponseModel.Result == null) return null; if (queryResponseModel.Result == null) return null;
foreach (JsonRPCResult result in queryResponseModel.Result) foreach (JsonRPCResult result in queryResponseModel.Result)
@ -84,7 +84,7 @@ namespace Flow.Launcher.Core.Plugin
else else
{ {
string actionReponse = ExecuteCallback(result1.JsonRPCAction); string actionReponse = ExecuteCallback(result1.JsonRPCAction);
JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject<JsonRPCRequestModel>(actionReponse); JsonRPCRequestModel jsonRpcRequestModel = JsonSerializer.Deserialize<JsonRPCRequestModel>(actionReponse);
if (jsonRpcRequestModel != null if (jsonRpcRequestModel != null
&& !String.IsNullOrEmpty(jsonRpcRequestModel.Method) && !String.IsNullOrEmpty(jsonRpcRequestModel.Method)
&& jsonRpcRequestModel.Method.StartsWith("Flow.Launcher.")) && jsonRpcRequestModel.Method.StartsWith("Flow.Launcher."))

View file

@ -2,10 +2,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.IO; using System.IO;
using Newtonsoft.Json;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
using System.Text.Json;
namespace Flow.Launcher.Core.Plugin namespace Flow.Launcher.Core.Plugin
{ {
@ -61,7 +61,7 @@ namespace Flow.Launcher.Core.Plugin
PluginMetadata metadata; PluginMetadata metadata;
try try
{ {
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath)); metadata = JsonSerializer.Deserialize<PluginMetadata>(File.ReadAllText(configPath));
metadata.PluginDirectory = pluginDirectory; metadata.PluginDirectory = pluginDirectory;
// for plugins which doesn't has ActionKeywords key // for plugins which doesn't has ActionKeywords key
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> { metadata.ActionKeyword }; metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> { metadata.ActionKeyword };

View file

@ -13,7 +13,6 @@ using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Http; using Flow.Launcher.Infrastructure.Http;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using System.IO;
using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View file

@ -49,7 +49,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog.Schema" Version="4.7.0-rc1" /> <PackageReference Include="NLog.Schema" Version="4.7.0-rc1" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" /> <PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" />

View file

@ -1,12 +1,18 @@
using System; using System;
using System.IO; using System.IO;
using Newtonsoft.Json; using System.Runtime.CompilerServices;
using Newtonsoft.Json.Converters; using System.Text.Json;
using System.Text.Json.Serialization;
namespace Flow.Launcher.Infrastructure namespace Flow.Launcher.Infrastructure
{ {
public static class Helper public static class Helper
{ {
static Helper()
{
jsonFormattedSerializerOptions.Converters.Add(new JsonStringEnumConverter());
}
/// <summary> /// <summary>
/// http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy /// http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy
/// </summary> /// </summary>
@ -65,13 +71,18 @@ namespace Flow.Launcher.Infrastructure
} }
} }
private static readonly JsonSerializerOptions jsonFormattedSerializerOptions = new JsonSerializerOptions
{
WriteIndented = true
};
public static string Formatted<T>(this T t) public static string Formatted<T>(this T t)
{ {
var formatted = JsonConvert.SerializeObject( var formatted = JsonSerializer.Serialize(t, new JsonSerializerOptions
t, {
Formatting.Indented, WriteIndented = true
new StringEnumConverter() });
);
return formatted; return formatted;
} }
} }

View file

@ -132,7 +132,7 @@ namespace Flow.Launcher.Infrastructure.Logger
public static void Exception(string message, System.Exception e) public static void Exception(string message, System.Exception e)
{ {
#if DEBUG #if DEBUG
throw e; throw e;
#else #else
if (FormatValid(message)) if (FormatValid(message))
{ {

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using Newtonsoft.Json; using System.Text.Json;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
namespace Flow.Launcher.Infrastructure.Storage namespace Flow.Launcher.Infrastructure.Storage
@ -11,7 +11,7 @@ namespace Flow.Launcher.Infrastructure.Storage
/// </summary> /// </summary>
public class JsonStrorage<T> public class JsonStrorage<T>
{ {
private readonly JsonSerializerSettings _serializerSettings; private readonly JsonSerializerOptions _serializerSettings;
private T _data; private T _data;
// need a new directory name // need a new directory name
public const string DirectoryName = "Settings"; public const string DirectoryName = "Settings";
@ -24,10 +24,9 @@ namespace Flow.Launcher.Infrastructure.Storage
{ {
// use property initialization instead of DefaultValueAttribute // use property initialization instead of DefaultValueAttribute
// easier and flexible for default value of object // easier and flexible for default value of object
_serializerSettings = new JsonSerializerSettings _serializerSettings = new JsonSerializerOptions
{ {
ObjectCreationHandling = ObjectCreationHandling.Replace, IgnoreNullValues = false
NullValueHandling = NullValueHandling.Ignore
}; };
} }
@ -56,7 +55,7 @@ namespace Flow.Launcher.Infrastructure.Storage
{ {
try try
{ {
_data = JsonConvert.DeserializeObject<T>(searlized, _serializerSettings); _data = JsonSerializer.Deserialize<T>(searlized, _serializerSettings);
} }
catch (JsonException e) catch (JsonException e)
{ {
@ -77,7 +76,7 @@ namespace Flow.Launcher.Infrastructure.Storage
BackupOriginFile(); BackupOriginFile();
} }
_data = JsonConvert.DeserializeObject<T>("{}", _serializerSettings); _data = JsonSerializer.Deserialize<T>("{}", _serializerSettings);
Save(); Save();
} }
@ -94,7 +93,8 @@ namespace Flow.Launcher.Infrastructure.Storage
public void Save() public void Save()
{ {
string serialized = JsonConvert.SerializeObject(_data, Formatting.Indented); string serialized = JsonSerializer.Serialize(_data, new JsonSerializerOptions() { WriteIndented = true });
File.WriteAllText(FilePath, serialized); File.WriteAllText(FilePath, serialized);
} }
} }

View file

@ -1,8 +1,7 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
using Newtonsoft.Json; using System.Text.Json.Serialization;
using Newtonsoft.Json.Converters;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
namespace Flow.Launcher.Infrastructure.UserSettings namespace Flow.Launcher.Infrastructure.UserSettings
@ -16,7 +15,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool ShowOpenResultHotkey { get; set; } = true; public bool ShowOpenResultHotkey { get; set; } = true;
public string Language public string Language
{ {
get => language; set { get => language; set
{
language = value; language = value;
OnPropertyChanged(); OnPropertyChanged();
} }
@ -73,9 +73,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public int MaxResultsToShow { get; set; } = 5; public int MaxResultsToShow { get; set; } = 5;
public int ActivateTimes { get; set; } public int ActivateTimes { get; set; }
// Order defaults to 0 or -1, so 1 will let this property appear last
[JsonProperty(Order = 1)]
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>(); public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();
public bool DontPromptUpdateMsg { get; set; } public bool DontPromptUpdateMsg { get; set; }
@ -100,8 +98,12 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public HttpProxy Proxy { get; set; } = new HttpProxy(); public HttpProxy Proxy { get; set; } = new HttpProxy();
[JsonConverter(typeof(StringEnumConverter))] [JsonConverter(typeof(JsonStringEnumConverter))]
public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected; public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected;
// This needs to be loaded last by staying at the bottom
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
} }
public enum LastQueryMode public enum LastQueryMode

View file

@ -62,7 +62,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" /> <PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -1,11 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Newtonsoft.Json; using System.Text.Json.Serialization;
namespace Flow.Launcher.Plugin namespace Flow.Launcher.Plugin
{ {
[JsonObject(MemberSerialization.OptOut)]
public class PluginMetadata : BaseModel public class PluginMetadata : BaseModel
{ {
private string _pluginDirectory; private string _pluginDirectory;

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
@ -63,6 +63,9 @@
<Content Include="Images\*.png"> <Content Include="Images\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Images\*.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -81,7 +84,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="PropertyChanged.Fody" Version="2.5.13" /> <PackageReference Include="PropertyChanged.Fody" Version="3.3.1" />
<PackageReference Include="SharpVectors" Version="1.7.1" /> <PackageReference Include="SharpVectors" Version="1.7.1" />
</ItemGroup> </ItemGroup>
@ -94,8 +97,4 @@
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" /> <Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
</Target> </Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -NoProfile -ExecutionPolicy Bypass -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir) $(TargetPath)" />
</Target>
</Project> </Project>

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
namespace Flow.Launcher.Storage namespace Flow.Launcher.Storage

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using System.Text.Json;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
namespace Flow.Launcher.Storage namespace Flow.Launcher.Storage
@ -8,7 +8,6 @@ namespace Flow.Launcher.Storage
// todo this class is not thread safe.... but used from multiple threads. // todo this class is not thread safe.... but used from multiple threads.
public class TopMostRecord public class TopMostRecord
{ {
[JsonProperty]
private Dictionary<string, Record> records = new Dictionary<string, Record>(); private Dictionary<string, Record> records = new Dictionary<string, Record>();
internal bool IsTopMost(Result result) internal bool IsTopMost(Result result)

View file

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json;
using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
@ -7,7 +6,6 @@ namespace Flow.Launcher.Storage
{ {
public class UserSelectedRecord public class UserSelectedRecord
{ {
[JsonProperty]
private Dictionary<string, int> records = new Dictionary<string, int>(); private Dictionary<string, int> records = new Dictionary<string, int>();
public void Add(Result result) public void Add(Result result)

View file

@ -11,6 +11,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View file

@ -7,6 +7,7 @@
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<ApplicationIcon /> <ApplicationIcon />
<StartupObject /> <StartupObject />
</PropertyGroup> </PropertyGroup>

View file

@ -1,15 +1,15 @@
using Newtonsoft.Json; using System;
using System;
using System.Linq; using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks
{ {
[JsonObject(MemberSerialization.OptIn)]
public class FolderLink public class FolderLink
{ {
[JsonProperty]
public string Path { get; set; } public string Path { get; set; }
[JsonIgnore]
public string Nickname public string Nickname
{ {
get get

View file

@ -1,28 +1,22 @@
using Flow.Launcher.Plugin.Explorer.Search; using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks; using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
using Newtonsoft.Json;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Flow.Launcher.Plugin.Explorer namespace Flow.Launcher.Plugin.Explorer
{ {
public class Settings public class Settings
{ {
[JsonProperty]
public int MaxResult { get; set; } = 100; public int MaxResult { get; set; } = 100;
[JsonProperty]
public List<FolderLink> QuickFolderAccessLinks { get; set; } = new List<FolderLink>(); public List<FolderLink> QuickFolderAccessLinks { get; set; } = new List<FolderLink>();
[JsonProperty]
public bool UseWindowsIndexForDirectorySearch { get; set; } = true; public bool UseWindowsIndexForDirectorySearch { get; set; } = true;
[JsonProperty]
public List<FolderLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<FolderLink>(); public List<FolderLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<FolderLink>();
[JsonProperty]
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
[JsonProperty]
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
} }
} }

View file

@ -10,6 +10,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View file

@ -0,0 +1,39 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Dialogues-->
<system:String x:Key="plugin_pluginsmanager_downloading_plugin">Sťahovanie pluginu</system:String>
<system:String x:Key="plugin_pluginsmanager_please_wait">Čakajte, prosím…</system:String>
<system:String x:Key="plugin_pluginsmanager_download_success">Úspešne stiahnuté</system:String>
<system:String x:Key="plugin_pluginsmanager_uninstall_prompt">{0} od {1} {2}{3}Chcete odinštalovať tento plugin? Po odinštalovaní sa Flow automaticky reštartuje.</system:String>
<system:String x:Key="plugin_pluginsmanager_install_prompt">{0} by {1} {2}{3}Chcete nainštalovať tento plugin? Po odinštalovaní sa Flow automaticky reštartuje.</system:String>
<system:String x:Key="plugin_pluginsmanager_install_title">Inštalovať plugin</system:String>
<system:String x:Key="plugin_pluginsmanager_uninstall_title">Odinštalovať plugin</system:String>
<system:String x:Key="plugin_pluginsmanager_install_errormetadatafile">Inštalácia zlyhala: nepodarilo sa nájsť metadáta súboru plugin.json nového pluginu</system:String>
<system:String x:Key="plugin_pluginsmanager_install_error_title">Chyba inštalácie pluginu</system:String>
<system:String x:Key="plugin_pluginsmanager_install_error_subtitle">Nastala chyba počas inštaláciu pluginu {0}</system:String>
<system:String x:Key="plugin_pluginsmanager_update_noresult_title">Nie je k dispozícii žiadna aktualizácia</system:String>
<system:String x:Key="plugin_pluginsmanager_update_noresult_subtitle">Všetky pluginy sú aktuálne</system:String>
<system:String x:Key="plugin_pluginsmanager_update_prompt">{0} od {1} {2}{3}Chcete aktualizovať tento plugin? Po odinštalovaní sa Flow automaticky reštartuje.</system:String>
<system:String x:Key="plugin_pluginsmanager_update_title">Aktualizácia pluginu</system:String>
<system:String x:Key="plugin_pluginsmanager_update_exists">Tento plugin má dostupnú aktualizáciu, chcete ju zobraziť?</system:String>
<system:String x:Key="plugin_pluginsmanager_update_alreadyexists">Tento plugin je už nainštalovaný</system:String>
<!--Controls-->
<!--Plugin Infos-->
<system:String x:Key="plugin_pluginsmanager_plugin_name">Správca pluginov</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_description">Správa inštalácie, odinštalácie alebo aktualizácie pluginov programu Flow Launcher</system:String>
<!--Context menu items-->
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_openwebsite_title">Prejsť na webovú stránku</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_openwebsite_subtitle">Prejsť na webovú stránku pluginu</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_gotosourcecode_title">Zobraziť zdrojový kód</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_gotosourcecode_subtitle">Zobraziť zdrojový kód pluginu</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_newissue_title">Navrhnúť vylepšenie alebo nahlásiť chybu</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_newissue_subtitle">Navrhnúť vylepšenie alebo nahlásiť chybu vývojárovi pluginu</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_pluginsmanifest_title">Prejsť na repozitár pluginov spúšťača Flow</system:String>
<system:String x:Key="plugin_pluginsmanager_plugin_contextmenu_pluginsmanifest_subtitle">Prejsť na repozitár pluginov spúšťača Flow a zobraziť príspevky komunity</system:String>
</ResourceDictionary>

View file

@ -1,10 +1,10 @@
using System.IO; using System.IO;
using System.Windows.Media; using System.Windows.Media;
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json;
using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Infrastructure.Image;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using System.Reflection; using System.Reflection;
using System.Text.Json.Serialization;
namespace Flow.Launcher.Plugin.WebSearch namespace Flow.Launcher.Plugin.WebSearch
{ {

View file

@ -1,6 +1,6 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Newtonsoft.Json; using System.Text.Json.Serialization;
using Flow.Launcher.Plugin.WebSearch.SuggestionSources; using Flow.Launcher.Plugin.WebSearch.SuggestionSources;
namespace Flow.Launcher.Plugin.WebSearch namespace Flow.Launcher.Plugin.WebSearch

View file

@ -2,10 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Flow.Launcher.Infrastructure.Http; using Flow.Launcher.Infrastructure.Http;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using System.Net.Http; using System.Net.Http;
@ -35,25 +34,20 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
Match match = _reg.Match(result); Match match = _reg.Match(result);
if (match.Success) if (match.Success)
{ {
JContainer json; JsonDocument json;
try try
{ {
json = JsonConvert.DeserializeObject(match.Groups[1].Value) as JContainer; json = JsonDocument.Parse(match.Groups[1].Value);
} }
catch (JsonSerializationException e) catch(JsonException e)
{ {
Log.Exception("|Baidu.Suggestions|can't parse suggestions", e); Log.Exception("|Baidu.Suggestions|can't parse suggestions", e);
return new List<string>(); return new List<string>();
} }
if (json != null) var results = json?.RootElement.GetProperty("s");
{
var results = json["s"] as JArray; return results?.EnumerateArray().Select(o => o.GetString()).ToList() ?? new List<string>();
if (results != null)
{
return results.OfType<JValue>().Select(o => o.Value).OfType<string>().ToList();
}
}
} }
return new List<string>(); return new List<string>();

View file

@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Flow.Launcher.Infrastructure.Http; using Flow.Launcher.Infrastructure.Http;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using System.Net.Http; using System.Net.Http;
using System.Text.Json;
using System.IO;
namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
{ {
@ -15,37 +15,32 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
{ {
public override async Task<List<string>> Suggestions(string query) public override async Task<List<string>> Suggestions(string query)
{ {
string result; Stream resultStream;
try try
{ {
const string api = "https://www.google.com/complete/search?output=chrome&q="; const string api = "https://www.google.com/complete/search?output=chrome&q=";
result = await Http.GetAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false); resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false);
} }
catch (HttpRequestException e) catch (HttpRequestException e)
{ {
Log.Exception("|Google.Suggestions|Can't get suggestion from google", e); Log.Exception("|Google.Suggestions|Can't get suggestion from google", e);
return new List<string>(); return new List<string>();
} }
if (string.IsNullOrEmpty(result)) return new List<string>(); if (resultStream.Length == 0) return new List<string>();
JContainer json; JsonDocument json;
try try
{ {
json = JsonConvert.DeserializeObject(result) as JContainer; json = await JsonDocument.ParseAsync(resultStream);
} }
catch (JsonSerializationException e) catch (JsonException e)
{ {
Log.Exception("|Google.Suggestions|can't parse suggestions", e); Log.Exception("|Google.Suggestions|can't parse suggestions", e);
return new List<string>(); return new List<string>();
} }
if (json != null)
{ var results = json?.RootElement.EnumerateArray().ElementAt(1);
var results = json[1] as JContainer;
if (results != null) return results?.EnumerateArray().Select(o => o.GetString()).ToList() ?? new List<string>();
{
return results.OfType<JValue>().Select(o => o.Value).OfType<string>().ToList();
}
}
return new List<string>();
} }
public override string ToString() public override string ToString()

View file

@ -1,13 +1,13 @@
param( param(
[string]$config = "Release", [string]$config = "Release",
[string]$solution, [string]$solution = (Join-Path $PSScriptRoot ".." -Resolve)
[string]$targetpath
) )
Write-Host "Config: $config" Write-Host "Config: $config"
function Build-Version { function Build-Version {
if ([string]::IsNullOrEmpty($env:flowVersion)) { if ([string]::IsNullOrEmpty($env:flowVersion)) {
$v = (Get-Command ${TargetPath}).FileVersionInfo.FileVersion $targetPath = Join-Path $solution "Output/Release/Flow.Launcher.dll" -Resolve
$v = (Get-Command ${targetPath}).FileVersionInfo.FileVersion
} else { } else {
$v = $env:flowVersion $v = $env:flowVersion
} }
@ -31,13 +31,9 @@ function Build-Path {
return $p return $p
} }
function Copy-Resources ($path, $config) { function Copy-Resources ($path) {
$project = "$path\Flow.Launcher"
$output = "$path\Output"
$target = "$output\$config"
Copy-Item -Recurse -Force $project\Images\* $target\Images\
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced. # making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
Copy-Item -Force $env:USERPROFILE\.nuget\packages\squirrel.windows\1.5.2\tools\Squirrel.exe $output\Update.exe Copy-Item -Force $env:USERPROFILE\.nuget\packages\squirrel.windows\1.5.2\tools\Squirrel.exe $path\Output\Update.exe
} }
function Delete-Unused ($path, $config) { function Delete-Unused ($path, $config) {
@ -55,17 +51,6 @@ function Validate-Directory ($output) {
New-Item $output -ItemType Directory -Force New-Item $output -ItemType Directory -Force
} }
function Zip-Release ($path, $version, $output) {
Write-Host "Begin zip release"
$content = "$path\Output\Release\*"
$zipFile = "$output\Flow-Launcher-v$version.zip"
Compress-Archive -Force -Path $content -DestinationPath $zipFile
Write-Host "End zip release"
}
function Pack-Squirrel-Installer ($path, $version, $output) { function Pack-Squirrel-Installer ($path, $version, $output) {
# msbuild based installer generation is not working in appveyor, not sure why # msbuild based installer generation is not working in appveyor, not sure why
Write-Host "Begin pack squirrel installer" Write-Host "Begin pack squirrel installer"
@ -75,6 +60,8 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
Write-Host "Packing: $spec" Write-Host "Packing: $spec"
Write-Host "Input path: $input" Write-Host "Input path: $input"
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
New-Alias Nuget $env:USERPROFILE\.nuget\packages\NuGet.CommandLine\5.4.0\tools\NuGet.exe -Force
# TODO: can we use dotnet pack here? # TODO: can we use dotnet pack here?
nuget pack $spec -Version $version -BasePath $input -OutputDirectory $output -Properties Configuration=Release nuget pack $spec -Version $version -BasePath $input -OutputDirectory $output -Properties Configuration=Release
@ -100,40 +87,30 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
Write-Host "End pack squirrel installer" Write-Host "End pack squirrel installer"
} }
function IsDotNetCoreAppSelfContainedPublishEvent{ function Publish-Self-Contained ($p) {
return Test-Path $solution\Output\Release\coreclr.dll
}
function FixPublishLastWriteDateTimeError ($solutionPath) { $csproj = Join-Path "$p" "Flow.Launcher/Flow.Launcher.csproj" -Resolve
#Fix error from publishing self contained app, when nuget tries to pack core dll references throws the error 'The DateTimeOffset specified cannot be converted into a Zip file timestamp' $profile = Join-Path "$p" "Flow.Launcher/Properties/PublishProfiles/NetCore3.1-SelfContained.pubxml" -Resolve
gci -path "$solutionPath\Output\Release" -rec -file *.dll | Where-Object {$_.LastWriteTime -lt (Get-Date).AddYears(-20)} | % { try { $_.LastWriteTime = '01/01/2000 00:00:00' } catch {} }
# we call dotnet publish on the main project.
# The other projects should have been built in Release at this point.
dotnet publish -c Release $csproj /p:PublishProfile=$profile
} }
function Main { function Main {
$p = Build-Path $p = Build-Path
$v = Build-Version $v = Build-Version
Copy-Resources $p $config Copy-Resources $p
if ($config -eq "Release"){ if ($config -eq "Release"){
if(IsDotNetCoreAppSelfContainedPublishEvent) {
FixPublishLastWriteDateTimeError $p
}
Delete-Unused $p $config Delete-Unused $p $config
Publish-Self-Contained $p
$o = "$p\Output\Packages" $o = "$p\Output\Packages"
Validate-Directory $o Validate-Directory $o
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
New-Alias Nuget $env:USERPROFILE\.nuget\packages\NuGet.CommandLine\5.4.0\tools\NuGet.exe -Force
Pack-Squirrel-Installer $p $v $o Pack-Squirrel-Installer $p $v $o
$isInCI = $env:APPVEYOR
if ($isInCI) {
Zip-Release $p $v $o
}
Write-Host "List output directory"
Get-ChildItem $o
} }
} }

View file

@ -16,6 +16,6 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.6.0")] [assembly: AssemblyVersion("1.7.0")]
[assembly: AssemblyFileVersion("1.6.0")] [assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyInformationalVersion("1.6.0")] [assembly: AssemblyInformationalVersion("1.7.0")]

View file

@ -1,4 +1,4 @@
version: '1.6.0.{build}' version: '1.7.0.{build}'
init: init:
- ps: | - ps: |
@ -26,17 +26,42 @@ before_build:
build: build:
project: Flow.Launcher.sln project: Flow.Launcher.sln
verbosity: minimal verbosity: minimal
after_build:
- ps: .\Scripts\post_build.ps1
artifacts: artifacts:
- path: 'Output\Packages\Flow-Launcher-*.zip'
name: Zip
- path: 'Output\Release\Flow.Launcher.Plugin.*.nupkg' - path: 'Output\Release\Flow.Launcher.Plugin.*.nupkg'
name: Plugin nupkg name: Plugin nupkg
- path: 'Output\Packages\Flow-Launcher-*.exe'
name: Squirrel Installer
- path: 'Output\Packages\FlowLauncher-*-full.nupkg'
name: Squirrel nupkg
- path: 'Output\Packages\RELEASES'
name: Squirrel RELEASES
deploy: deploy:
provider: NuGet - provider: NuGet
artifact: /.*\.nupkg/ artifact: Plugin nupkg
api_key: api_key:
secure: n80IeWR3pN81p0w4uXq4mO0TdTXoJSHHFL+yTB9YBJ0Wni2DjZGYwOFdaWzW4hRi secure: n80IeWR3pN81p0w4uXq4mO0TdTXoJSHHFL+yTB9YBJ0Wni2DjZGYwOFdaWzW4hRi
on: on:
branch: master branch: master
- provider: GitHub
release: v$(flowVersion)
auth_token:
secure: ij4UeXUYQBDJxn2YRAAhUOjklOGVKDB87Hn5J8tKIzj13yatoI7sLM666QDQFEgv
artifact: Squirrel Installer, Squirrel nupkg, Squirrel RELEASES
draft: true
force_update: true
on:
branch: master
- provider: GitHub
release: v$(flowVersion)
auth_token:
secure: ij4UeXUYQBDJxn2YRAAhUOjklOGVKDB87Hn5J8tKIzj13yatoI7sLM666QDQFEgv
artifact: Squirrel Installer, Squirrel nupkg, Squirrel RELEASES
force_update: true
on:
APPVEYOR_REPO_TAG: true