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

Commit

Permalink
Merge branch 'main' into jamesmontemagno-patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis authored Jan 18, 2022
2 parents 98a69b1 + 66d4a60 commit 801f849
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 120 deletions.
20 changes: 1 addition & 19 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,4 @@ labels: feature-request
assignees: ''

---

## Summary
Please provide a brief summary of your proposal. Two to three sentences is best here.

## API Changes

Include a list of all API changes, additions, subtractions as would be required by your proposal. These APIs should be considered placeholders, so the naming is not as important as getting the concepts correct. If possible you should include some "example" code of usage of your new API. You should also provide details of the level of availability for the feature on each of the supported platforms.

e.g.

In order to facilitate the new Shiny Button api, a bool is added to the Button class. This is done as a bool because it is simpler to data bind and other reasons...

var button = new Button ();
button.MakeShiny = true; // new API

The MakeShiny API works even if the button is already visible.

## Intended Use Case
Provide a detailed example of where your proposal would be used and for what purpose.
We are no longer accepting new feature request for Xamarin.Essentials. Please make your new feature requests in the .NET MAUI repo which contains .NET MAUI Essentials.
6 changes: 2 additions & 4 deletions DeviceTests/DeviceTests.Android/DeviceTests.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<RootNamespace>DeviceTests.Droid</RootNamespace>
<AssemblyName>XamarinEssentialsDeviceTestsAndroid</AssemblyName>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<AndroidApplication>True</AndroidApplication>
<AndroidUseIntermediateDesignerFile>true</AndroidUseIntermediateDesignerFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
Expand All @@ -19,6 +18,7 @@
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidUseAapt2>true</AndroidUseAapt2>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -29,7 +29,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
Expand All @@ -47,7 +46,6 @@
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
</PropertyGroup>
Expand All @@ -63,7 +61,7 @@
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.25" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.20602.1" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.21620.1" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0.1" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.6" />
</ItemGroup>
Expand Down
31 changes: 31 additions & 0 deletions DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,36 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<queries>
<!-- Email -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
<!-- Browser -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
<!-- Browser -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- Sms -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="smsto" />
</intent>
<!-- PhoneDialer -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- MediaPicker -->
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/MainTheme"></application>
</manifest>
2 changes: 1 addition & 1 deletion DeviceTests/DeviceTests.iOS/DeviceTests.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.25" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.20602.1" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.21620.1" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions DeviceTests/DeviceTests.iOS/Main.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using UIKit;
using System;
using UIKit;

namespace DeviceTests.iOS
{
public class Application
{
static void Main(string[] args)
{
if (args?.Length > 0) // usually means this is from xharness
UIApplication.Main(args, null, nameof(TestApplicationDelegate));
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("ci-run")))
UIApplication.Main(args, null, typeof(TestApplicationDelegate));
else
UIApplication.Main(args, null, nameof(AppDelegate));
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}
5 changes: 3 additions & 2 deletions DeviceTests/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ Task("test-ios-emu")
CleanDirectories(IOS_TEST_RESULTS_PATH.FullPath);
// Run the tests
var resultCode = StartProcess("xharness", "ios test " +
var resultCode = StartProcess("xharness", "apple test " +
$"--app=\"{IOS_IPA_PATH}\" " +
$"--targets=\"ios-simulator-64\" " +
$"--output-directory=\"{IOS_TEST_RESULTS_PATH}\" " +
$"--verbosity=\"Debug\" ");
$"--verbosity=\"Debug\" " +
$"--set-env=ci-run=true ");
// Rename test result files
var resultFiles = GetFiles($"{IOS_TEST_RESULTS_PATH}/*.xml");
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ Here are some frequently asked questions about Xamarin.Essentials, but be sure t

Please see the [License](LICENSE).

## Stats
<img src="https://repobeats.axiom.co/api/embed/f917a77cbbdeee19b87fa1f2f932895d1df18b31.svg" />
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.Apple" Version="5.0.14" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="5.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="5.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="5.0.10" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="AspNet.Security.OAuth.Apple" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/Samples.iOS/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Application
{
static void Main(string[] args)
{
UIApplication.Main(args, null, nameof(AppDelegate));
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}
8 changes: 8 additions & 0 deletions Xamarin.Essentials/Contacts/Contacts.ios.macos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ static Task<Contact> PlatformPickContactAsync()
})
};

if (picker.PresentationController != null)
{
picker.PresentationController.Delegate = new Platform.UIPresentationControllerDelegate
{
DismissHandler = () => source?.TrySetResult(null)
};
}

uiView.PresentViewController(picker, true, null);

return source.Task;
Expand Down
13 changes: 11 additions & 2 deletions Xamarin.Essentials/Email/Email.ios.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Threading.Tasks;
using Foundation;
using MessageUI;
Expand Down Expand Up @@ -50,13 +51,21 @@ static Task ComposeWithMailCompose(EmailMessage message)
}
}

// show the controller
var tcs = new TaskCompletionSource<bool>();
controller.Finished += (sender, e) =>
{
controller.DismissViewController(true, null);
tcs.TrySetResult(e.Result == MFMailComposeResult.Sent);
};

if (controller.PresentationController != null)
{
controller.PresentationController.Delegate = new Platform.UIPresentationControllerDelegate
{
DismissHandler = () => tcs.TrySetResult(false)
};
}

parentController.PresentViewController(controller, true, null);

return tcs.Task;
Expand Down
12 changes: 2 additions & 10 deletions Xamarin.Essentials/FilePicker/FilePicker.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ static async Task<IEnumerable<FileResult>> PlatformPickAsync(PickOptions options

if (documentPicker.PresentationController != null)
{
documentPicker.PresentationController.Delegate = new PickerPresentationControllerDelegate
documentPicker.PresentationController.Delegate = new Platform.UIPresentationControllerDelegate
{
PickHandler = urls => GetFileResults(urls, tcs)
DismissHandler = () => GetFileResults(null, tcs)
};
}

Expand Down Expand Up @@ -74,14 +74,6 @@ public override void DidPickDocument(UIDocumentPickerViewController controller,
public override void DidPickDocument(UIDocumentPickerViewController controller, NSUrl url)
=> PickHandler?.Invoke(new NSUrl[] { url });
}

class PickerPresentationControllerDelegate : UIAdaptivePresentationControllerDelegate
{
public Action<NSUrl[]> PickHandler { get; set; }

public override void DidDismiss(UIPresentationController presentationController) =>
PickHandler?.Invoke(null);
}
}

public partial class FilePickerFileType
Expand Down
12 changes: 2 additions & 10 deletions Xamarin.Essentials/MediaPicker/MediaPicker.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ static async Task<FileResult> PhotoAsync(MediaPickerOptions options, bool photo,

if (picker.PresentationController != null)
{
picker.PresentationController.Delegate = new PhotoPickerPresentationControllerDelegate
picker.PresentationController.Delegate = new Platform.UIPresentationControllerDelegate
{
CompletedHandler = info => GetFileResult(info, tcs)
DismissHandler = () => GetFileResult(null, tcs)
};
}

Expand Down Expand Up @@ -167,13 +167,5 @@ public override void FinishedPickingMedia(UIImagePickerController picker, NSDict
public override void Canceled(UIImagePickerController picker) =>
CompletedHandler?.Invoke(null);
}

class PhotoPickerPresentationControllerDelegate : UIAdaptivePresentationControllerDelegate
{
public Action<NSDictionary> CompletedHandler { get; set; }

public override void DidDismiss(UIPresentationController presentationController) =>
CompletedHandler?.Invoke(null);
}
}
}
Loading

0 comments on commit 801f849

Please sign in to comment.