Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ImageCropper.Forms.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2024
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Android", "Test\Test.Android\Test.Android.csproj", "{21888A92-3966-474B-BFD8-04E6DC7A260F}"
EndProject
Expand Down Expand Up @@ -67,6 +67,7 @@ Global
{21888A92-3966-474B-BFD8-04E6DC7A260F}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{21888A92-3966-474B-BFD8-04E6DC7A260F}.AppStore|iPhoneSimulator.Deploy.0 = Release|Any CPU
{21888A92-3966-474B-BFD8-04E6DC7A260F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21888A92-3966-474B-BFD8-04E6DC7A260F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21888A92-3966-474B-BFD8-04E6DC7A260F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{21888A92-3966-474B-BFD8-04E6DC7A260F}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{21888A92-3966-474B-BFD8-04E6DC7A260F}.Debug|iPhone.Build.0 = Debug|Any CPU
Expand Down Expand Up @@ -94,6 +95,7 @@ Global
{5AE225C1-20C1-444A-ABD7-547965282F49}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator
{5AE225C1-20C1-444A-ABD7-547965282F49}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator
{5AE225C1-20C1-444A-ABD7-547965282F49}.Debug|Any CPU.ActiveCfg = Debug|iPhone
{5AE225C1-20C1-444A-ABD7-547965282F49}.Debug|Any CPU.Build.0 = Debug|iPhone
{5AE225C1-20C1-444A-ABD7-547965282F49}.Debug|iPhone.ActiveCfg = Debug|iPhone
{5AE225C1-20C1-444A-ABD7-547965282F49}.Debug|iPhone.Build.0 = Debug|iPhone
{5AE225C1-20C1-444A-ABD7-547965282F49}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
Expand All @@ -116,6 +118,7 @@ Global
{7B7692F4-D2C1-4FE8-B4EB-33C2E25E7C44}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7B7692F4-D2C1-4FE8-B4EB-33C2E25E7C44}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{7B7692F4-D2C1-4FE8-B4EB-33C2E25E7C44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B7692F4-D2C1-4FE8-B4EB-33C2E25E7C44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B7692F4-D2C1-4FE8-B4EB-33C2E25E7C44}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7B7692F4-D2C1-4FE8-B4EB-33C2E25E7C44}.Debug|iPhone.Build.0 = Debug|Any CPU
{7B7692F4-D2C1-4FE8-B4EB-33C2E25E7C44}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
Expand Down
17 changes: 10 additions & 7 deletions ImageCropper.nuspec
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>ImageCropper.Forms.Fix.v2</id>
<version>1.0.5</version>
<id>ImageCropper.Forms.Fix.MultiPicker</id>
<version>1.0.7</version>
<authors>Marko Rothstein</authors>
<owners>Marko Rothstein</owners>
<projectUrl>https://github.com/INHack20/ImageCropper.Forms</projectUrl>
<licenseUrl>https://github.com/INHack20/ImageCropper.Forms/blob/master/LICENSE.md</licenseUrl>
<license>https://github.com/INHack20/ImageCropper.Forms/blob/master/LICENSE.md</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Xamarin.Forms plugin to crop and rotate photos.</description>
<summary>Xamarin.Forms plugin to crop and rotate photos. Supports Android and iOS.</summary>
<summary>Xamarin.Forms plugin to crop and rotate photos taken by the Camera or Picked multiple images from Gallery. Supports Android and iOS.</summary>
<releaseNotes>First release.</releaseNotes>
<copyright>© StormLion 2018</copyright>
<tags>xamarin forms crop rotate photo image</tags>
<tags>xamarin forms crop rotate photo image multipicker</tags>
<dependencies>
<group>
<dependency id="Xamarin.Forms" version="4.*"/>
<dependency id="Xam.Plugin.Media" version="5.*" />
<dependency id="ExifLib.PCL" version="1.0.1" />
<dependency id="MetadataExtractor" version="2.4.2" />
</group>
<group targetFramework="monoandroid">
<dependency id="Xamarin.AndroidX.ExifInterface" version="1.1" />
<dependency id="Xamarin.AndroidX.Migration" version="1.*" />
<dependency id="ExifLib.PCL" version="1.0.1" />
</group>
</dependencies>
</metadata>
<files>

<file src="ImageCropper/ImageCropper/bin/Release/netstandard2.0/Stormlion.ImageCropper.dll" target="lib/netstandard2.0" />

<file src="ImageCropper/ImageCropper.Android/bin/Release/Stormlion.ImageCropper.dll" target="lib/MonoAndroid" />
<file src="ImageCropper/ImageCropper.Android/bin/Release/Binding_AndroidImageCropper.dll" target="lib/MonoAndroid" />
<file src="ImageCropper/ImageCropper.Android/bin/Release/Stormlion.ImageCropper.Android.dll" target="lib/MonoAndroid" />


<file src="ImageCropper/ImageCropper.iOS/bin/Release/Stormlion.ImageCropper.dll" target="lib/Xamarin.iOS10" />
<file src="ImageCropper/ImageCropper.iOS/bin/Release/TOCropViewController.dll" target="lib/Xamarin.iOS10" />
Expand Down
8 changes: 6 additions & 2 deletions ImageCropper/ImageCropper.Android/ImageCropper.Android.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -62,6 +62,9 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ExifLib.PCL">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Plugin.Permissions">
<Version>6.0.1</Version>
</PackageReference>
Expand All @@ -77,6 +80,7 @@
<PackageReference Include="Xamarin.Forms">
<Version>4.5.0.725</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.6" /></ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.6" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
59 changes: 31 additions & 28 deletions ImageCropper/ImageCropper.Android/ImageCropperImplementation.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
using Com.Theartofdev.Edmodo.Cropper;
using Stormlion.ImageCropper.Droid;
using System.Diagnostics;
using Xamarin.Forms;
using System;
using Xamarin.Essentials;
using System.Collections.Generic;

