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

Commit

Permalink
Update libraries and add more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Nov 12, 2019
1 parent 27619a8 commit 08ba38f
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 322 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected override void OnCreate(Bundle bundle)
ToolbarResource = Resource.Layout.Toolbar;

base.OnCreate(bundle);
FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true);
CrossCurrentActivity.Current.Init(this, bundle);
Xamarin.Forms.Forms.Init(this, bundle);
Android.Glide.Forms.Init(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
<PackageReference Include="Plugin.Permissions">
<Version>5.0.0-beta</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.2.0.848062" />
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.947036" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
rootFrame = new Frame();

rootFrame.NavigationFailed += OnNavigationFailed;

FFImageLoading.Forms.Platform.CachedImageRenderer.Init();
Xamarin.Forms.Forms.Init(e);

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@
<PackageReference Include="Plugin.Permissions">
<Version>5.0.0-beta</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.2.0.848062" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.7" />
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.947036" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Media.Plugin\Media.Plugin.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public partial class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDe
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Xamarin.Forms.Forms.Init();
FFImageLoading.Forms.Platform.CachedImageRenderer.Init();
Xamarin.Forms.Forms.Init();
LoadApplication(new App());

return base.FinishedLaunching(app, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@
<PackageReference Include="Plugin.Permissions">
<Version>5.0.0-beta</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.2.0.848062" />
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.947036" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<ItemGroup>
<PackageReference Include="Plugin.Permissions" Version="5.0.0-beta" />
<PackageReference Include="Xamarin.Forms" Version="4.2.0.848062" />
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.11.982" />
<PackageReference Include="Xamarin.Forms" Version="4.3.0.947036" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 11 additions & 4 deletions src/Media.Plugin.Sample/Media.Plugin.Sample/MediaPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Plugin.Media;
using FFImageLoading.Forms;
using Plugin.Media;
using Plugin.Media.Abstractions;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -59,7 +60,8 @@ public MediaPage()
}
var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
{
PhotoSize = PhotoSize.Medium
PhotoSize = PhotoSize.Full,
SaveMetaData = true
});


Expand Down Expand Up @@ -143,12 +145,17 @@ private void Files_CollectionChanged(object sender, System.Collections.Specializ

var file = e.NewItems[0] as MediaFile;
var image = new Image { WidthRequest = 300, HeightRequest = 300, Aspect = Aspect.AspectFit };
image.Source = ImageSource.FromStream(() =>
image.Source = ImageSource.FromFile(file.Path);
/*image.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
});*/
ImageList.Children.Add(image);

var image2 = new CachedImage { WidthRequest = 300, HeightRequest = 300, Aspect = Aspect.AspectFit };
image2.Source = ImageSource.FromFile(file.Path);
ImageList.Children.Add(image2);
}

private async void Button_Clicked(object sender, EventArgs e)
Expand Down
5 changes: 5 additions & 0 deletions src/Media.Plugin/Media.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<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>
Expand All @@ -29,6 +30,10 @@
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DebugType>portable</DebugType>
<DefineConstants>$(DefineConstants);</DefineConstants>


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

</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
Expand Down
153 changes: 0 additions & 153 deletions src/Media.Plugin/iOS/CheckMarkView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,157 +170,4 @@ public enum CheckMarkStyle
GrayedOut
}

//enum SSCheckMarkStyle
//{
// OpenCircle,
// GrayedOut
//}

//class SSCheckMark : UIView
//{

// private bool checkedBool = false;
// // choose whether you like open or grayed out non-selected items
// private SSCheckMarkStyle checkMarkStyleReal = SSCheckMarkStyle.GrayedOut;

// public bool Checked
// {
// get => checkedBool;
// set
// {
// checkedBool = value;
// SetNeedsDisplay();
// }
// }

// public SSCheckMarkStyle CheckMarkStyle
// {
// get => checkMarkStyleReal;
// set
// {
// checkMarkStyleReal = value;
// SetNeedsDisplay();
// }
// }

