Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #947 from jamesmontemagno/net6
Browse files Browse the repository at this point in the history
Net6
  • Loading branch information
jamesmontemagno authored Sep 20, 2022
2 parents 5ba6134 + 02f7cd9 commit 3e038b3
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 521 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Ported from [Xamarin.Mobile](http://www.github.com/xamarin/xamarin.mobile) to a

Build Status:
* ![](https://jamesmontemagno.visualstudio.com/_apis/public/build/definitions/6b79a378-ddd6-4e31-98ac-a12fcd68644c/24/badge)
* CI NuGet Feed: http://myget.org/F/xamarin-plugins

**Platform Support**

Expand All @@ -28,6 +27,10 @@ Build Status:
|Xamarin.iOS|iOS 7+|
|Xamarin.Android|API 14+|
|Windows 10 UWP|10+|
|.NET for iOS |iOS 10+|
|.NET for Android |API 21+|
|Windows App SDK (WinUI3)|10+|
|.NET for Mac Catalyst|All|
|Tizen|4+|


Expand Down

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/Media.Plugin/Android/CustomPermissions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using static Xamarin.Essentials.Permissions;
using System.Threading.Tasks;
#if NET6_0_OR_GREATER
using Microsoft.Maui.ApplicationModel;
using static Microsoft.Maui.ApplicationModel.Permissions;
#else
using Xamarin.Essentials;
using static Xamarin.Essentials.Permissions;
#endif
using Android;

namespace Plugin.Media
Expand Down
15 changes: 12 additions & 3 deletions src/Media.Plugin/Android/MediaImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
using System.Collections.Generic;
using System.Linq;
using Android.App;
#if NET6_0_OR_GREATER
using Permissions = Microsoft.Maui.ApplicationModel.Permissions;
using PermissionStatus = Microsoft.Maui.ApplicationModel.PermissionStatus;
#else
using Permissions = Xamarin.Essentials.Permissions;
using PermissionStatus = Xamarin.Essentials.PermissionStatus;

#endif
namespace Plugin.Media
{
/// <summary>
Expand Down Expand Up @@ -217,7 +221,7 @@ async Task FixOrientationAndResize(PickMediaOptions options, MediaFile media)
var albumUri = cr.Insert(MediaStore.Images.Media.ExternalContentUri, values);

using (System.IO.Stream input = File.OpenRead(media.Path))
using (System.IO.Stream output = cr.OpenOutputStream(albumUri))
using (var output = cr.OpenOutputStream(albumUri))
input.CopyTo(output);
}
catch (Exception ex)
Expand Down Expand Up @@ -290,7 +294,7 @@ async Task FixOrientationAndResize(PickMediaOptions options, MediaFile media)

if (!(await RequestCameraPermissions()))
{
throw new MediaPermissionException(nameof(Xamarin.Essentials.Permissions.Camera));
throw new MediaPermissionException(nameof(Permissions.Camera));
}

VerifyOptions(options);
Expand Down Expand Up @@ -397,7 +401,12 @@ bool HasPermissionInManifest(string permission)
return requestedPermissions.Any(r => r.Equals(permission, StringComparison.InvariantCultureIgnoreCase));

//try to use current activity else application context
#if NET6_0_OR_GREATER
var permissionContext = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity ?? Application.Context;
#else
var permissionContext = Xamarin.Essentials.Platform.CurrentActivity ?? Application.Context;
#endif


if (context == null)
{
Expand Down
89 changes: 70 additions & 19 deletions src/Media.Plugin/Media.Plugin.csproj
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard2.0;MonoAndroid10.0;Xamarin.iOS10;uap10.0.19041;Tizen40</TargetFrameworks>
<AssemblyName>Plugin.Media</AssemblyName>
<Project Sdk="MSBuild.Sdk.Extras/3.0.44">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;MonoAndroid10.0;Xamarin.iOS10;net6.0-android;net6.0-ios;net6.0-maccatalyst;Tizen40</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);uap10.0.19041;net6.0-windows10.0.19041;</TargetFrameworks>
<AssemblyName>Plugin.Media</AssemblyName>
<RootNamespace>Plugin.Media</RootNamespace>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyFileVersion>1.0.0.0</AssemblyFileVersion>
<Version>1.0.0.0</Version>
<Authors>James Montemagno</Authors>
<PackageId>Xam.Plugin.Media</PackageId>
<LangVersion>8.0</LangVersion>
<PackOnBuild>true</PackOnBuild>
<PackageIconUrl>http://www.refractored.com/images/plugin_icon_media.png</PackageIconUrl>
<PackageLicenseUrl>https://github.com/jamesmontemagno/MediaPlugin/blob/master/LICENSE</PackageLicenseUrl>
<Owners>JamesMontemagno</Owners>
<PackageProjectUrl>https://github.com/jamesmontemagno/MediaPlugin</PackageProjectUrl>
<Summary>Take or pick photos and videos from a cross platform API.</Summary>
<PackageTags>xamarin, pcl, xam.pcl, media, photo, video, plugin, plugin for xamarin, windows phone, winphone, wp8, winrt, android, xamarin.forms, ios</PackageTags>
<Title>Media Plugin for Xamarin and Windows</Title>
<PackageTags>xamarin, pcl, xam.pcl, dotnet maui, .net maui, .net 6, media, photo, video, plugin, plugin for xamarin, windows phone, winphone, wp8, winrt, android, xamarin.forms, ios</PackageTags>
<Title>Media Plugin for .NET 6, .NET MAUI, Xamarin, and Windows</Title>
<Description>
Take or pick photos and videos from a cross platform API.
</Description>
<Copyright>Copyright 2022</Copyright>
<RepositoryUrl>https://github.com/jamesmontemagno/MediaPlugin</RepositoryUrl>
<PackageReleaseNotes>See: https://github.com/jamesmontemagno/MediaPlugin </PackageReleaseNotes>

<NeutralLanguage>en</NeutralLanguage>
<LangVersion>default</LangVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DebugType>portable</DebugType>
<DefineConstants>$(DefineConstants);</DefineConstants>


<!--When built in 2019 will remove extra references on pack-->
<DisableExtraReferences>false</DisableExtraReferences>

<LangVersion>10.0</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" $(TargetFramework.StartsWith('uap10.0')) ">
<DefineConstants>$(DefineConstants);UWP</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" $(TargetFramework.Contains('-windows')) ">
<DefineConstants>$(DefineConstants);UWP</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
<DebugSymbols>true</DebugSymbols>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>


<PropertyGroup Condition=" '$(Configuration)'=='Release' ">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- sourcelink: Declare that the Repository URL can be published to NuSpec -->
Expand All @@ -54,13 +52,30 @@
<!-- sourcelink: Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>


<ItemGroup Condition=" '$(Configuration)'=='Release' ">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<!-- platform version number information -->
<PropertyGroup>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-ios'))">10.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-tvos'))">10.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-maccatalyst'))">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-macos'))">10.14</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-android'))">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows10'))">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows10'))">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>

