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

Commit

Permalink
Fixes #754
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Oct 12, 2019
1 parent 335fefa commit ec4b4b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dotnet_naming_rule.methods_and_properties_must_be_pascal_case.symbols = method_a
dotnet_naming_rule.methods_and_properties_must_be_pascal_case.style = pascal_case_style

# Non-public members must be lower-case
dotnet_naming_symbols.non_public_symbols.applicable_kinds = property,method,field,event,delegate
dotnet_naming_symbols.non_public_symbols.applicable_kinds = field,event,delegate
dotnet_naming_symbols.non_public_symbols.applicable_accessibilities = private
dotnet_naming_style.all_lower_case_style.capitalization = camel_case

Expand Down
42 changes: 19 additions & 23 deletions src/Media.Plugin/iOS/MediaPickerDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Foundation;
using UIKit;
using NSAction = System.Action;
using System.Globalization;
using ImageIO;
using MobileCoreServices;
using System.Drawing;
Expand Down Expand Up @@ -41,10 +40,7 @@ public UIPopoverController Popover
set;
}

public void CancelTask()
{
tcs.SetResult(null);
}
public void CancelTask() => tcs.SetResult(null);

public UIView View => viewController.View;

Expand Down Expand Up @@ -130,7 +126,7 @@ public void DisplayPopover(bool hideFirst = false)
if (IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation))
orientation = UIDevice.CurrentDevice.Orientation;
else
orientation = GetDeviceOrientation(viewController.InterfaceOrientation);
orientation = getDeviceOrientation(viewController.InterfaceOrientation);
}

double x, y;
Expand All @@ -151,14 +147,14 @@ public void DisplayPopover(bool hideFirst = false)
Popover.PresentFromRect(new CGRect(x, y, width, height), View, 0, animated: true);
}

private UIDeviceOrientation? orientation;
private NSObject observer;
private readonly UIViewController viewController;
private readonly UIImagePickerControllerSourceType source;
private TaskCompletionSource<List<MediaFile>> tcs = new TaskCompletionSource<List<MediaFile>>();
private readonly StoreCameraMediaOptions options;
UIDeviceOrientation? orientation;
NSObject observer;
readonly UIViewController viewController;
readonly UIImagePickerControllerSourceType source;
TaskCompletionSource<List<MediaFile>> tcs = new TaskCompletionSource<List<MediaFile>>();
readonly StoreCameraMediaOptions options;

private bool IsCaptured =>
bool IsCaptured =>
source == UIImagePickerControllerSourceType.Camera;

private void Dismiss(UINavigationController picker, NSAction onDismiss)
Expand Down Expand Up @@ -229,37 +225,37 @@ private void DidRotate(NSNotification notice)

private bool GetShouldRotate(UIDeviceOrientation orientation)
{
var iorientation = UIInterfaceOrientation.Portrait;
UIInterfaceOrientation iOrientation;
switch (orientation)
{
case UIDeviceOrientation.LandscapeLeft:
iorientation = UIInterfaceOrientation.LandscapeLeft;
iOrientation = UIInterfaceOrientation.LandscapeLeft;
break;

case UIDeviceOrientation.LandscapeRight:
iorientation = UIInterfaceOrientation.LandscapeRight;
iOrientation = UIInterfaceOrientation.LandscapeRight;
break;

case UIDeviceOrientation.Portrait:
iorientation = UIInterfaceOrientation.Portrait;
iOrientation = UIInterfaceOrientation.Portrait;
break;

case UIDeviceOrientation.PortraitUpsideDown:
iorientation = UIInterfaceOrientation.PortraitUpsideDown;
iOrientation = UIInterfaceOrientation.PortraitUpsideDown;
break;

default: return false;
}

return viewController.ShouldAutorotateToInterfaceOrientation(iorientation);
return viewController.ShouldAutorotateToInterfaceOrientation(iOrientation);
}

private bool GetShouldRotate6(UIDeviceOrientation orientation)
{
if (!viewController.ShouldAutorotate())
return false;

var mask = UIInterfaceOrientationMask.Portrait;
UIInterfaceOrientationMask mask;
switch (orientation)
{
case UIDeviceOrientation.LandscapeLeft:
Expand Down Expand Up @@ -619,12 +615,12 @@ private async Task<MediaFile> GetMovieMediaFile(NSDictionary info)
return new MediaFile(path, () => File.OpenRead(path), albumPath: aPath);
}

private static string GetUniquePath(string type, string path, string name, string pathExtension)
static string GetUniquePath(string type, string path, string name, string pathExtension)
{
var isPhoto = (type == MediaImplementation.TypeImage);
var ext = Path.GetExtension(name);
if (string.IsNullOrWhiteSpace(ext))
ext = pathExtension;
ext = "." + pathExtension;
if(string.IsNullOrWhiteSpace(ext))
ext = ((isPhoto) ? ".jpg" : ".mp4");

Expand Down Expand Up @@ -683,7 +679,7 @@ private static bool IsSameOrientationKind(UIDeviceOrientation o1, UIDeviceOrient
return false;
}

private static UIDeviceOrientation GetDeviceOrientation(UIInterfaceOrientation self)
private static UIDeviceOrientation getDeviceOrientation(UIInterfaceOrientation self)
{
switch (self)
{
Expand Down

0 comments on commit ec4b4b4

Please sign in to comment.