-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPDFViewAndroid.uno
More file actions
65 lines (44 loc) · 1.92 KB
/
PDFViewAndroid.uno
File metadata and controls
65 lines (44 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
namespace Native.Android
{
using Uno;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
using Fuse.Controls.Native.Android;
[Require("Gradle.Dependency.Compile", "com.github.barteksc:android-pdf-viewer:2.7.0")]
[ForeignInclude(Language.Java, "com.fuse.Activity", "com.github.barteksc.pdfviewer.PDFView", "com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle", "com.github.barteksc.pdfviewer.listener.OnPageChangeListener", "com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener", "android.content.Context", "android.util.Log", "android.content.Intent", "android.net.Uri", "java.io.File", "android.os.Environment", "android.graphics.pdf.PdfRenderer")]
[Require("AndroidManifest.Permission", "android.permission.WRITE_EXTERNAL_STORAGE")]
[Require("AndroidManifest.Permission", "android.permission.WRITE_INTERNAL_STORAGE")]
[Require("AndroidManifest.Permission", "android.permission.READ_EXTERNAL_STORAGE")]
[Require("AndroidManifest.Permission", "android.permission.READ_INTERNAL_STORAGE")]
extern(Android) class PDF : LeafView, IPDF
{
PDFHost _host;
public PDF (PDFHost host) : base(Create())
{
_host = host;
}
void IPDF.Load(string filename)
{
Load(Handle, filename);
}
[Foreign(Language.Java)]
static Java.Object Create()
@{
PDFView pdfView = new PDFView(Activity.getRootActivity(), null);
return pdfView;
@}
[Foreign(Language.Java)]
void Load(this Java.Object handle, string fileName)
@{
PDFView pdfView = (PDFView)handle;
String pathFile = Activity.getRootActivity().getFilesDir() + "/" + fileName;
File dwldsPath = new File(pathFile);
pdfView.fromFile(dwldsPath)
.defaultPage(0)
.enableAnnotationRendering(true)
.scrollHandle(new DefaultScrollHandle(Activity.getRootActivity()))
.spacing(10) // in dp
.load();
@}
}
}