<PropertyGroup Condition=" $(TargetFramework.StartsWith('uap10.0')) ">
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>


<ItemGroup>
<None Include="..\..\nuget\readme.txt" PackagePath="readme.txt" Pack="true" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.1" />
<Compile Include="**\Shared\*.cs" />
</ItemGroup>

Expand All @@ -71,15 +86,51 @@
<Compile Include="**\UWP\*.cs" />
</ItemGroup>

<PropertyGroup Condition=" $(TargetFramework.Contains('-windows')) ">
</PropertyGroup>


<ItemGroup Condition=" $(TargetFramework.Contains('-windows')) ">
<Compile Include="**\UWP\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.Contains('-android')) ">
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.8.0.1" />
<Compile Include="**\Android\*.cs" />
</ItemGroup>

<PropertyGroup Condition=" $(TargetFramework.Contains('-android')) ">
<UseMauiEssentials>true</UseMauiEssentials>
</PropertyGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.6.0.1" />
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.7.0.2" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.3" />
<Compile Include="**\Android\*.cs" />
</ItemGroup>


<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
<PackageReference Include="Xamarin.Essentials" Version="1.7.3" />
<Compile Include="**\iOS\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.Contains('-ios')) ">
<Compile Include="**\iOS\*.cs" />
</ItemGroup>

