Skip to content
Open
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
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:4.0.1'
}
}
rootProject.allprojects {
Expand All @@ -30,6 +30,6 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
}
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Binary file added android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Fri Aug 28 10:05:12 ICT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
172 changes: 172 additions & 0 deletions android/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions android/gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 31 additions & 5 deletions android/src/main/java/com/example/pdfviewerplugin/PdfViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.github.barteksc.pdfviewer.PDFView;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.view.View;

import java.io.File;
Expand All @@ -18,18 +21,38 @@
public class PdfViewer implements PlatformView, MethodCallHandler {
private PDFView pdfView;
private String filePath;
private String uri;
private int spacing = 0;
private String bgColorString = "#000000";
private boolean fitEachPage = true;
private PDFView.Configurator configurator;

PdfViewer(Context context, BinaryMessenger messenger, int id, Map<String, Object> args) {
MethodChannel methodChannel = new MethodChannel(messenger, "pdf_viewer_plugin_" + id);
methodChannel.setMethodCallHandler(this);

pdfView = new PDFView(context, null);
if (args.containsKey("backgroundColor") && args.get("backgroundColor") != null) {
bgColorString = (String) args.get("backgroundColor");
}
pdfView.setBackgroundColor(Color.parseColor(bgColorString));

if (!args.containsKey("filePath")) {
return;
if (args.containsKey("filePath") && args.get("filePath") != null) {
filePath = (String) args.get("filePath");
configurator = pdfView.fromFile(new File(filePath));
}

filePath = (String)args.get("filePath");
// if (args.containsKey("uri") && args.get("uri") != null) {
// uri = (String) args.get("uri");
// configurator = pdfView.fromUri(Uri.parse(uri));
// }

if (args.containsKey("spacing") && args.get("spacing") != null) {
spacing = (int) args.get("spacing");
}
if (args.containsKey("fitEachPage") && args.get("fitEachPage") != null) {
fitEachPage = (boolean) args.get("fitEachPage");
}
loadPdfView();
}

Expand All @@ -43,10 +66,12 @@ public void onMethodCall(MethodCall call, Result result) {
}

private void loadPdfView() {
pdfView.fromFile(new File(filePath))
configurator
.enableSwipe(true) // allows to block changing pages using swipe
.swipeHorizontal(false)
.enableDoubletap(true)
.spacing(spacing)
.fitEachPage(true)
.defaultPage(0)
.load();
}
Expand All @@ -57,5 +82,6 @@ public View getView() {
}

@Override
public void dispose() {}
public void dispose() {
}
}
1 change: 1 addition & 0 deletions example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"path_provider","dependencies":[]},{"name":"pdf_viewer_plugin","dependencies":[]}]}
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:4.0.1'
}
}

Expand Down
1 change: 1 addition & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
3 changes: 2 additions & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Fri Aug 28 10:40:00 ICT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
1 change: 1 addition & 0 deletions example/android/settings_aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
Loading