Skip to content

Commit

Permalink
Merge pull request #44 from FabriBertani/ver/1.2.0
Browse files Browse the repository at this point in the history
New release 1.2.0
  • Loading branch information
FabriBertani authored Oct 14, 2024
2 parents 3d742d7 + b923aa7 commit 01d881c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 18 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.2.0 (10/14/2024)
[Full Changelog](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/compare/v1.1.6...v1.2.0)

**Implemented enhancements:**
- Added `Blazor` sample to showcase the implementation of this plugin.
- Added `IsProtectionEnabled` property to check if screen protection is already enabled or disabled.
- Added `ScreenCaptured` event handler, which triggers notifications when a screenshot is taken or the screen is recorded.
- Added plugin initialization.
- Updated sample projects with new implementations.

**Fixed bugs:**
- Implemented a new screenshot prevention method for iOS 17+.
- Fixed `GetWindow` method on iOS.
- Merged [#39: Bug iOS on Blur](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/pull/39) PR by [fabien367](https://github.com/fabien367).

## 1.1.8-beta (05/25/2024)
[Full Changelog](https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/compare/v1.1.7-beta...v1.1.8-beta)

Expand Down
6 changes: 3 additions & 3 deletions Plugin.Maui.ScreenSecurity/Plugin.Maui.ScreenSecurity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<RepositoryUrl>https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>dotnet-maui;maui;toolkit;security;Plugin.Maui.ScreenSecurity;ScreenSecurity;screen;protection;leak;android;ios</PackageTags>
<AssemblyVersion>1.1.8</AssemblyVersion>
<FileVersion>1.1.8-beta</FileVersion>
<AssemblyVersion>1.2.0</AssemblyVersion>
<FileVersion>1.2.0</FileVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>plugin.maui.screensecurity_128x128.jpg</PackageIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>1.1.8-beta</Version>
<Version>1.2.0</Version>
<PackageReleaseNotes>https://github.com/FabriBertani/Plugin.Maui.ScreenSecurity/blob/main/CHANGELOG.md</PackageReleaseNotes>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down
84 changes: 69 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Plugin.Maui.ScreenSecurity
[![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)
[![NuGet](https://img.shields.io/nuget/v/Plugin.Maui.ScreenSecurity.svg?label=NuGet)](https://www.nuget.org/packages/Plugin.Maui.ScreenSecurity)

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

Expand All @@ -10,27 +10,53 @@
|.Net MAUI iOS|iOS 14+|
|Windows|10.0.17763+|

## Version 1.1.6
## Version 1.2.0

### What's new?
- Removed .Net6 support. :warning:
- Added .Net8 support to all platforms.
- Fixed iOS 17 issues.
- 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:
- Added `IsProtectionEnabled` property to check if screen protection is already enabled or disabled.
- Added `ScreenCaptured` event handler, which triggers notifications when a screenshot is taken or the screen is recorded.
- Fixed iOS issues.
- Added `Blazor` sample to showcase the implementation of this plugin.

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

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

Install-Package Plugin.Maui.ScreenSecurity

In your `MauiProgram` class add the following `using` statement:
Initialize the plugin in your `MauiProgram` class:

```csharp
using Plugin.Maui.ScreenSecurity;

public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();

builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseScreenSecurity();

return builder.Build();
}
```

### Android

In your `Android.manifest` file (Platforms/Android) add the following permission:

```xml
<uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" />
```

### Using Plugin.Maui.ScreenSecurity

Finally, add the default instance of the plugin as a singleton to inject it in your code late:

```csharp
Expand All @@ -46,7 +72,7 @@ It's important to acknowledge that preventing users from taking screenshots or r
## API Usage
> 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.
The new unified API only have 2 methods: `ActivateScreenSecurityProtection()` and `DeactivateScreenSecurityProtection()`, with optional parameters that will be only applied to the iOS platform.
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.

```csharp
void ActivateScreenSecurityProtection();
Expand Down Expand Up @@ -88,6 +114,16 @@ void DeactivateScreenSecurityProtection();
```
This method deactivates all screen security protection.

```csharp
bool IsProtectionEnabled { get; }
```
This bool checks if screen protection is enabled.

```csharp
event EventHandler<EventArgs>? ScreenCaptured;
```
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**.

## Usage Example

```csharp
Expand All @@ -106,8 +142,15 @@ public partial class MainPage : ContentPage
{
base.OnAppearing();

// Activate the screen security protection with default settings
_screenSecurity.ActivateScreenSecurityProtection();
// Check if screen security protection is not enabled
if (!_screenSecurity.IsProtectionEnabled)
{
// Activate the screen security protection with default settings
_screenSecurity.ActivateScreenSecurityProtection();
}

// Attach to the ScreenCaptured event handler
_screenSecurity.ScreenCaptured += OnScreenCaptured;

/*
// For changing iOS options, follow one of the next examples:
Expand All @@ -129,16 +172,26 @@ public partial class MainPage : ContentPage
};
_screenSecurity.ActivateScreenSecurityProtection(screenProtectionOptions);
*/
}

protected override void OnDisappearing()
{
_screenSecurity.DeactivateScreenSecurityProtection();


// Detach from the ScreenCaptured event handler
_screenSecurity.ScreenCaptured -= OnScreenCaptured;

base.OnDisappearing();
}

private async void OnScreenCaptured(object sender, EventArgs e)
{
string title = "ScreenSecuritySample";
string message = "Screen was captured by screenshot or recording.";

await Shell.Current.DisplayAlert(title, message, "Ok");
}
}
```

Expand All @@ -149,8 +202,9 @@ Refer to the [ScreenSecuritySample](https://github.com/FabriBertani/Plugin.Maui.
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.

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

## Contributors

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

0 comments on commit 01d881c

Please sign in to comment.