<PropertyGroup Condition=" $(TargetFramework.Contains('-ios')) ">
<UseMauiEssentials>true</UseMauiEssentials>
</PropertyGroup>

<PropertyGroup Condition=" $(TargetFramework.Contains('-mac')) ">
<UseMauiEssentials>true</UseMauiEssentials>
</PropertyGroup>

<ItemGroup Condition=" $(TargetFramework.Contains('-mac')) ">
<Compile Include="**\iOS\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Tizen')) ">
<Compile Include="**\Tizen\*.cs" />
<PackageReference Include="Tizen.NET" Version="4.0.0">
Expand Down
4 changes: 2 additions & 2 deletions src/Media.Plugin/Shared/CrossMedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public static IMedia Current

static IMedia CreateMedia()
{
#if NETSTANDARD1_0 || NETSTANDARD2_0
#if NETSTANDARD
return null;
#elif UWP
#elif UWP || WINDOWS
return Flags.Contains(FeatureFlags.UwpUseNewMediaImplementation)
? (IMedia)new NewMediaImplementation()
: new MediaImplementation();
Expand Down
2 changes: 1 addition & 1 deletion src/Media.Plugin/Shared/FeatureFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
static class FeatureFlags
{
#if UWP
#if UWP || WINDOWS
internal const string UwpUseNewMediaImplementation = "UwpUseNewMediaImplementation";
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/Media.Plugin/Shared/MediaFileNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Plugin.Media.Abstractions
/// <summary>
///
/// </summary>
#if !NETSTANDARD1_0
#if !NETSTANDARD
[Serializable]
#endif
public class MediaFileNotFoundException : Exception
Expand Down
1 change: 0 additions & 1 deletion src/Media.Plugin/Shared/MediaPermissionException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using static Xamarin.Essentials.Permissions;

namespace Plugin.Media.Abstractions
{
Expand Down
20 changes: 20 additions & 0 deletions src/Media.Plugin/iOS/CheckMarkView.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using CoreGraphics;
using UIKit;
#if NET6_0_OR_GREATER
using System.Runtime.InteropServices;
#endif


namespace Plugin.Media
{
Expand Down Expand Up @@ -60,7 +64,11 @@ void DrawRectChecked(CGRect rect)
// Shadow Declarations
var shadow2 = UIColor.Brown;
var shadow2Offset = new CGSize(0.1, -0.1);
#if NET6_0_OR_GREATER
NFloat shadow2BlurRadius = 2.5f;
#else
nfloat shadow2BlurRadius = 2.5f;
#endif

var frame = Bounds;

Expand Down Expand Up @@ -102,7 +110,11 @@ void DrawRectGrayedOut(CGRect rect)
// Shadow Declarations
var shadow2 = UIColor.Black;
var shadow2Offset = new CGSize(0.1, -0.1);
#if NET6_0_OR_GREATER
NFloat shadow2BlurRadius = 2.5f;
#else
nfloat shadow2BlurRadius = 2.5f;
#endif

var frame = Bounds;

Expand Down Expand Up @@ -139,10 +151,18 @@ void DrawRectOpenCircle(CGRect rect)
// Shadow Declarations
var shadow = UIColor.Black;
var shadowOffset = new CGSize(0.1, -0.1);
#if NET6_0_OR_GREATER
NFloat shadowBlurRadius = 0.5f;
#else
nfloat shadowBlurRadius = 0.5f;
#endif
var shadow2 = UIColor.Black;
var shadow2Offset = new CGSize(0.1, -0.1);
#if NET6_0_OR_GREATER
NFloat shadow2BlurRadius = 2.5f;
#else
nfloat shadow2BlurRadius = 2.5f;
#endif

var frame = Bounds;

Expand Down
Loading

0 comments on commit 3e038b3

Please sign in to comment.