From 02e0f2b25489bba452806790914915a6ba16d796 Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 23 Jun 2026 14:41:52 +0200 Subject: [PATCH] Removed obsolete code Fixed #461 --- ...aredMauiCoreLibrary.Database.SQLite.csproj | 2 + .../SharedMauiCoreLibrary.Test.csproj | 2 +- .../Android/Services/PlatformThemeService.cs | 32 ------------- .../Services/PlatformThemeService.cs | 47 ------------------- .../Windows/Services/PlatformThemeService.cs | 39 --------------- .../iOS/Services/PlatformThemeService.cs | 34 -------------- .../Services/PlatformThemeService.cs | 12 ----- .../Utilities/SecretAppSettingReader.cs | 32 ------------- 8 files changed, 3 insertions(+), 197 deletions(-) delete mode 100644 src/SharedMauiCoreLibrary/Platforms/Android/Services/PlatformThemeService.cs delete mode 100644 src/SharedMauiCoreLibrary/Platforms/MacCatalyst/Services/PlatformThemeService.cs delete mode 100644 src/SharedMauiCoreLibrary/Platforms/Windows/Services/PlatformThemeService.cs delete mode 100644 src/SharedMauiCoreLibrary/Platforms/iOS/Services/PlatformThemeService.cs delete mode 100644 src/SharedMauiCoreLibrary/Services/PlatformThemeService.cs delete mode 100644 src/SharedNetCoreLibrary/Utilities/SecretAppSettingReader.cs diff --git a/src/SharedMauiCoreLibrary.Database.SQLite/SharedMauiCoreLibrary.Database.SQLite.csproj b/src/SharedMauiCoreLibrary.Database.SQLite/SharedMauiCoreLibrary.Database.SQLite.csproj index 36801dd..02eecb0 100644 --- a/src/SharedMauiCoreLibrary.Database.SQLite/SharedMauiCoreLibrary.Database.SQLite.csproj +++ b/src/SharedMauiCoreLibrary.Database.SQLite/SharedMauiCoreLibrary.Database.SQLite.csproj @@ -46,6 +46,8 @@ + + diff --git a/src/SharedMauiCoreLibrary.Test/SharedMauiCoreLibrary.Test.csproj b/src/SharedMauiCoreLibrary.Test/SharedMauiCoreLibrary.Test.csproj index 0f19ca6..8c18ea0 100644 --- a/src/SharedMauiCoreLibrary.Test/SharedMauiCoreLibrary.Test.csproj +++ b/src/SharedMauiCoreLibrary.Test/SharedMauiCoreLibrary.Test.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/SharedMauiCoreLibrary/Platforms/Android/Services/PlatformThemeService.cs b/src/SharedMauiCoreLibrary/Platforms/Android/Services/PlatformThemeService.cs deleted file mode 100644 index 2852fff..0000000 --- a/src/SharedMauiCoreLibrary/Platforms/Android/Services/PlatformThemeService.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Android.OS; -using Microsoft.Maui.Platform; -using System.Runtime.Versioning; -using Color = Microsoft.Maui.Graphics.Color; - -namespace AndreasReitberger.Shared.Core.Services -{ - public partial class PlatformThemeService - { - // Source: https://stackoverflow.com/a/39164921/10083577 - [UnsupportedOSPlatform("Android22.0")] - [SupportedOSPlatform("Android21.0")] - public static partial void SetStatusBarColor(Color color) - { - Android.Graphics.Color androidColor = color.AddLuminosity(-0.1f).ToPlatform(); - // The SetStatusBarcolor is new since API 21 - if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop && Build.VERSION.SdkInt < BuildVersionCodes.VanillaIceCream) - { - Platform.CurrentActivity?.Window?.SetStatusBarColor(androidColor); - } - else if (Build.VERSION.SdkInt >= BuildVersionCodes.VanillaIceCream) - { - - } - else - { - // Here you will just have to set your - // color in styles.xml file as shown below. - } - } - } -} diff --git a/src/SharedMauiCoreLibrary/Platforms/MacCatalyst/Services/PlatformThemeService.cs b/src/SharedMauiCoreLibrary/Platforms/MacCatalyst/Services/PlatformThemeService.cs deleted file mode 100644 index f613360..0000000 --- a/src/SharedMauiCoreLibrary/Platforms/MacCatalyst/Services/PlatformThemeService.cs +++ /dev/null @@ -1,47 +0,0 @@ -using CoreGraphics; -using Foundation; -using Microsoft.Maui.Platform; -using System.Runtime.Versioning; -using UIKit; -using Color = Microsoft.Maui.Graphics.Color; - -namespace AndreasReitberger.Shared.Core.Services -{ - public partial class PlatformThemeService - { - // Source: https://stackoverflow.com/a/39164921/10083577 - [SupportedOSPlatform(SPlatforms.IOSVersion)] - [SupportedOSPlatform(SPlatforms.MACCatalystVersion)] - public static partial void SetStatusBarColor(Color color) - { - // Source: https://blog.verslu.is/maui/change-maui-ios-status-bar-color/ - UIView? statusBar; - if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0)) - { - nint tag = 4567890; - UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow(); - statusBar = window.ViewWithTag(tag); - //if (statusBar == null || statusBar.Frame != UIApplication.SharedApplication.StatusBarFrame) - if (statusBar == null || statusBar.Frame != window.WindowScene?.StatusBarManager?.StatusBarFrame) - { - if (window.WindowScene?.StatusBarManager?.StatusBarFrame is CGRect frame) - { - statusBar ??= new(frame); - statusBar.Frame = frame; - statusBar.Tag = tag; - window.AddSubview(statusBar); - } - } - } - else - { - if (UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) is UIView view) - { - statusBar = view; - statusBar?.BackgroundColor = color.ToPlatform(); - } - } - - } - } -} diff --git a/src/SharedMauiCoreLibrary/Platforms/Windows/Services/PlatformThemeService.cs b/src/SharedMauiCoreLibrary/Platforms/Windows/Services/PlatformThemeService.cs deleted file mode 100644 index 4508e7e..0000000 --- a/src/SharedMauiCoreLibrary/Platforms/Windows/Services/PlatformThemeService.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.UI; -using Microsoft.UI.Windowing; -using System.Runtime.Versioning; -using WinRT.Interop; -using Color = Microsoft.Maui.Graphics.Color; - -namespace AndreasReitberger.Shared.Core.Services -{ - public partial class PlatformThemeService - { - //AppWindow m_AppWindow; - [SupportedOSPlatform(SPlatforms.WindowsVersion)] - public static partial void SetStatusBarColor(Color color) - { - // https://learn.microsoft.com/en-us/windows/apps/develop/title-bar?tabs=wasdk - if (AppWindowTitleBar.IsCustomizationSupported()) - { - // Not supported on WinUI3 - /* - if (m_AppWindow == null) - { - m_AppWindow = GetAppWindowForCurrentWindow(); - } - AppWindowTitleBar titleBar = m_AppWindow.TitleBar; - titleBar.BackgroundColor = color.ToWindowsColor(); - */ - } - } - - #region Private - AppWindow GetAppWindowForCurrentWindow() - { - IntPtr hWnd = WindowNative.GetWindowHandle(this); - WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd); - return AppWindow.GetFromWindowId(wndId); - } - #endregion - } -} diff --git a/src/SharedMauiCoreLibrary/Platforms/iOS/Services/PlatformThemeService.cs b/src/SharedMauiCoreLibrary/Platforms/iOS/Services/PlatformThemeService.cs deleted file mode 100644 index e5b43db..0000000 --- a/src/SharedMauiCoreLibrary/Platforms/iOS/Services/PlatformThemeService.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Foundation; -using Microsoft.Maui.Platform; -using System.Runtime.Versioning; -using UIKit; -using Color = Microsoft.Maui.Graphics.Color; - -namespace AndreasReitberger.Shared.Core.Services -{ - public partial class PlatformThemeService - { - // Source: https://stackoverflow.com/a/39164921/10083577 - [SupportedOSPlatform(SPlatforms.IOSVersion)] - [SupportedOSPlatform(SPlatforms.MACCatalystVersion)] - public static partial void SetStatusBarColor(Color color) - { - if (OperatingSystem.IsIOSVersionAtLeast(13)) - { - //var currentWindow = WindowStateManager.Default.GetCurrentUIWindow(); - // Nothing to do here, if needed use the `StatusBarBehavior` - // Docs: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/statusbar-behavior?tabs=ios - // Git : https://github.com/CommunityToolkit/Maui/blob/main/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs - } - else - { - if (UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) is UIView statusBar && statusBar.RespondsToSelector( - new ObjCRuntime.Selector("setBackgroundColor:"))) - { - // change to your desired color - statusBar.BackgroundColor = color.ToPlatform(); - } - } - } - } -} diff --git a/src/SharedMauiCoreLibrary/Services/PlatformThemeService.cs b/src/SharedMauiCoreLibrary/Services/PlatformThemeService.cs deleted file mode 100644 index c0601b5..0000000 --- a/src/SharedMauiCoreLibrary/Services/PlatformThemeService.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace AndreasReitberger.Shared.Core.Services -{ - // Somehow has trouble with .NET 6 -#if ANDROID || IOS || MACCATALYST || WINDOWS - [Obsolete("Use the CommunityToolkit Behavior instead: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/statusbar-behavior?tabs=ios")] - public partial class PlatformThemeService - { - // Based on: https://stackoverflow.com/a/39164921/10083577 - public static partial void SetStatusBarColor(Color color); - } -#endif -} diff --git a/src/SharedNetCoreLibrary/Utilities/SecretAppSettingReader.cs b/src/SharedNetCoreLibrary/Utilities/SecretAppSettingReader.cs deleted file mode 100644 index 66118d3..0000000 --- a/src/SharedNetCoreLibrary/Utilities/SecretAppSettingReader.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; - -namespace AndreasReitberger.Shared.Core.Utilities -{ - [Obsolete("Use `UserSecretsManager` instead of this class")] - public class SecretAppSettingReader - { - #region Properties - public static Assembly? Assembly { get; set; } - #endregion - - public static T? ReadSectionFromConfigurationRoot(Type type, string appNameSpace, string sectionName, JsonSerializerContext? context = null) - { - // It seems that this way makes problems if the app is published on Windows in Release mode - // Needs the Directory.Build.targets in order to work (copies the secret.json as EmbeddedResource to the app) - UserSecretsManager? secrets = null; - if (Assembly is null) - { - Assembly = IntrospectionExtensions.GetTypeInfo(type).Assembly; - secrets = new UserSecretsManager.UserSecretsManagerBuilder() - .WithAppNamespace(appNameSpace) - .WithCustomAssambly(Assembly) - .Build(); - } - context ??= CoreSourceGenerationContext.Default; - string? settings = secrets?[sectionName].ToString(); - if (string.IsNullOrEmpty(settings)) - return default; - return (T?)JsonSerializer.Deserialize(settings, typeof(T), context); - } - } -}