Add Prerelease update source

This commit is contained in:
Hongtao 2023-03-30 17:21:22 -05:00
parent 1bf95201cc
commit 82a174ff30
7 changed files with 108 additions and 20 deletions

View file

@ -22,18 +22,20 @@ namespace Flow.Launcher.Core
{
public class Updater
{
public string GitHubRepository { get; }
public bool UpdateToPrerelease { get; set; }
public const string ReleaseRepository = "https://github.com/Flow-Launcher/Flow.Launcher";
public const string PrereleaseRepository = "https://github.com/Flow-Launcher/Prereleases";
public string GitHubRepository => UpdateToPrerelease ? PrereleaseRepository : ReleaseRepository;
public Updater(string gitHubRepository)
{
GitHubRepository = gitHubRepository;
}
private SemaphoreSlim UpdateLock { get; } = new SemaphoreSlim(1);
public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
{
await UpdateLock.WaitAsync().ConfigureAwait(false);
try
{
if (!silentUpdate)
@ -54,6 +56,7 @@ namespace Flow.Launcher.Core
{
if (!silentUpdate)
MessageBox.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
return;
}
@ -94,7 +97,7 @@ namespace Flow.Launcher.Core
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
else
Log.Exception($"|Updater.UpdateApp|Error Occurred", e);
if (!silentUpdate)
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
api.GetTranslation("update_flowlauncher_check_connection"));
@ -134,6 +137,7 @@ namespace Flow.Launcher.Core
{
Proxy = Http.WebProxy
};
var downloader = new FileDownloader(client);
var manager = new UpdateManager(latestUrl, urlDownloader: downloader);

View file

@ -64,8 +64,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public double SettingWindowHeight { get; set; } = 700;
public double SettingWindowTop { get; set; }
public double SettingWindowLeft { get; set; }
public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal;
public WindowState SettingWindowState { get; set; } = WindowState.Normal;
public bool PrereleaseUpdateSource { get; set; }
public int CustomExplorerIndex { get; set; } = 0;
[JsonIgnore]
@ -253,8 +255,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings
[JsonConverter(typeof(JsonStringEnumConverter))]
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();
}

View file

@ -29,7 +29,7 @@ namespace Flow.Launcher
private Settings _settings;
private MainViewModel _mainVM;
private SettingWindowViewModel _settingsVM;
private readonly Updater _updater = new Updater(Flow.Launcher.Properties.Settings.Default.GithubRepo);
private readonly Updater _updater = new();
private readonly Portable _portable = new Portable();
private readonly PinyinAlphabet _alphabet = new PinyinAlphabet();
private StringMatcher _stringMatcher;
@ -59,7 +59,7 @@ namespace Flow.Launcher
RegisterDispatcherUnhandledException();
ImageLoader.Initialize();
_settingsVM = new SettingWindowViewModel(_updater, _portable);
_settings = _settingsVM.Settings;

View file

@ -234,6 +234,9 @@
<system:String x:Key="clearlogfolder">Clear Logs</system:String>
<system:String x:Key="clearlogfolderMessage">Are you sure you want to delete all logs?</system:String>
<system:String x:Key="welcomewindow">Wizard</system:String>
<system:String x:Key="updateSource">Update Source</system:String>
<system:String x:Key="release">Release</system:String>
<system:String x:Key="prerelease">Prerelease</system:String>
<!-- FileManager Setting Dialog -->
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>

View file

@ -5,5 +5,8 @@
<Setting Name="GithubRepo" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://github.com/Flow-Launcher/Flow.Launcher</Value>
</Setting>
<Setting Name="PrereleaseRepo" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://github.com/Flow-Launcher/Prereleases</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -3058,12 +3058,13 @@
Grid.Column="1"
VerticalAlignment="Center"
Style="{DynamicResource SettingTitleLabel}"
Text="Update Source" />
Text="{DynamicResource updateSource}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<ComboBox Margin="0,0,8,0" SelectedIndex="0">
<ComboBoxItem>Release</ComboBoxItem>
<ComboBoxItem>Preview</ComboBoxItem>
<ComboBoxItem Content="{DynamicResource release}"/>
<ComboBoxItem IsSelected="{Binding Settings.PrereleaseUpdateSource}"
Content="{DynamicResource prerelease}"/>
</ComboBox>
<Button
Margin="0,0,14,0"

View file

@ -43,29 +43,41 @@ namespace Flow.Launcher.ViewModel
{
case nameof(Settings.ActivateTimes):
OnPropertyChanged(nameof(ActivatedTimes));
break;
case nameof(Settings.WindowSize):
OnPropertyChanged(nameof(WindowWidthSize));
break;
case nameof(Settings.UseDate):
case nameof(Settings.DateFormat):
OnPropertyChanged(nameof(DateText));
break;
case nameof(Settings.UseClock):
case nameof(Settings.TimeFormat):
OnPropertyChanged(nameof(ClockText));
break;
case nameof(Settings.Language):
OnPropertyChanged(nameof(ClockText));
OnPropertyChanged(nameof(DateText));
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
break;
case nameof(Settings.PreviewHotkey):
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
break;
case nameof(Settings.PrereleaseUpdateSource):
_updater.UpdateToPrerelease = Settings.PrereleaseUpdateSource;
break;
}
};
_updater.UpdateToPrerelease = Settings.PrereleaseUpdateSource;
}
public Settings Settings { get; set; }
@ -160,6 +172,7 @@ namespace Flow.Launcher.ViewModel
};
var result = dlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
return dlg.FileName;
@ -176,6 +189,7 @@ namespace Flow.Launcher.ViewModel
public class LastQueryMode : BaseModel
{
public string Display { get; set; }
public Infrastructure.UserSettings.LastQueryMode Value { get; set; }
}
@ -188,6 +202,7 @@ namespace Flow.Launcher.ViewModel
{
_lastQueryModes = InitLastQueryModes();
}
return _lastQueryModes;
}
}
@ -196,6 +211,7 @@ namespace Flow.Launcher.ViewModel
{
var modes = new List<LastQueryMode>();
var enums = (Infrastructure.UserSettings.LastQueryMode[])Enum.GetValues(typeof(Infrastructure.UserSettings.LastQueryMode));
foreach (var e in enums)
{
var key = $"LastQuery{e}";
@ -204,8 +220,10 @@ namespace Flow.Launcher.ViewModel
{
Display = display, Value = e,
};
modes.Add(m);
}
return modes;
}
@ -266,8 +284,11 @@ namespace Flow.Launcher.ViewModel
KeyConstant.Ctrl,
$"{KeyConstant.Ctrl}+{KeyConstant.Alt}"
};
private Internationalization _translater => InternationalizationManager.Instance;
public List<Language> Languages => _translater.LoadAvailableLanguages();
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
public string AlwaysPreviewToolTip => string.Format(_translater.GetTranslation("AlwaysPreviewToolTip"), Settings.PreviewHotkey);
@ -276,10 +297,12 @@ namespace Flow.Launcher.ViewModel
{
var proxyServer = Settings.Proxy.Server;
var proxyUserName = Settings.Proxy.UserName;
if (string.IsNullOrEmpty(proxyServer))
{
return InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty");
}
if (Settings.Proxy.Port <= 0)
{
return InternationalizationManager.Instance.GetTranslation("portCantBeEmpty");
@ -298,9 +321,11 @@ namespace Flow.Launcher.ViewModel
Credentials = new NetworkCredential(proxyUserName, Settings.Proxy.Password)
};
}
try
{
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
return InternationalizationManager.Instance.GetTranslation("proxyIsCorrect");
@ -321,6 +346,7 @@ namespace Flow.Launcher.ViewModel
#region plugin
public static string Plugin => @"https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest";
public PluginViewModel SelectedPlugin { get; set; }
public IList<PluginViewModel> PluginViewModels
@ -358,11 +384,13 @@ namespace Flow.Launcher.ViewModel
get
{
var settingProvider = SelectedPlugin.PluginPair.Plugin as ISettingProvider;
if (settingProvider != null)
{
var control = settingProvider.CreateSettingPanel();
control.HorizontalAlignment = HorizontalAlignment.Stretch;
control.VerticalAlignment = VerticalAlignment.Stretch;
return control;
}
else
@ -378,8 +406,8 @@ namespace Flow.Launcher.ViewModel
await PluginsManifest.UpdateManifestAsync();
OnPropertyChanged(nameof(ExternalPlugins));
}
internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0)
{
@ -396,6 +424,7 @@ namespace Flow.Launcher.ViewModel
#region theme
public static string Theme => @"https://flowlauncher.com/docs/#/how-to-create-a-theme";
public static string ThemeGallery => @"https://github.com/Flow-Launcher/Flow.Launcher/discussions/1438";
public string SelectedTheme
@ -421,6 +450,7 @@ namespace Flow.Launcher.ViewModel
if (ThemeManager.Instance.BlurEnabled && value)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("shadowEffectNotAllowed"));
return;
}
@ -440,6 +470,7 @@ namespace Flow.Launcher.ViewModel
public class ColorScheme
{
public string Display { get; set; }
public ColorSchemes Value { get; set; }
}
@ -449,6 +480,7 @@ namespace Flow.Launcher.ViewModel
{
List<ColorScheme> modes = new List<ColorScheme>();
var enums = (ColorSchemes[])Enum.GetValues(typeof(ColorSchemes));
foreach (var e in enums)
{
var key = $"ColorScheme{e}";
@ -457,8 +489,10 @@ namespace Flow.Launcher.ViewModel
{
Display = display, Value = e,
};
modes.Add(m);
}
return modes;
}
}
@ -466,6 +500,7 @@ namespace Flow.Launcher.ViewModel
public class SearchWindowScreen
{
public string Display { get; set; }
public SearchWindowScreens Value { get; set; }
}
@ -475,17 +510,19 @@ namespace Flow.Launcher.ViewModel
{
List<SearchWindowScreen> modes = new List<SearchWindowScreen>();
var enums = (SearchWindowScreens[])Enum.GetValues(typeof(SearchWindowScreens));
foreach (var e in enums)
{
var key = $"SearchWindowScreen{e}";
var display = _translater.GetTranslation(key);
var m = new SearchWindowScreen
{
Display = display,
Value = e,
Display = display, Value = e,
};
modes.Add(m);
}
return modes;
}
}
@ -493,6 +530,7 @@ namespace Flow.Launcher.ViewModel
public class SearchWindowAlign
{
public string Display { get; set; }
public SearchWindowAligns Value { get; set; }
}
@ -502,6 +540,7 @@ namespace Flow.Launcher.ViewModel
{
List<SearchWindowAlign> modes = new List<SearchWindowAlign>();
var enums = (SearchWindowAligns[])Enum.GetValues(typeof(SearchWindowAligns));
foreach (var e in enums)
{
var key = $"SearchWindowAlign{e}";
@ -510,8 +549,10 @@ namespace Flow.Launcher.ViewModel
{
Display = display, Value = e,
};
modes.Add(m);
}
return modes;
}
}
@ -522,10 +563,12 @@ namespace Flow.Launcher.ViewModel
{
var screens = System.Windows.Forms.Screen.AllScreens;
var screenNumbers = new List<int>();
for (int i = 1; i <= screens.Length; i++)
{
screenNumbers.Add(i);
}
return screenNumbers;
}
}
@ -643,6 +686,7 @@ namespace Flow.Launcher.ViewModel
get
{
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
if (wallpaper != null && File.Exists(wallpaper))
{
var memStream = new MemoryStream(File.ReadAllBytes(wallpaper));
@ -656,12 +700,14 @@ namespace Flow.Launcher.ViewModel
{
Stretch = Stretch.UniformToFill
};
return brush;
}
else
{
var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
var brush = new SolidColorBrush(wallpaperColor);
return brush;
}
}
@ -698,8 +744,10 @@ namespace Flow.Launcher.ViewModel
IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.ProcessKiller\Images\app.png")
}
};
var vm = new ResultsViewModel(Settings);
vm.AddResults(results, "PREVIEW");
return vm;
}
}
@ -713,11 +761,13 @@ namespace Flow.Launcher.ViewModel
o.FamilyNames.Values.Contains(Settings.QueryBoxFont)) > 0)
{
var font = new FontFamily(Settings.QueryBoxFont);
return font;
}
else
{
var font = new FontFamily("Segoe UI");
return font;
}
}
@ -738,6 +788,7 @@ namespace Flow.Launcher.ViewModel
Settings.QueryBoxFontWeight,
Settings.QueryBoxFontStretch
));
return typeface;
}
set
@ -758,11 +809,13 @@ namespace Flow.Launcher.ViewModel
o.FamilyNames.Values.Contains(Settings.ResultFont)) > 0)
{
var font = new FontFamily(Settings.ResultFont);
return font;
}
else
{
var font = new FontFamily("Segoe UI");
return font;
}
}
@ -783,6 +836,7 @@ namespace Flow.Launcher.ViewModel
Settings.ResultFontWeight,
Settings.ResultFontStretch
));
return typeface;
}
set
@ -815,16 +869,21 @@ namespace Flow.Launcher.ViewModel
public void DeleteSelectedCustomShortcut()
{
var item = SelectedCustomShortcut;
if (item == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return;
}
string deleteWarning = string.Format(
InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"),
item.Key, item.Value);
if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"),
item.Key,
item.Value);
if (MessageBox.Show(deleteWarning,
InternationalizationManager.Instance.GetTranslation("delete"),
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
Settings.CustomShortcuts.Remove(item);
@ -834,13 +893,16 @@ namespace Flow.Launcher.ViewModel
public bool EditSelectedCustomShortcut()
{
var item = SelectedCustomShortcut;
if (item == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return false;
}
var shortcutSettingWindow = new CustomShortcutSetting(item.Key, item.Value, this);
if (shortcutSettingWindow.ShowDialog() == true)
{
// Fix un-selectable shortcut item after the first selection
@ -849,14 +911,17 @@ namespace Flow.Launcher.ViewModel
item.Key = shortcutSettingWindow.Key;
item.Value = shortcutSettingWindow.Value;
SelectedCustomShortcut = item;
return true;
}
return false;
}
public void AddCustomShortcut()
{
var shortcutSettingWindow = new CustomShortcutSetting(this);
if (shortcutSettingWindow.ShowDialog() == true)
{
var shortcut = new CustomShortcutModel(shortcutSettingWindow.Key, shortcutSettingWindow.Value);
@ -874,11 +939,17 @@ namespace Flow.Launcher.ViewModel
#region about
public string Website => Constant.Website;
public string SponsorPage => Constant.SponsorPage;
public string ReleaseNotes => _updater.GitHubRepository + @"/releases/latest";
public string Documentation => Constant.Documentation;
public string Docs => Constant.Docs;
public string Github => Constant.GitHub;
public string Version
{
get
@ -893,6 +964,7 @@ namespace Flow.Launcher.ViewModel
}
}
}
public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
public string CheckLogFolder
@ -901,6 +973,7 @@ namespace Flow.Launcher.ViewModel
{
var logFiles = GetLogFiles();
long size = logFiles.Sum(file => file.Length);
return string.Format("{0} ({1})", _translater.GetTranslation("clearlogfolder"), BytesToReadableString(size));
}
}
@ -942,6 +1015,7 @@ namespace Flow.Launcher.ViewModel
{
"GB", "MB", "KB", "B"
};
long max = (long)Math.Pow(scale, orders.Length - 1);
foreach (string order in orders)
@ -951,6 +1025,7 @@ namespace Flow.Launcher.ViewModel
max /= scale;
}
return "0 B";
}