Skip to content

Commit

Permalink
Merge pull request #37 from myfix16/dev_v1.4.2
Browse files Browse the repository at this point in the history
Dev v1.4.2
  • Loading branch information
myfix16 authored Jun 8, 2023
2 parents 657e445 + 577eaa6 commit e8020b3
Show file tree
Hide file tree
Showing 24 changed files with 813 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
10 changes: 0 additions & 10 deletions Tests/BatteryTracker.Tests.UnitTests/Mocks/MockBatteryIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ public MockBatteryIcon(IAppNotificationService notificationService, ILogger<Mock
{
}

public new bool EnableLowPowerNotification { get; set; }

public new int LowPowerNotificationThreshold { get; set; }

public new bool EnableHighPowerNotification { get; set; }

public new int HighPowerNotificationThreshold { get; set; }

public new bool EnableFullyChargedNotification { get; set; }

public new async Task InitAsync(TaskbarIcon icon)
{
await Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class MockSettingsService : ISettingsService
{
public IList<AppLanguageItem> 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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -96,7 +95,7 @@ public void TestAppThemeSettingWroteToStorage(ElementTheme theme)
// App theme
try
{
_viewModel.ElementTheme = theme;
_viewModel.AppTheme = theme;
}
catch { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public BatteryIconTest()
{
_batteryIcon.Dispose();
}

#if DEBUG
[UITestMethod]
public void TestUpdateIconPercent()
{
Expand All @@ -54,4 +54,5 @@ public void TestUpdateIconPercent()
Thread.Sleep(100);
}
}
#endif
}
2 changes: 1 addition & 1 deletion scripts/CreateBatteryTrackerUpload.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/Activation/LaunchActivationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
19 changes: 9 additions & 10 deletions src/App.xaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Application
x:Class="BatteryTracker.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BatteryTracker"
>
xmlns:local="using:BatteryTracker">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
<!-- Other merged dictionaries here -->
<ResourceDictionary Source="/Resources/Commands.xaml" />
<ResourceDictionary Source="/Styles/Button.xaml" />
<ResourceDictionary Source="/Styles/FontSizes.xaml" />
<ResourceDictionary Source="/Styles/Thickness.xaml" />
<ResourceDictionary Source="/Styles/TextBlock.xaml" />
</ResourceDictionary.MergedDictionaries>

<!-- Other app resources here -->
<!-- Other app resources here -->
<!-- Overrides -->
<Thickness x:Key="InfoBarIconMargin">6,16,16,16</Thickness>
<Thickness x:Key="InfoBarContentRootPadding">16,0,0,0</Thickness>
<x:Double x:Key="SettingActionControlMinWidth">240</x:Double>

<TransitionCollection x:Key="SettingsCardsAnimations">
<EntranceThemeTransition FromVerticalOffset="50"/>
<!-- Animates cards when loaded-->
<RepositionThemeTransition IsStaggeringEnabled="False" />
<!-- Smoothly animates individual cards upon whenever Expanders are expanded/collapsed -->
<EntranceThemeTransition FromVerticalOffset="50" />
<!-- Animates cards when loaded -->
<RepositionThemeTransition IsStaggeringEnabled="False" />
<!-- Smoothly animates individual cards upon whenever Expanders are expanded/collapsed -->
</TransitionCollection>
</ResourceDictionary>
</Application.Resources>
Expand Down
2 changes: 1 addition & 1 deletion src/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IActivationService>().ActivateAsync(activationArgs);

Expand Down
93 changes: 44 additions & 49 deletions src/BatteryTracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
<ApplicationIcon>Assets\logo.ico</ApplicationIcon>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>1DCF5FAB4D9BC65E306EB18C7165F58F246D9952</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<GenerateTestArtifacts>False</GenerateTestArtifacts>
<AppxBundle>Always</AppxBundle>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
<PackageCertificateKeyFile>BatteryTracker_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -50,6 +50,7 @@
<EmbeddedResource Remove="StaticResources\**" />
<None Remove="StaticResources\**" />
<Page Remove="StaticResources\**" />
<PRIResource Remove="StaticResources\**" />
</ItemGroup>
<ItemGroup>
<Content Remove="Assets\BadgeLogo.png" />
Expand Down Expand Up @@ -79,9 +80,20 @@
<None Remove="Assets\Square44x44Logo.targetsize-32.png" />
<None Remove="Assets\Square44x44Logo.targetsize-48.png" />
<None Remove="Assets\Square44x44Logo.targetsize-48_altform-unplated.png" />
</ItemGroup>

<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>

<ItemGroup>
<None Remove="Controls\SettingsGroup.xaml" />
<None Remove="MainWindow.xaml" />
<None Remove="Settings.xaml" />
<None Remove="Styles\Button.xaml" />
<None Remove="Styles\FontSizes.xaml" />
<None Remove="Styles\TextBlock.xaml" />
Expand All @@ -92,15 +104,7 @@
<None Remove="Views\ShellPage.xaml" />
</ItemGroup>

<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>

<!-- Package references -->
<ItemGroup>
<PackageReference Include="CommunityToolkit.Labs.WinUI.SettingsControls" Version="0.0.17" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
Expand All @@ -109,11 +113,11 @@
<PackageReference Include="H.NotifyIcon" Version="2.0.108" />
<PackageReference Include="H.NotifyIcon.WinUI" Version="2.0.108" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230331000" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230502000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="Mii.Serilog.Extensions.Logging.File" Version="1.0.1" />
<PackageReference Include="WinUIEx" Version="2.1.0" />
<PackageReference Include="WinUIEx" Version="2.2.0" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand All @@ -125,32 +129,31 @@
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<ItemGroup>
<Page Update="Views\AboutPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Explorer "Package and Publish" context menu entry to be enabled for this project even if
the Windows App SDK Nuget package has not yet been restored.
-->
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>

<!-- Views -->
<ItemGroup>
<Page Update="MainWindow.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Settings.xaml">
<Folder Include="Controls\SettingsGroup\" />
<Page Update="Controls\SettingsGroup.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Styles\FontSizes.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Styles\TextBlock.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Styles\Thickness.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="TrayIcon.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\AboutPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\SettingsPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
Expand All @@ -159,30 +162,22 @@
</Page>
</ItemGroup>

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Explorer "Package and Publish" context menu entry to be enabled for this project even if
the Windows App SDK Nuget package has not yet been restored.
-->
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>
<ItemGroup>
<PRIResource Remove="StaticResources\**" />
</ItemGroup>
<!-- Styles -->
<ItemGroup>
<Page Update="Styles\Button.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Controls\SettingsGroup.xaml">
<Generator>MSBuild:Compile</Generator>
<Page Update="Styles\FontSizes.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Styles\TextBlock.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Styles\Thickness.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>
<ItemGroup>
<Folder Include="Controls\SettingsGroup\" />
</ItemGroup>

<!-- <ItemGroup> -->
<!-- <Page Remove="Themes\Generic.xaml" /> -->
<!-- </ItemGroup> -->
Expand Down
18 changes: 18 additions & 0 deletions src/Contracts/Models/IBatterySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace BatteryTracker.Contracts.Models
{
/// <summary>
/// Contains settings for battery notifications.
/// </summary>
public interface IBatterySettings
{
bool FullyChargedNotificationEnabled { get; set; }

bool LowPowerNotificationEnabled { get; set; }

int LowPowerNotificationThreshold { get; set; }

bool HighPowerNotificationEnabled { get; set; }

int HighPowerNotificationThreshold { get; set; }
}
}
Loading

0 comments on commit e8020b3

Please sign in to comment.