-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share pdf file to this app and render it Android/IOS
- Loading branch information
1 parent
3899836
commit 6c9a0ab
Showing
21 changed files
with
416 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: [ feature/github_workflow ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
Build: | ||
runs-on: [windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup MSBuild | ||
uses: microsoft/setup-msbuild@v1 | ||
|
||
- name: Setup NuGet | ||
uses: NuGet/[email protected] | ||
|
||
- name: Restore NuGet packages | ||
run: nuget restore iCL.DocumentConverter.sln | ||
|
||
- name: Build the Solution | ||
run: msbuild iCL.DocumentConverter.sln /p:Configuration=Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ feature/github_workflow ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
Build: | ||
runs-on: [windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
dotnet-version: 6.0.x | ||
|
||
- name: Setup MSBuild | ||
uses: microsoft/setup-msbuild@v1 | ||
|
||
- name: Execute unit tests | ||
run: dotnet test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,109 @@ | ||
using Android.App; | ||
using System.IO; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.Content.PM; | ||
using Android.Net; | ||
using Android.OS; | ||
using Android.Provider; | ||
using Android.Runtime; | ||
using Android.Views; | ||
using Android.Widget; | ||
using DocumentConverter.Plugin.Shared; | ||
using DocumentConverter.Plugin.Shared.FileSharing; | ||
using DocumentConverter.Plugin.Shared.StreamProvider; | ||
using DocumentPicker.Samples; | ||
using DocumentPicker.Samples.NotifyVisibility; | ||
using Svg; | ||
|
||
namespace DocumentPicker.Droid | ||
{ | ||
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] | ||
[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = @"application/pdf")] | ||
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity | ||
{ | ||
protected override void OnCreate(Bundle bundle) | ||
{ | ||
base.OnCreate(bundle); | ||
LoadApp(bundle); | ||
|
||
|
||
if (Intent.ActionSend.Equals(Intent?.Action) && | ||
Intent.Type != null && | ||
"application/pdf".Equals(Intent.Type)) | ||
{ | ||
// This is just an example of the data stored in the extras | ||
var uriFromExtras = Intent.GetParcelableExtra(Intent.ExtraStream) as Android.Net.Uri; | ||
var subject = Intent.GetStringExtra(Intent.ExtraSubject); | ||
|
||
// Get the info from ClipData | ||
var pdf = Intent.ClipData.GetItemAt(0); | ||
|
||
// Open a stream from the URI | ||
var pdfStream = ContentResolver.OpenInputStream(pdf.Uri); | ||
|
||
SharedStream.Instance = pdfStream; | ||
SharedVisibles.ShowShareViews(); | ||
|
||
//Save off the path and description here | ||
//Remove dialog and navigate back to app or browser that shared | ||
//the link | ||
} | ||
} | ||
|
||
private void LoadApp(Bundle bundle) | ||
{ | ||
FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); | ||
Xamarin.Essentials.Platform.Init(this, bundle); | ||
Xamarin.Forms.Forms.Init(this, bundle); | ||
SvgPlatform.Init(); | ||
LoadApplication(new App()); | ||
} | ||
|
||
//private Stream GetFileStream(Uri uri) | ||
//{ | ||
|
||
// // Get the info from ClipData | ||
// var pdf = Intent.ClipData.GetItemAt(0); | ||
|
||
// // Open a stream from the URI | ||
// var pdfStream = ContentResolver.OpenInputStream(pdf.Uri); | ||
|
||
|
||
// return pdfStream; | ||
//} | ||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) | ||
{ | ||
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); | ||
|
||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults); | ||
} | ||
|
||
//private void handleSendUrl() | ||
//{ | ||
// var view = new LinearLayout(this) { Orientation = Orientation.Vertical }; | ||
// var url = Intent.GetStringExtra(Intent.ExtraText); | ||
|
||
// var urlTextView = new TextView(this) { Gravity = GravityFlags.Center }; | ||
// urlTextView.Text = url; | ||
|
||
// view.AddView(urlTextView); | ||
// var description = new EditText(this) { Gravity = GravityFlags.Top }; | ||
// view.AddView(description); | ||
|
||
// new AlertDialog.Builder(this) | ||
// .SetTitle("Save a URL Link") | ||
// .SetMessage("Type a description for your link") | ||
// .SetView(view) | ||
// .SetPositiveButton("Add", (dialog, whichButton) => | ||
// { | ||
// var desc = description.Text; | ||
// //Save off the url and description here | ||
// //Remove dialog and navigate back to app or browser that shared | ||
// //the link | ||
// FinishAndRemoveTask(); | ||
// FinishAffinity(); | ||
// }) | ||
// .Show(); | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/DocumentPicker.Plugin/Shared/FileSharing/SharedStream.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.IO; | ||
using DocumentConverter.Plugin.Shared.StreamProvider; | ||
|
||
namespace DocumentConverter.Plugin.Shared.FileSharing | ||
{ | ||
public static class SharedStream | ||
{ | ||
private static Stream _stream; | ||
|
||
public static Stream Instance | ||
{ | ||
get => _stream; | ||
set => _stream = value; | ||
} | ||
|
||
public static void DisposeStream() | ||
{ | ||
Instance.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.