// public override void Draw(CGRect rect)
// {
// base.Draw(rect);

// if (Checked)
// {
// this.DrawRectChecked(rect);
// }
// else
// {
// if (CheckMarkStyle == SSCheckMarkStyle.OpenCircle)
// {
// DrawRectOpenCircle(rect);
// }
// else if (CheckMarkStyle == SSCheckMarkStyle.GrayedOut)
// {
// DrawRectGrayedOut(rect);
// }
// }
// }

// private void DrawRectChecked(CGRect rect)
// {
// var context = UIGraphics.GetCurrentContext();
// var checkmarkBlue2 = UIColor.FromRGB((nfloat)0.078, (nfloat)0.435, (nfloat)0.875);
// var shadow2 = UIColor.Black;
// var shadow2Offset = new CGSize(width: 0.1, height: -0.1);
// var shadow2BlurRadius = 2.5;
// var frame = this.Bounds;
// var group = new CGRect(frame.Left + 3, frame.Bottom + 3, width: frame.Width - 6, height: frame.Height - 6);

// var checkedOvalPath = UIBezierPath.FromOval(new CGRect(group.Left + Math.Floor(group.Width * 0.00000 + 0.5), group.Bottom + Math.Floor(group.Height * 0.00000 + 0.5), Math.Floor(group.Width * 1.00000 + 0.5) - Math.Floor(group.Width * 0.00000 + 0.5), height: Math.Floor(group.Height * 1.00000 + 0.5) - Math.Floor(group.Height * 0.00000 + 0.5)));

// context.SaveState();

// context.SetShadow(shadow2Offset, (nfloat)shadow2BlurRadius, shadow2.CGColor);
// checkmarkBlue2.SetFill();
// checkedOvalPath.Fill();
// context.RestoreState();

// UIColor.White.SetStroke();
// checkedOvalPath.LineWidth = 1;
// checkedOvalPath.Stroke();

// var bezierPath = new UIBezierPath();
// bezierPath.MoveTo(new CGPoint(group.Left + 0.27083 * group.Width, group.Top + 0.54167 * group.Height));
// bezierPath.AddLineTo(new CGPoint(group.Left + 0.41667 * group.Width, group.Bottom + 0.68750 * group.Height));
// bezierPath.AddLineTo(new CGPoint(group.Left + 0.75000 * group.Width, group.Bottom + 0.35417 * group.Height));
// bezierPath.LineCapStyle = CGLineCap.Square;
// UIColor.White.SetStroke();
// bezierPath.LineWidth = (nfloat)1.3;
// bezierPath.Stroke();
// }

// void DrawRectGrayedOut(CGRect rect)
// {
// var context = UIGraphics.GetCurrentContext();
// var grayTranslucent = UIColor.FromRGBA(0xFF, 0xFF, 0xFF, 0x99);
// var shadow2 = UIColor.Black;
// var shadow2Offset = new CGSize(0.1, -0.1);
// var shadow2BlurRadius = 2.5;
// var frame = Bounds;
// var group = new CGRect(frame.Left + 3, y: frame.Bottom + 3, width: frame.Width - 6, height: frame.Height - 6);

// var uncheckedOvalPath = UIBezierPath.FromOval(new CGRect(group.Bottom + Math.Floor(group.Width * 0.00000 + 0.5), group.Bottom + Math.Floor(group.Height * 0.00000 + 0.5), Math.Floor(group.Width * 1.00000 + 0.5) - Math.Floor(group.Width * 0.00000 + 0.5), Math.Floor(group.Height * 1.00000 + 0.5) - Math.Floor(group.Height * 0.00000 + 0.5)));

// context.SaveState();
// context.SetShadow(shadow2Offset, (nfloat)shadow2BlurRadius, shadow2.CGColor);
// grayTranslucent.SetFill();
// uncheckedOvalPath.Fill();
// context.RestoreState();