namespace Stormlion.ImageCropper.Droid
{
public class ImageCropperImplementation : IImageCropperWrapper
{
public void ShowFromFile(ImageCropper imageCropper, string imageFile)
public void ShowFromFile(ImageCropper imageCropper, List<ImageProperties> imagesCroppingList)
{
try
{
CropImage.ActivityBuilder activityBuilder = CropImage.Activity(Android.Net.Uri.FromFile(new Java.IO.File(imageFile)));
CropImage.ActivityBuilder activityBuilder;

if(imageCropper.CropShape == ImageCropper.CropShapeType.Oval)
foreach (var imageFile in imagesCroppingList)
{
activityBuilder.SetCropShape(CropImageView.CropShape.Oval);
}
else
{
activityBuilder.SetCropShape(CropImageView.CropShape.Rectangle);
}
activityBuilder = CropImage.Activity(Android.Net.Uri.FromFile(new Java.IO.File(imageFile.ImagePath)));

if(imageCropper.AspectRatioX > 0 && imageCropper.AspectRatioY > 0)
{
activityBuilder.SetFixAspectRatio(true);
activityBuilder.SetAspectRatio(imageCropper.AspectRatioX, imageCropper.AspectRatioY);
}
else
{
activityBuilder.SetFixAspectRatio(false);
}
if (imageCropper.CropShape == ImageCropper.CropShapeType.Oval)
{
activityBuilder.SetCropShape(CropImageView.CropShape.Oval);
}
else
{
activityBuilder.SetCropShape(CropImageView.CropShape.Rectangle);
}

if(!string.IsNullOrWhiteSpace(imageCropper.PageTitle))
{
activityBuilder.SetActivityTitle(imageCropper.PageTitle);
}
if (imageCropper.AspectRatioX > 0 && imageCropper.AspectRatioY > 0)
{
activityBuilder.SetFixAspectRatio(true);
activityBuilder.SetAspectRatio(imageCropper.AspectRatioX, imageCropper.AspectRatioY);
}
else
{
activityBuilder.SetFixAspectRatio(false);
}

activityBuilder.Start(Xamarin.Essentials.Platform.CurrentActivity);
if (!string.IsNullOrWhiteSpace(imageCropper.PageTitle))
{
activityBuilder.SetActivityTitle(imageCropper.PageTitle);
}

activityBuilder.Start(Xamarin.Essentials.Platform.CurrentActivity);
}
}
catch(Exception ex)
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}

}
}
}
55 changes: 45 additions & 10 deletions ImageCropper/ImageCropper.Android/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,54 @@ public static void Init()

public static async void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (requestCode == CropImage.CropImageActivityRequestCode)
if (data == null)
{
CropImage.ActivityResult result = CropImage.GetActivityResult(data);
ImageCropper.Current.indexCounter++;
return;
}

// small delay
await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
if (resultCode == Result.Ok)
{
ImageCropper.Current.Success?.Invoke(result.Uri.Path);
}
else if ((int)resultCode == (int)(CropImage.CropImageActivityResultErrorCode))
else
{
if (requestCode == CropImage.CropImageActivityRequestCode)
{
ImageCropper.Current.Faiure?.Invoke();
string originalFileCreationDate = string.Empty;

originalFileCreationDate = ImageCropper.Current.
BeforeCroppingList[ImageCropper.Current.
indexCounter].OriginalPictureDate;

CropImage.ActivityResult result = CropImage.GetActivityResult(data);

if (result != null)
{
ImageCropper.Current.CroppingResultList.Add(new ImageProperties()
{
ImagePath = result.Uri.Path,
OriginalPictureDate = originalFileCreationDate
});

ImageCropper.Current.indexCounter++;

// small delay
await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));

if (resultCode == Result.Ok)
{
if (ImageCropper.Current.indexCounter == ImageCropper.Current.BeforeCroppingList.Count)
{
ImageCropper.Current.Success?.Invoke(ImageCropper.Current.CroppingResultList);
}
}
else if ((int)resultCode == (int)(CropImage.CropImageActivityResultErrorCode))
{
ImageCropper.Current.Faiure?.Invoke();
}
}
else
{
ImageCropper.Current.Faiure?.Invoke();
return;
}
}
}
}
Expand Down
13 changes: 1 addition & 12 deletions ImageCropper/ImageCropper.iOS/ImageCropper.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
<Reference Include="Xamarin.iOS" />
<Reference Include="OpenTK-1.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<Compile Include="ImageCropperImplementation.cs" />
<Compile Include="Platform.cs" />
Expand All @@ -57,14 +54,6 @@
<Name>ImageCropper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Resources\Media.xcassets\sample1.imageset\Contents.json">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Resources\Media.xcassets\sample1.imageset\Photo.png">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Plugin.Permissions">
<Version>6.0.1</Version>
Expand All @@ -77,4 +66,4 @@
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
</Project>
Loading