diff --git a/Tests/BatteryTracker.Tests.UnitTests/BatteryTracker.Tests.UnitTests.csproj b/Tests/BatteryTracker.Tests.UnitTests/BatteryTracker.Tests.UnitTests.csproj index bf704f1..a4ad931 100644 --- a/Tests/BatteryTracker.Tests.UnitTests/BatteryTracker.Tests.UnitTests.csproj +++ b/Tests/BatteryTracker.Tests.UnitTests/BatteryTracker.Tests.UnitTests.csproj @@ -13,10 +13,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/BatteryTracker.Tests.UnitTests/Mocks/MockBatteryIcon.cs b/Tests/BatteryTracker.Tests.UnitTests/Mocks/MockBatteryIcon.cs index 702ec4f..f85ea1b 100644 --- a/Tests/BatteryTracker.Tests.UnitTests/Mocks/MockBatteryIcon.cs +++ b/Tests/BatteryTracker.Tests.UnitTests/Mocks/MockBatteryIcon.cs @@ -12,16 +12,6 @@ public MockBatteryIcon(IAppNotificationService notificationService, ILogger Languages { get; } - public bool EnableFullyChargedNotification { get; set; } + public bool FullyChargedNotificationEnabled { get; set; } - public bool EnableLowPowerNotification { get; set; } + public bool LowPowerNotificationEnabled { get; set; } public int LowPowerNotificationThreshold { get; set; } - public bool EnableHighPowerNotification { get; set; } + public bool HighPowerNotificationEnabled { get; set; } public int HighPowerNotificationThreshold { get; set; } diff --git a/Tests/BatteryTracker.Tests.UnitTests/ViewModelsTests/SettingsViewModelTest.cs b/Tests/BatteryTracker.Tests.UnitTests/ViewModelsTests/SettingsViewModelTest.cs index f6e52d5..4c8b09f 100644 --- a/Tests/BatteryTracker.Tests.UnitTests/ViewModelsTests/SettingsViewModelTest.cs +++ b/Tests/BatteryTracker.Tests.UnitTests/ViewModelsTests/SettingsViewModelTest.cs @@ -36,8 +36,8 @@ public SettingsViewModelTest() public void TestFullyChargedNotificationSettingWroteToStorage(bool isEnabled) { // Fully charged notification - _viewModel.EnableFullyChargedNotification = isEnabled; - Assert.AreEqual(isEnabled, (bool)_settingsService.EnableFullyChargedNotification); + _viewModel.FullyChargedNotificationEnabled = isEnabled; + Assert.AreEqual(isEnabled, _settingsService.FullyChargedNotificationEnabled); } [TestMethod] @@ -46,8 +46,8 @@ public void TestFullyChargedNotificationSettingWroteToStorage(bool isEnabled) public void TestLowPowerNotificationSettingWroteToStorage(bool isEnabled) { // Low power notification - _viewModel.EnableLowPowerNotification = isEnabled; - Assert.AreEqual(isEnabled, (bool)_settingsService.EnableLowPowerNotification); + _viewModel.LowPowerNotificationEnabled = isEnabled; + Assert.AreEqual(isEnabled, _settingsService.LowPowerNotificationEnabled); } [TestMethod] @@ -60,7 +60,7 @@ public void TestLowPowerThresholdSettingWroteToStorage(int threshold) { // Low power threshold _viewModel.LowPowerNotificationThreshold = threshold; - Assert.AreEqual(threshold, (int)_settingsService.LowPowerNotificationThreshold); + Assert.AreEqual(threshold, _settingsService.LowPowerNotificationThreshold); } [TestMethod] @@ -69,8 +69,8 @@ public void TestLowPowerThresholdSettingWroteToStorage(int threshold) public void TestHighPowerNotificationSettingWroteToStorage(bool isEnabled) { // High power notification - _viewModel.EnableHighPowerNotification = isEnabled; - Assert.AreEqual(isEnabled, (bool)_settingsService.EnableHighPowerNotification); + _viewModel.HighPowerNotificationEnabled = isEnabled; + Assert.AreEqual(isEnabled, _settingsService.HighPowerNotificationEnabled); } [TestMethod] @@ -83,8 +83,7 @@ public void TestHighPowerThresholdSettingWroteToStorage(int threshold) { // High power threshold _viewModel.HighPowerNotificationThreshold = threshold; - Assert.AreEqual(threshold, - (int)_settingsService.HighPowerNotificationThreshold); + Assert.AreEqual(threshold, _settingsService.HighPowerNotificationThreshold); } [TestMethod] @@ -96,7 +95,7 @@ public void TestAppThemeSettingWroteToStorage(ElementTheme theme) // App theme try { - _viewModel.ElementTheme = theme; + _viewModel.AppTheme = theme; } catch { } diff --git a/Tests/BatteryTracker.Tests.UnitTests/ViewTests/BatteryIconTest.cs b/Tests/BatteryTracker.Tests.UnitTests/ViewTests/BatteryIconTest.cs index 9828bf2..4d2cf13 100644 --- a/Tests/BatteryTracker.Tests.UnitTests/ViewTests/BatteryIconTest.cs +++ b/Tests/BatteryTracker.Tests.UnitTests/ViewTests/BatteryIconTest.cs @@ -44,7 +44,7 @@ public BatteryIconTest() { _batteryIcon.Dispose(); } - +#if DEBUG [UITestMethod] public void TestUpdateIconPercent() { @@ -54,4 +54,5 @@ public void TestUpdateIconPercent() Thread.Sleep(100); } } +#endif } diff --git a/scripts/CreateBatteryTrackerUpload.ps1 b/scripts/CreateBatteryTrackerUpload.ps1 index a9ef6b5..85719e8 100644 --- a/scripts/CreateBatteryTrackerUpload.ps1 +++ b/scripts/CreateBatteryTrackerUpload.ps1 @@ -12,7 +12,7 @@ param ( $packagesFolder = Join-Path (Get-Item $PSScriptRoot).Parent "packages" $msixsFolder = Join-Path $packagesFolder "msixs" $symbolsFolder = Join-Path $packagesFolder "symbols" -$outputFormatString = Join-Path (Get-Item $PSScriptRoot).Parent "src/bin/{0}/Release/net7.0-windows10.0.22000.0/win10-{0}/AppPackages/BatteryTracker_{1}_Test" +$outputFormatString = Join-Path (Get-Item $PSScriptRoot).Parent "src/bin/{0}/Release/net7.0-windows10.0.22000.0/AppPackages/BatteryTracker_{1}_Test" $msixBundlePath = Join-Path $packagesFolder "BatteryTracker_${version}_x86_x64_arm64.msixbundle" $msixUploadPath = Join-Path $packagesFolder "BatteryTracker_${version}_x86_x64_arm64_bundle.msixupload" $archs = "x86", "x64", "arm64" diff --git a/src/Activation/LaunchActivationHandler.cs b/src/Activation/LaunchActivationHandler.cs index 0659a60..fc8aec1 100644 --- a/src/Activation/LaunchActivationHandler.cs +++ b/src/Activation/LaunchActivationHandler.cs @@ -45,7 +45,7 @@ protected override async Task HandleInternalAsync(AppActivationArguments args) if (args.Data is ILaunchActivatedEventArgs launchArgs) { string[] argStrings = launchArgs.Arguments.Split(' '); - _logger.LogInformation($"App launched with command line args: [{string.Join(", ", argStrings)}]"); + _logger.LogInformation("App launched with command line args: [{args}]", string.Join(", ", argStrings)); if (argStrings.Contains(OpenSettingsCommandArg)) { diff --git a/src/App.xaml b/src/App.xaml index 6065894..e1c99f4 100644 --- a/src/App.xaml +++ b/src/App.xaml @@ -1,17 +1,16 @@ - - + + + xmlns:local="using:BatteryTracker"> - + @@ -19,17 +18,17 @@ - + 6,16,16,16 16,0,0,0 240 - - - - + + + + diff --git a/src/App.xaml.cs b/src/App.xaml.cs index d3f92cf..e611f42 100644 --- a/src/App.xaml.cs +++ b/src/App.xaml.cs @@ -126,7 +126,7 @@ public async void OnXamlRootChanged(XamlRoot sender, XamlRootChangedEventArgs _) protected override async void OnLaunched(LaunchActivatedEventArgs args) { AppActivationArguments activationArgs = AppInstance.GetCurrent().GetActivatedEventArgs(); - _logger.LogInformation($"App launched with activation kind: {activationArgs.Kind}"); + _logger.LogInformation("App launched with activation kind: {activationKind}", activationArgs.Kind); await GetService().ActivateAsync(activationArgs); diff --git a/src/BatteryTracker.csproj b/src/BatteryTracker.csproj index 48ed100..117d1be 100644 --- a/src/BatteryTracker.csproj +++ b/src/BatteryTracker.csproj @@ -16,14 +16,14 @@ Assets\logo.ico False True - 1DCF5FAB4D9BC65E306EB18C7165F58F246D9952 SHA256 False True - True + False Always 0 x86|x64|arm64 + BatteryTracker_TemporaryKey.pfx @@ -50,6 +50,7 @@ + @@ -79,9 +80,20 @@ + + + + + + + + + + + + - @@ -92,15 +104,7 @@ - - - - - - - - - + @@ -109,11 +113,11 @@ - + - + @@ -125,32 +129,31 @@ - - - MSBuild:Compile - - + + + + true + + + $(DefaultXamlRuntime) - + + MSBuild:Compile - - $(DefaultXamlRuntime) - - - $(DefaultXamlRuntime) - - - $(DefaultXamlRuntime) - - - MSBuild:Compile + + MSBuild:Compile + $(DefaultXamlRuntime) @@ -159,30 +162,22 @@ - - - true - - - - + MSBuild:Compile - - - - MSBuild:Compile + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) - - - + diff --git a/src/Contracts/Models/IBatterySettings.cs b/src/Contracts/Models/IBatterySettings.cs new file mode 100644 index 0000000..c0b3169 --- /dev/null +++ b/src/Contracts/Models/IBatterySettings.cs @@ -0,0 +1,18 @@ +namespace BatteryTracker.Contracts.Models +{ + /// + /// Contains settings for battery notifications. + /// + public interface IBatterySettings + { + bool FullyChargedNotificationEnabled { get; set; } + + bool LowPowerNotificationEnabled { get; set; } + + int LowPowerNotificationThreshold { get; set; } + + bool HighPowerNotificationEnabled { get; set; } + + int HighPowerNotificationThreshold { get; set; } + } +} diff --git a/src/Contracts/Services/ISettingsService.cs b/src/Contracts/Services/ISettingsService.cs index dc425a3..5663feb 100644 --- a/src/Contracts/Services/ISettingsService.cs +++ b/src/Contracts/Services/ISettingsService.cs @@ -1,22 +1,13 @@ using System.Collections.Generic; +using BatteryTracker.Contracts.Models; using BatteryTracker.Models; namespace BatteryTracker.Contracts.Services { - public interface ISettingsService + public interface ISettingsService : IBatterySettings { IList Languages { get; } - bool EnableFullyChargedNotification { get; set; } - - bool EnableLowPowerNotification { get; set; } - - int LowPowerNotificationThreshold { get; set; } - - bool EnableHighPowerNotification { get; set; } - - int HighPowerNotificationThreshold { get; set; } - ElementTheme Theme { get; set; } AppLanguageItem Language { get; set; } diff --git a/src/Helpers/LaunchHelper.cs b/src/Helpers/LaunchHelper.cs index 06adaf3..af7953b 100644 --- a/src/Helpers/LaunchHelper.cs +++ b/src/Helpers/LaunchHelper.cs @@ -10,6 +10,7 @@ public static class LaunchHelper public const string PrivacyStatementUri = "https://github.com/myfix16/BatteryTracker/blob/main/Privacy.md"; public const string EmailFeedbackUri = "mailto:myfix16@outlook.com?subject=Battery%20Tracker%20Feedback"; public const string StoreRatingUri = "ms-windows-store:review/?ProductId=9P1FBSLRNM43"; + public const string TranslationUri = "https://hosted.weblate.org/projects/battery-tracker/app/"; public static Process? StartProcess(string process) { diff --git a/src/MainWindow.xaml b/src/MainWindow.xaml index 2954f72..e1e5e65 100644 --- a/src/MainWindow.xaml +++ b/src/MainWindow.xaml @@ -4,31 +4,23 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:windowex="using:WinUIEx" - xmlns:tb="using:H.NotifyIcon" + xmlns:tb="using:H.NotifyIcon" xmlns:windowex="using:WinUIEx" + MinWidth="500" MinHeight="200" PersistenceId="MainWindow" - MinHeight="200" - MinWidth="500" mc:Ignorable="d"> - - - + + + + + ContextMenuMode="PopupMenu" NoLeftClickDelay="True" + ToolTipText="Battery Tracker" Visibility="Visible"> + BackgroundType="Rectangle" FontFamily="Arial" FontWeight="SemiBold" + Foreground="White" Text="99" /> diff --git a/src/Package.appxmanifest b/src/Package.appxmanifest index 315f7d9..8a22da7 100644 --- a/src/Package.appxmanifest +++ b/src/Package.appxmanifest @@ -13,12 +13,7 @@ - - - - - + Version="1.4.2.0" /> Battery Tracker @@ -34,6 +29,8 @@ + + diff --git a/src/Services/SettingsService.cs b/src/Services/SettingsService.cs index c0e6b19..b0fa8e4 100644 --- a/src/Services/SettingsService.cs +++ b/src/Services/SettingsService.cs @@ -41,24 +41,24 @@ internal sealed class SettingsService : BaseJsonSettingsService, ISettingsServic public IList Languages { get; private set; } - private bool _enableFullyChargedNotification; - public bool EnableFullyChargedNotification + private bool _fullyChargedNotificationEnabled; + public bool FullyChargedNotificationEnabled { - get => _enableFullyChargedNotification; + get => _fullyChargedNotificationEnabled; set { - _enableFullyChargedNotification = value; + _fullyChargedNotificationEnabled = value; Set(EnableFullyChargedNotificationSettingsKey, value); } } - private bool _enableLowPowerNotification; - public bool EnableLowPowerNotification + private bool _lowPowerNotificationEnabled; + public bool LowPowerNotificationEnabled { - get => _enableLowPowerNotification; + get => _lowPowerNotificationEnabled; set { - _enableLowPowerNotification = value; + _lowPowerNotificationEnabled = value; Set(EnableLowPowerNotificationSettingsKey, value); } } @@ -74,13 +74,13 @@ public int LowPowerNotificationThreshold } } - private bool _enableHighPowerNotification; - public bool EnableHighPowerNotification + private bool _highPowerNotificationEnabled; + public bool HighPowerNotificationEnabled { - get => _enableHighPowerNotification; + get => _highPowerNotificationEnabled; set { - _enableHighPowerNotification = value; + _highPowerNotificationEnabled = value; Set(EnableHighPowerNotificationSettingsKey, value); } } @@ -173,13 +173,13 @@ private void AddSupportedAppLanguages() private void LoadSettingValues() { - _enableFullyChargedNotification = + _fullyChargedNotificationEnabled = Get(EnableFullyChargedNotificationSettingsKey, EnableFullyChargedNotificationDefault); - _enableLowPowerNotification = + _lowPowerNotificationEnabled = Get(EnableLowPowerNotificationSettingsKey, EnableLowPowerNotificationDefault); _lowPowerNotificationThreshold = Get(LowPowerNotificationThresholdSettingsKey, LowPowerNotificationThresholdDefault); - _enableHighPowerNotification = + _highPowerNotificationEnabled = Get(EnableHighPowerNotificationSettingsKey, EnableHighPowerNotificationDefault); _highPowerNotificationThreshold = Get(HighPowerNotificationThresholdSettingsKey, HighPowerNotificationThresholdDefault); @@ -198,11 +198,11 @@ private void ConvertAndLoadOlderSettings() // Read and convert old settings object? value; value = StorageGetRawValue(EnableFullyChargedNotificationSettingsKey); - EnableFullyChargedNotification = value != null ? (bool)value : EnableFullyChargedNotificationDefault; + FullyChargedNotificationEnabled = value != null ? (bool)value : EnableFullyChargedNotificationDefault; value = StorageGetRawValue(EnableLowPowerNotificationSettingsKey); - EnableLowPowerNotification = value != null ? (bool)value : EnableLowPowerNotificationDefault; + LowPowerNotificationEnabled = value != null ? (bool)value : EnableLowPowerNotificationDefault; value = StorageGetRawValue(EnableHighPowerNotificationSettingsKey); - EnableHighPowerNotification = value != null ? (bool)value : EnableHighPowerNotificationDefault; + HighPowerNotificationEnabled = value != null ? (bool)value : EnableHighPowerNotificationDefault; value = StorageGetRawValue(LowPowerNotificationThresholdSettingsKey); LowPowerNotificationThreshold = value != null ? (int)value : LowPowerNotificationThresholdDefault; value = StorageGetRawValue(HighPowerNotificationThresholdSettingsKey); diff --git a/src/Strings/en-us/Resources.resw b/src/Strings/en-us/Resources.resw index 8752151..5c982dc 100644 --- a/src/Strings/en-us/Resources.resw +++ b/src/Strings/en-us/Resources.resw @@ -1,4 +1,4 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Копіювати + + + Відкритий вихідний код + + + Battery Tracker + + + Показати відсоток заряду батареї на панелі завдань + + + Персоналізація + + + Тема + + + Світла + + + Темна + + + За замовчуванням Windows + + + Про цей застосунок + + + Положення про конфіденційність + + + Ввімкнути сповіщення про повний заряд + + + Ввімкнути сповіщення про низький рівень енергоспоживання + + + Сповіщення + + + Про + + + Налаштування + + + Перезавантажити + + + Застосунок завершено, оскільки сталася непередбачувана помилка + + + Надсилайте відгуки електронною поштою + + + Надіслати відгук + + + Вийти + + + Налаштування + + + Батарею повністю заряджено + + + Мало заряду + + + Ввімкнути сповіщення про достатній заряд + + + Інший екземпляр вже запущено + + + Зовнішній вигляд і поведінка + + + Тема застосунку + + + Версія застосунку + + + Налаштування + + + Відкрити папку журналу + + + Повідомити мене, коли відсоток заряду батареї буде нижчим за: + + + Battery Tracker запуститься автоматично + + + Запустити під час запуску системи + + + Сторонні ліцензії + + + Версія + + + Скопійовано! + + + Налаштування кольорів Windows + + + Оцініть застосунок + + + Системний за замовчуванням + + + Показувати відсоток заряду батареї на панелі завдань + + + Мова + + + Перезапустіть застосунок, щоб зміна мови набула чинності + + + Допомога та підтримка + + + Надіслати проблему на GitHub + + + Версія Windows + + + Повідомити мене, коли відсоток заряду батареї буде вищим за: + + + Надайте зворотній зв'язок + + + Батарея має достатньо заряду + + + Репозиторій GitHub + + + Мова застосунку + + + Допоможіть нам перекласти Battery Tracker! + + \ No newline at end of file diff --git a/src/Strings/zh-Hant/Resources.resw b/src/Strings/zh-Hant/Resources.resw new file mode 100644 index 0000000..8ac41dc --- /dev/null +++ b/src/Strings/zh-Hant/Resources.resw @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 一款在任務欄顯示電池百分比的實用工具 + + + 個性化 + + + 主題 + + + 淺色 + + + 深色 + + + Windows 默認 + + + 關於 + + + 隱私聲明 + + + 啓用低電量通知 + + + 語言 + + + 通知 + + + 設置 + + + 重啓 + + + 重啓應用使變更生效 + + + 一款在任務欄顯示電池百分比的實用工具 + + + 出現了未知錯誤,應用將退出 + + + Battery Tracker + + + 在Github上提交issue + + + 提供反饋 + + + 提交反饋 + + + 退出 + + + 電池已充滿 + + + 電池已有足夠電量 + + + 電池電量不足 + + + 該應用的另一個實例正在運行 + + + 外觀和行爲 + + + 應用主題 + + + 應用版本 + + + 複製 + + + Windows 版本 + + + 設置 + + + Github 存儲庫 + + + 幫助和支持 + + + 在電量百分比高於以下值時推送通知: + + + 應用語言 + + + 打開日志文件夾 + + + 儅電池百分比低於以下值時推送通知: + + + Battery Tracker 將自動啓動 + + + 啓動時運行 + + + 第三方許可 + + + 版本 + + + 已複製! + + + Windows 顔色設置 + + + 評價本應用 + + + 啓用滿電量通知 + + + 關於 + + + 電子郵件反饋 + + + 設置 + + + 啓用電量充足通知 + + + 開放源代碼 + + + 系統默認 + + + 幫助我們翻譯Battery Tracker! + + \ No newline at end of file diff --git a/src/Strings/zh-cn/Resources.resw b/src/Strings/zh-cn/Resources.resw index 617c12c..8ef64c5 100644 --- a/src/Strings/zh-cn/Resources.resw +++ b/src/Strings/zh-cn/Resources.resw @@ -1,4 +1,4 @@ - + @@ -33,10 +33,10 @@ x:Uid="Settings_EnableLowPowerNotification" HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=}" - IsExpanded="{x:Bind ViewModel.EnableLowPowerNotification, Mode=OneWay}"> - + IsExpanded="{x:Bind ViewModel.LowPowerNotificationEnabled, Mode=OneWay}"> + - + - + IsExpanded="{x:Bind ViewModel.HighPowerNotificationEnabled, Mode=OneWay}"> + - + - + - + @@ -108,6 +108,9 @@ + + + - - + + - + - - - + + + diff --git a/src/Views/SettingsPage.xaml.cs b/src/Views/SettingsPage.xaml.cs index 6352e63..13b24b5 100644 --- a/src/Views/SettingsPage.xaml.cs +++ b/src/Views/SettingsPage.xaml.cs @@ -13,9 +13,4 @@ public SettingsPage() ViewModel = App.GetService(); InitializeComponent(); } - - private async void HyperlinkButton_Click(object _, RoutedEventArgs _1) - { - await LaunchHelper.LaunchUriAsync(LaunchHelper.ColorsSettingsUri); - } }