// UIColor.White.SetStroke();
// uncheckedOvalPath.LineWidth = 1;
// uncheckedOvalPath.Stroke();

// var bezierPath = new UIBezierPath();
// bezierPath.MoveTo(new CGPoint(group.Left + 0.27083 * group.Width, group.Bottom + 0.54167 * group.Height));
// bezierPath.AddLineTo(new CGPoint(group.Left + 0.41667 * group.Width, group.Bottom + 0.68750 * group.Height));
// bezierPath.AddLineTo(new CGPoint(group.Left + 0.75000 * group.Width, group.Bottom + 0.35417 * group.Height));
// bezierPath.LineCapStyle = CGLineCap.Square;
// UIColor.White.SetStroke();
// bezierPath.LineWidth = (nfloat)1.3;
// bezierPath.Stroke();
// }

// void DrawRectOpenCircle(CGRect rect)
// {
// var context = UIGraphics.GetCurrentContext();

// var shadow = UIColor.Black;

// var shadowOffset = new CGSize(width: 0.1, height: -0.1);

// var shadowBlurRadius = 0.5;

// var shadow2 = UIColor.Black;

// var shadow2Offset = new CGSize(width: 0.1, height: -0.1);

// var shadow2BlurRadius = 2.5;

// var frame = Bounds;

// var group = new CGRect(x: frame.Left + 3, y: frame.Bottom + 3, width: frame.Width - 6, height: frame.Height - 6);

// var emptyOvalPath = UIBezierPath.FromOval(new CGRect((nfloat)(group.Left + Math.Floor(group.Width * 0.00000 + 0.5)), (nfloat)(group.Bottom + Math.Floor(group.Height * 0.00000 + 0.5)), (nfloat)(Math.Floor(group.Width * 1.00000 + 0.5) - Math.Floor(group.Width * 0.00000 + 0.5)), (nfloat)(Math.Floor(group.Height * 1.00000 + 0.5) - Math.Floor(group.Height * 0.00000 + 0.5))));

// context.SaveState();
// context.SetShadow(shadow2Offset, (nfloat)shadow2BlurRadius, shadow2.CGColor);
// context.RestoreState();

// context.SaveState();
// context.SetShadow(shadowOffset, (nfloat)shadowBlurRadius, shadow.CGColor);
// UIColor.White.SetStroke();
// emptyOvalPath.LineWidth = 1;
// emptyOvalPath.Stroke();
// context.RestoreState();
// }
//}
}
19 changes: 15 additions & 4 deletions src/Media.Plugin/iOS/ECLImagePickerViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,22 @@ private MediaFile GetPictureMediaFile(ALAsset asset, long index = 0)
stop = false;
};

manager.RequestImageData(ph, phOptions, (data, i, orientation, k) =>
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
if (data != null)
image = new UIImage(data, 1.0f);
});
manager.RequestImageDataAndOrientation(ph, phOptions, (data, i, orientation, k) =>
{
if (data != null)
image = new UIImage(data, 1.0f);
});
}
else
{
manager.RequestImageData(ph, phOptions, (data, i, orientation, k) =>
{
if (data != null)
image = new UIImage(data, 1.0f);
});
}
phOptions?.Dispose();
fetch?.Dispose();
ph?.Dispose();
Expand Down
5 changes: 4 additions & 1 deletion src/Media.Plugin/iOS/MediaPickerDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,10 @@ internal static bool SaveImageWithMetadata(UIImage image, float quality, NSDicti
var success = destination.Close();
if (success)
{
imageWithExif.Save(path, true);
var saved = imageWithExif.Save(path, true, out NSError error);
if (error != null)
Debug.WriteLine($"Unable to save exif data: {error.ToString()}");

imageWithExif.Dispose();
imageWithExif = null;
}
Expand Down
Loading

0 comments on commit 08ba38f

Please sign in to comment.