mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Share android ok
This commit is contained in:
		
							parent
							
								
									1899b3a5b3
								
							
						
					
					
						commit
						e8d2d62287
					
				
					 7 changed files with 52 additions and 3 deletions
				
			
		|  | @ -426,5 +426,8 @@ | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <AndroidResource Include="Resources\drawable\battle_axe_.xml" /> |     <AndroidResource Include="Resources\drawable\battle_axe_.xml" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <AndroidResource Include="Resources\xml\file_paths.xml" /> | ||||||
|  |   </ItemGroup> | ||||||
|   <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> |   <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> | ||||||
| </Project> | </Project> | ||||||
|  | @ -195,5 +195,30 @@ namespace AideDeJeu.Droid | ||||||
|         //    return Task.CompletedTask; |         //    return Task.CompletedTask; | ||||||
|         //} |         //} | ||||||
| 
 | 
 | ||||||
|  |         public async Task LaunchFileAsync(string title, string message, string filePath) | ||||||
|  |         { | ||||||
|  |             var context = Android.App.Application.Context; | ||||||
|  |             var uri = Android.Support.V4.Content.FileProvider.GetUriForFile(context, context.PackageName + ".fileprovider", new Java.IO.File(filePath)); | ||||||
|  |             //var uri = Android.Net.Uri.Parse("file://" + filePath); | ||||||
|  |             var contentType = "application/pdf"; | ||||||
|  |             var intent = new Intent(Intent.ActionView); | ||||||
|  |             /*intent.PutExtra(Intent.ExtraStream, uri); | ||||||
|  |             intent.PutExtra(Intent.ExtraText, string.Empty); | ||||||
|  |             intent.PutExtra(Intent.ExtraSubject, message ?? string.Empty); | ||||||
|  |             intent.SetType(contentType); | ||||||
|  |             var chooserIntent = Intent.CreateChooser(intent, title ?? string.Empty); | ||||||
|  |             //chooserIntent.SetDataAndType(uri, "application/pdf"); | ||||||
|  |             chooserIntent.SetFlags(ActivityFlags.ClearTop); | ||||||
|  |             chooserIntent.SetFlags(ActivityFlags.NewTask); | ||||||
|  |             chooserIntent.AddFlags(ActivityFlags.GrantReadUriPermission); | ||||||
|  |             chooserIntent.AddFlags(ActivityFlags.GrantWriteUriPermission); | ||||||
|  |             context.StartActivity(chooserIntent); | ||||||
|  |             */ | ||||||
|  |             intent.SetDataAndType(uri, "application/pdf"); | ||||||
|  |             intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.GrantReadUriPermission); | ||||||
|  |             context.StartActivity(intent); | ||||||
|  |             //return Task.FromResult(true); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,5 +1,12 @@ | ||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nioux.aidedejeu" android:installLocation="preferExternal" android:versionCode="33" android:versionName="1.33"> | <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nioux.aidedejeu" android:installLocation="preferExternal" android:versionCode="33" android:versionName="1.33"> | ||||||
| 	<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28" /> | 	<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28" /> | ||||||
| 	<application android:label="Beta Haches & Dés"></application> | 	<application android:label="Beta Haches & Dés"> | ||||||
|  |     <provider android:name="android.support.v4.content.FileProvider" | ||||||
|  |             android:authorities="com.nioux.aidedejeu.fileprovider" | ||||||
|  |             android:exported="false" | ||||||
|  |             android:grantUriPermissions="true"> | ||||||
|  |       <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data> | ||||||
|  |     </provider> | ||||||
|  |   </application> | ||||||
| </manifest> | </manifest> | ||||||
|  | @ -12163,7 +12163,10 @@ namespace AideDeJeu.Droid | ||||||
| 		{ | 		{ | ||||||
| 			 | 			 | ||||||
| 			// aapt resource value: 0x7f070000 | 			// aapt resource value: 0x7f070000 | ||||||
| 			public const int xamarin_essentials_fileprovider_file_paths = 2131165184; | 			public const int file_paths = 2131165184; | ||||||
|  | 			 | ||||||
|  | 			// aapt resource value: 0x7f070001 | ||||||
|  | 			public const int xamarin_essentials_fileprovider_file_paths = 2131165185; | ||||||
| 			 | 			 | ||||||
| 			static Xml() | 			static Xml() | ||||||
| 			{ | 			{ | ||||||
|  |  | ||||||
							
								
								
									
										8
									
								
								AideDeJeu/AideDeJeu.Android/Resources/xml/file_paths.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								AideDeJeu/AideDeJeu.Android/Resources/xml/file_paths.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <paths xmlns:android="http://schemas.android.com/apk/res/android"> | ||||||
|  |   <external-path name="external" path="." /> | ||||||
|  |   <external-files-path name="external_files" path="." /> | ||||||
|  |   <cache-path name="cache" path="." /> | ||||||
|  |   <external-cache-path name="external_cache" path="." /> | ||||||
|  |   <files-path name="files" path="." /> | ||||||
|  | </paths> | ||||||
|  | @ -14,5 +14,6 @@ namespace AideDeJeu.Tools | ||||||
|         Task SaveStreamAsync(string filename, Stream stream); |         Task SaveStreamAsync(string filename, Stream stream); | ||||||
|         Stream CreateStream(string filename); |         Stream CreateStream(string filename); | ||||||
|         //void OpenFileByName(string fileName); |         //void OpenFileByName(string fileName); | ||||||
|  |         Task LaunchFileAsync(string title, string message, string filePath); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1260,6 +1260,8 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|             //var file = Path.Combine(FileSystem.CacheDirectory, fn); |             //var file = Path.Combine(FileSystem.CacheDirectory, fn); | ||||||
|             //File.WriteAllText(file, "Hello World"); |             //File.WriteAllText(file, "Hello World"); | ||||||
|             var testfile = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory, "test.pdf"); |             var testfile = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory, "test.pdf"); | ||||||
|  |             await DependencyService.Get<INativeAPI>().LaunchFileAsync("hophop", "coucou", testfile); | ||||||
|  |             /* | ||||||
|             var shareFile = new Xamarin.Essentials.ShareFile(testfile); |             var shareFile = new Xamarin.Essentials.ShareFile(testfile); | ||||||
|             //var truc = Platform.GetShareableFileUri(request.File.FullPath); |             //var truc = Platform.GetShareableFileUri(request.File.FullPath); | ||||||
|             //await Xamarin.Essentials.Browser.OpenAsync(testfile); |             //await Xamarin.Essentials.Browser.OpenAsync(testfile); | ||||||
|  | @ -1268,7 +1270,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|                 Title = "ou yeah", |                 Title = "ou yeah", | ||||||
|                 File = shareFile |                 File = shareFile | ||||||
|             }); |             }); | ||||||
| 
 |             */ | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private int PickAbility(Random random, ref List<int> mins, ref List<int> maxs, string name) |         private int PickAbility(Random random, ref List<int> mins, ref List<int> maxs, string name) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez