Merge branch 'dev' into add_filecontent_search

This commit is contained in:
Jeremy Wu 2020-07-12 22:50:51 +10:00
commit ef46225c33
10 changed files with 50 additions and 24 deletions

View file

@ -16,6 +16,7 @@ using Flow.Launcher.Infrastructure.Http;
using Flow.Launcher.Infrastructure.Logger;
using System.IO;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
namespace Flow.Launcher.Core
{
@ -28,11 +29,14 @@ namespace Flow.Launcher.Core
GitHubRepository = gitHubRepository;
}
public async Task UpdateApp(bool silentIfLatestVersion = true)
public async Task UpdateApp(IPublicAPI api , bool silentUpdate = true)
{
UpdateManager updateManager;
UpdateInfo newUpdateInfo;
if (!silentUpdate)
api.ShowMsg("Please wait...", "Checking for new update");
try
{
updateManager = await GitHubUpdateManager(GitHubRepository);
@ -62,12 +66,15 @@ namespace Flow.Launcher.Core
if (newReleaseVersion <= currentVersion)
{
if (!silentIfLatestVersion)
if (!silentUpdate)
MessageBox.Show("You already have the latest Flow Launcher version");
updateManager.Dispose();
return;
}
if (!silentUpdate)
api.ShowMsg("Update found", "Updating...");
try
{
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
@ -96,11 +103,15 @@ namespace Flow.Launcher.Core
var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());
MessageBox.Show(newVersionTips);
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
// always dispose UpdateManager
updateManager.Dispose();
if (MessageBox.Show(newVersionTips, "New Update", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
UpdateManager.RestartApp(Constant.ApplicationFileName);
}
}
[UsedImplicitly]

View file

@ -118,12 +118,12 @@ namespace Flow.Launcher
var timer = new Timer(1000 * 60 * 60 * 5);
timer.Elapsed += async (s, e) =>
{
await _updater.UpdateApp();
await _updater.UpdateApp(API);
};
timer.Start();
// check updates on startup
await _updater.UpdateApp();
await _updater.UpdateApp(API);
}
});
}

View file

@ -96,7 +96,7 @@
<system:String x:Key="version">Version</system:String>
<system:String x:Key="about_activate_times">You have activated Flow Launcher {0} times</system:String>
<system:String x:Key="checkUpdates">Check for Updates</system:String>
<system:String x:Key="newVersionTips">New version {0} is available, please restart Flow Launcher.</system:String>
<system:String x:Key="newVersionTips">New version {0} is available, would you like to restart Flow Launcher to use the update?</system:String>
<system:String x:Key="checkUpdatesFailed">Check updates failed, please check your connection and proxy settings to api.github.com.</system:String>
<system:String x:Key="downloadUpdatesFailed">
Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com,

View file

@ -9,13 +9,10 @@
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="#FF000000" />
<Setter Property="Background" Value="#01FFFFFF" />
<Setter Property="Background" Value="Transparent" />
</Style>
<Style x:Key="QuerySuggestionBoxStyle" BasedOn="{StaticResource BaseQuerySuggestionBoxStyle}" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="#FF000000" />
<Setter Property="Background" Value="#01FFFFFF" />
</Style>
<Style x:Key="QuerySuggestionBoxStyle" BasedOn="{StaticResource BaseQuerySuggestionBoxStyle}" TargetType="{x:Type TextBox}" />
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
<Setter Property="Background">

View file

@ -45,7 +45,7 @@ namespace Flow.Launcher.ViewModel
public async void UpdateApp()
{
await _updater.UpdateApp(false);
await _updater.UpdateApp(App.API, false);
}
public bool AutoUpdates

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -9,7 +9,10 @@ using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
using System.Linq;
using System.Reflection;
using MessageBox = System.Windows.Forms.MessageBox;
using MessageBoxIcon = System.Windows.Forms.MessageBoxIcon;
using MessageBoxButton = System.Windows.Forms.MessageBoxButtons;
using DialogResult = System.Windows.Forms.DialogResult;
namespace Flow.Launcher.Plugin.Explorer
{
@ -101,10 +104,25 @@ namespace Flow.Launcher.Plugin.Explorer
{
try
{
if (MessageBox.Show(
string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefolderconfirm"),fileOrFolder),
string.Empty,
MessageBoxButton.YesNo,
MessageBoxIcon.Warning)
== DialogResult.No)
return false;
if (record.Type == ResultType.File)
File.Delete(record.FullPath);
else
Directory.Delete(record.FullPath, true);
Task.Run(() =>
{
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess"),
string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess_detail"), fileOrFolder),
Constants.ExplorerIconImageFullPath);
});
}
catch (Exception e)
{
@ -212,15 +230,11 @@ namespace Flow.Launcher.Plugin.Explorer
if(!Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == record.FullPath))
Settings.IndexSearchExcludedSubdirectoryPaths.Add(new FolderLink { Path = record.FullPath });
var pluginDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location.ToString());
var iconPath = pluginDirectory + "\\" + Constants.ExplorerIconImagePath;
Task.Run(() =>
{
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_excludedfromindexsearch_msg"),
Context.API.GetTranslation("plugin_explorer_path") +
" " + record.FullPath, iconPath);
" " + record.FullPath, Constants.ExplorerIconImageFullPath);
// so the new path can be persisted to storage and not wait till next ViewModel save.
Context.API.SaveAppAllSettings();

View file

@ -5,6 +5,9 @@
<!--Dialogues-->
<system:String x:Key="plugin_explorer_select_folder_link_warning">Please select a folder link</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">Are you sure you want to delete {0}?</system:String>
<system:String x:Key="plugin_explorer_deletefilefolderconfirm">Are you sure you want to permanently delete this {0}?</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String>
<!--Controls-->
<system:String x:Key="plugin_explorer_delete">Delete</system:String>

View file

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
namespace Flow.Launcher.Plugin.Explorer.Search
{
@ -26,6 +26,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal const string WindowsIndexingOptions = "srchadmin.dll";
internal static string ExplorerIconImageFullPath
=> Directory.GetParent(Assembly.GetExecutingAssembly().Location.ToString()) + "\\" + ExplorerIconImagePath;
internal const string WindowsIndexFileContentSearchHotkey = "content:";
}
}

View file

@ -244,8 +244,6 @@ namespace Flow.Launcher.Plugin.Sys
{
Application.Current.MainWindow.Hide();
context.API.CheckForNewUpdate();
context.API.ShowMsg("Please wait...",
"Checking for new update");
return true;
}
}