Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed capture photo with linker #86

Merged
merged 2 commits into from
Dec 18, 2021
Merged
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
1 change: 1 addition & 0 deletions MediaGallery/MediaGallery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<ItemGroup Condition=" '$(_Droid)' == 'true' ">
<Compile Include="**\*.android.*.cs" />
<Compile Include="**\*.android.cs" />
<AndroidResource Include="Resources\xml\*.xml" />
</ItemGroup>
<ItemGroup Condition=" '$(_IOS)' == 'true' ">
<Compile Include="**\*.ios.*.cs" />
Expand Down
2 changes: 1 addition & 1 deletion MediaGallery/MediaGallery/PickMedia.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static async Task<IMediaFile> PlatformCapturePhotoAsync(CancellationToken token)
using var file = new File(tempFilePath);
if (!file.Exists())
file.CreateNewFile();
outputUri = FileProvider.GetUriForFile(Platform.AppActivity, Platform.AppActivity.PackageName + ".fileProvider", file);
outputUri = MediaFileProvider.GetUriForFile(Platform.AppActivity, file);
intent.PutExtra(MediaStore.ExtraOutput, outputUri);

CancelTaskIfRequested(token, tcsCamera);
Expand Down
12 changes: 12 additions & 0 deletions MediaGallery/Platform/Platform.android.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Android.App;
using Android.Content;
using Android.OS;
using AndroidUri = Android.Net.Uri;
using ContentFileProvider = AndroidX.Core.Content.FileProvider;

namespace NativeMedia
{
Expand Down Expand Up @@ -39,4 +41,14 @@ internal static bool IsIntentSupported(Intent intent)
}

}

[ContentProvider(new[] { "${applicationId}" + Authority },Name = "haraba.fileProvider", Exported = false, GrantUriPermissions = true)]
[MetaData("android.support.FILE_PROVIDER_PATHS", Resource = "@xml/file_provider_paths")]
public class MediaFileProvider : ContentFileProvider
{
internal const string Authority = ".mediaFileProvider";

internal static AndroidUri GetUriForFile(Context context, Java.IO.File file)
=> GetUriForFile(context, context.PackageName + Authority, file);
}
}
4 changes: 4 additions & 0 deletions MediaGallery/Resources/xml/file_provider_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<paths>
<cache-path name="internal_cache" path="." />
</paths>
2 changes: 1 addition & 1 deletion Xamarim.MediaGallery.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<_UseNuget>true</_UseNuget>
<_UseNuget Condition="'$(Configuration)'=='Release'">true</_UseNuget>
<_LibVersion>2.1.0</_LibVersion>
<_LibVersion>2.1.1</_LibVersion>
<_PermissionLibVersion>2.0.0</_PermissionLibVersion>
<_IsSample Condition="'$(_IsSample)'!='false'">true</_IsSample>
<_NET6 Condition=" $(TargetFramework.StartsWith('net6')) ">true</_NET6>
Expand Down