Skip to content

Commit 01d881c

Browse files
authored
Merge pull request #44 from FabriBertani/ver/1.2.0
New release 1.2.0
2 parents 3d742d7 + b923aa7 commit 01d881c

File tree

3 files changed

+87
-18
lines changed

3 files changed

+87
-18
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 1.2.0 (10/14/2024)
4+
[Full Changelog](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/compare/v1.1.6...v1.2.0)
5+
6+
**Implemented enhancements:**
7+
- Added `Blazor` sample to showcase the implementation of this plugin.
8+
- Added `IsProtectionEnabled` property to check if screen protection is already enabled or disabled.
9+
- Added `ScreenCaptured` event handler, which triggers notifications when a screenshot is taken or the screen is recorded.
10+
- Added plugin initialization.
11+
- Updated sample projects with new implementations.
12+
13+
**Fixed bugs:**
14+
- Implemented a new screenshot prevention method for iOS 17+.
15+
- Fixed `GetWindow` method on iOS.
16+
- Merged [#39: Bug iOS on Blur](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/pull/39) PR by [fabien367](https://github.com/fabien367).
17+
318
## 1.1.8-beta (05/25/2024)
419
[Full Changelog](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/compare/v1.1.7-beta...v1.1.8-beta)
520

Plugin.Maui.ScreenSecurity/Plugin.Maui.ScreenSecurity.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
<RepositoryUrl>https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity</RepositoryUrl>
2222
<RepositoryType>git</RepositoryType>
2323
<PackageTags>dotnet-maui;maui;toolkit;security;Plugin.Maui.ScreenSecurity;ScreenSecurity;screen;protection;leak;android;ios</PackageTags>
24-
<AssemblyVersion>1.1.8</AssemblyVersion>
25-
<FileVersion>1.1.8-beta</FileVersion>
24+
<AssemblyVersion>1.2.0</AssemblyVersion>
25+
<FileVersion>1.2.0</FileVersion>
2626
<PackageReadmeFile>README.md</PackageReadmeFile>
2727
<NeutralLanguage>en</NeutralLanguage>
2828
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2929
<PackageIcon>plugin.maui.screensecurity_128x128.jpg</PackageIcon>
3030
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
31-
<Version>1.1.8-beta</Version>
31+
<Version>1.2.0</Version>
3232
<PackageReleaseNotes>https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/blob/main/CHANGELOG.md</PackageReleaseNotes>
3333
<IncludeSymbols>True</IncludeSymbols>
3434
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

README.md

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Plugin.Maui.ScreenSecurity
2-
[![NuGet](https://img.shields.io/nuget/v/Plugin.Maui.ScreenSecurity.svg?label=NuGet)](https://www.nuget.org/packages/Plugin.Maui.ScreenSecurity/1.1.8-beta)
2+
[![NuGet](https://img.shields.io/nuget/v/Plugin.Maui.ScreenSecurity.svg?label=NuGet)](https://www.nuget.org/packages/Plugin.Maui.ScreenSecurity)
33

44
`Plugin.Maui.ScreenSecurity` provides a seamless solution for preventing content exposure, as well as blocking screenshots and recordings within your .NET MAUI application
55

@@ -10,27 +10,53 @@
1010
|.Net MAUI iOS|iOS 14+|
1111
|Windows|10.0.17763+|
1212

13-
## Version 1.1.6
13+
## Version 1.2.0
1414

1515
### What's new?
16-
- Removed .Net6 support. :warning:
17-
- Added .Net8 support to all platforms.
18-
- Fixed iOS 17 issues.
19-
- Fixed screenshot not working on iOS 17+ issue, by changing the screenshot protection implementation, now a blank white or black (depending on the current OS theme) is added before taking the screenshot to cover the screen content. :exclamation:
16+
- Added `IsProtectionEnabled` property to check if screen protection is already enabled or disabled.
17+
- Added `ScreenCaptured` event handler, which triggers notifications when a screenshot is taken or the screen is recorded.
18+
- Fixed iOS issues.
19+
- Added `Blazor` sample to showcase the implementation of this plugin.
2020

21-
Click [here](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/releases/tag/v1.1.6) to see the full Changelog!
21+
Click [here](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/releases/tag/v1.2.0) to see the full Changelog!
2222

2323
## Installation
2424
`Plugin.Maui.ScreenSecurity` is available via NuGet, grab the latest package and install it on your solution:
2525

2626
Install-Package Plugin.Maui.ScreenSecurity
2727

28-
In your `MauiProgram` class add the following `using` statement:
28+
Initialize the plugin in your `MauiProgram` class:
2929

3030
```csharp
3131
using Plugin.Maui.ScreenSecurity;
32+
33+
public static MauiApp CreateMauiApp()
34+
{
35+
var builder = MauiApp.CreateBuilder();
36+
37+
builder
38+
.UseMauiApp<App>()
39+
.ConfigureFonts(fonts =>
40+
{
41+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
42+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
43+
})
44+
.UseScreenSecurity();
45+
46+
return builder.Build();
47+
}
3248
```
3349

50+
### Android
51+
52+
In your `Android.manifest` file (Platforms/Android) add the following permission:
53+
54+
```xml
55+
<uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" />
56+
```
57+
58+
### Using Plugin.Maui.ScreenSecurity
59+
3460
Finally, add the default instance of the plugin as a singleton to inject it in your code late:
3561

3662
```csharp
@@ -46,7 +72,7 @@ It's important to acknowledge that preventing users from taking screenshots or r
4672
## API Usage
4773
> If you are still using version 1.0.0, please refer to the [Legacy docs](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/wiki/Legacy) for the previous version.
4874
49-
The new unified API only have 2 methods: `ActivateScreenSecurityProtection()` and `DeactivateScreenSecurityProtection()`, with optional parameters that will be only applied to the iOS platform.
75+
The new unified API includes two methods: `ActivateScreenSecurityProtection()` and `DeactivateScreenSecurityProtection()`, with optional parameters applicable only to the iOS platform. It also provides two properties: `IsProtectionEnabled`, which checks if protection is active, and the `ScreenCaptured` event handler, which notifies when a screenshot is taken or the screen is recorded.
5076

5177
```csharp
5278
void ActivateScreenSecurityProtection();
@@ -88,6 +114,16 @@ void DeactivateScreenSecurityProtection();
88114
```
89115
This method deactivates all screen security protection.
90116

117+
```csharp
118+
bool IsProtectionEnabled { get; }
119+
```
120+
This bool checks if screen protection is enabled.
121+
122+
```csharp
123+
event EventHandler<EventArgs>? ScreenCaptured;
124+
```
125+
The event handler is triggered when the screen is captured, either through a screenshot or recording on Android and iOS, **but only for screenshots on Windows**.
126+
91127
## Usage Example
92128

93129
```csharp
@@ -106,8 +142,15 @@ public partial class MainPage : ContentPage
106142
{
107143
base.OnAppearing();
108144

109-
// Activate the screen security protection with default settings
110-
_screenSecurity.ActivateScreenSecurityProtection();
145+
// Check if screen security protection is not enabled
146+
if (!_screenSecurity.IsProtectionEnabled)
147+
{
148+
// Activate the screen security protection with default settings
149+
_screenSecurity.ActivateScreenSecurityProtection();
150+
}
151+
152+
// Attach to the ScreenCaptured event handler
153+
_screenSecurity.ScreenCaptured += OnScreenCaptured;
111154

112155
/*
113156
// For changing iOS options, follow one of the next examples:
@@ -129,16 +172,26 @@ public partial class MainPage : ContentPage
129172
};
130173
131174
_screenSecurity.ActivateScreenSecurityProtection(screenProtectionOptions);
132-
133175
*/
134176
}
135177

136178
protected override void OnDisappearing()
137179
{
138180
_screenSecurity.DeactivateScreenSecurityProtection();
139-
181+
182+
// Detach from the ScreenCaptured event handler
183+
_screenSecurity.ScreenCaptured -= OnScreenCaptured;
184+
140185
base.OnDisappearing();
141186
}
187+
188+
private async void OnScreenCaptured(object sender, EventArgs e)
189+
{
190+
string title = "ScreenSecuritySample";
191+
string message = "Screen was captured by screenshot or recording.";
192+
193+
await Shell.Current.DisplayAlert(title, message, "Ok");
194+
}
142195
}
143196
```
144197

@@ -149,8 +202,9 @@ Refer to the [ScreenSecuritySample](https://github.com/FabriBertani/Plugin.Maui.
149202
Please feel free to open an [Issue](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/issues) if you encounter any bugs or submit a PR to contribute improvements or fixes. Your contributions are greatly appreciated.
150203

151204
## License
152-
The Plugin.Maui.ScreenSecurity is licensed under [MIT](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/blob/main/LICENSE).
205+
The Plugin.Maui.ScreenSecurity is licensed under [MIT](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/blob/main/LICENSE) license.
153206

154207
## Contributors
155208

156-
* **[Goran Karacic](https://github.com/Gogzs)** for the iOS 17 fix.
209+
* **[Goran Karacic](https://github.com/Gogzs)** for the iOS 17 fix.
210+
* **[fabien367](https://github.com/fabien367)** for the iOS leak fix.

0 commit comments

Comments
 (0)