diff --git a/android-pdf-viewer/bintray.gradle b/android-pdf-viewer/bintray.gradle
deleted file mode 100644
index 9a01f197..00000000
--- a/android-pdf-viewer/bintray.gradle
+++ /dev/null
@@ -1,89 +0,0 @@
-apply plugin: 'com.github.dcendents.android-maven'
-apply plugin: 'com.jfrog.bintray'
-
-group = publishedGroupId
-version = libraryVersion
-
-install {
- repositories.mavenInstaller {
- pom.project {
- packaging 'aar'
- groupId publishedGroupId
- artifactId artifact
-
- name libraryName
- description libraryDescription
- url siteUrl
-
- licenses {
- license {
- name licenseName
- url licenseUrl
- }
- }
- developers {
- developer {
- id developerId
- name developerName
- email developerEmail
- }
- }
- scm {
- connection gitUrl
- developerConnection gitUrl
- url siteUrl
- }
- }
- }
-}
-
-task sourcesJar(type: Jar) {
- classifier = 'sources'
- from android.sourceSets.main.java.srcDirs
-}
-
-task javadoc(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
-}
-
-afterEvaluate {
- javadoc.classpath += files(android.libraryVariants.collect { variant ->
- variant.javaCompileProvider.get().classpath.files
- })
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-artifacts {
- archives javadocJar
- archives sourcesJar
-}
-
-Properties properties = new Properties()
-properties.load(project.rootProject.file('local.properties').newDataInputStream())
-
-bintray {
- user = properties.getProperty("bintray.user")
- key = properties.getProperty("bintray.apikey")
-
- configurations = ['archives']
- pkg {
- repo = bintrayRepo
- name = bintrayName
- desc = libraryDescription
- websiteUrl = siteUrl
- vcsUrl = gitUrl
- licenses = allLicenses
- dryRun = false
- publish = true
- override = false
- publicDownloadNumbers = true
- version {
- desc = libraryDescription
- }
- }
-}
\ No newline at end of file
diff --git a/android-pdf-viewer/build.gradle b/android-pdf-viewer/build.gradle
index 3f325edd..e7d55e9f 100644
--- a/android-pdf-viewer/build.gradle
+++ b/android-pdf-viewer/build.gradle
@@ -1,44 +1,17 @@
apply plugin: 'com.android.library'
-ext {
- bintrayRepo = 'maven'
- bintrayName = 'android-pdf-viewer'
-
- publishedGroupId = 'com.github.barteksc'
- libraryName = 'AndroidPdfViewer'
- artifact = 'android-pdf-viewer'
-
- libraryDescription = 'Android view for displaying PDFs rendered with PdfiumAndroid'
-
- siteUrl = 'https://github.com/barteksc/AndroidPdfViewer'
- gitUrl = 'https://github.com/barteksc/AndroidPdfViewer.git'
-
- libraryVersion = '3.2.0-beta.1'
-
- developerId = 'barteksc'
- developerName = 'Bartosz Schiller'
- developerEmail = 'barteksch@boo.pl'
-
- licenseName = 'The Apache Software License, Version 2.0'
- licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- allLicenses = ["Apache-2.0"]
-}
-
android {
compileSdkVersion 29
defaultConfig {
- minSdkVersion 14
+ minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "3.2.0-beta.1"
}
-
}
dependencies {
- implementation 'androidx.core:core:1.2.0'
- api 'com.github.barteksc:pdfium-android:1.9.0'
-}
-
-apply from: 'bintray.gradle'
\ No newline at end of file
+ implementation 'androidx.core:core:1.3.1'
+ api 'com.github.TalbotGooday:PdfiumAndroid:1.0.1'
+}
\ No newline at end of file
diff --git a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/DecodingAsyncTask.java b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/DecodingAsyncTask.java
index 6e5cdb8d..911cebf7 100644
--- a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/DecodingAsyncTask.java
+++ b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/DecodingAsyncTask.java
@@ -51,9 +51,19 @@ protected Throwable doInBackground(Void... params) {
PDFView pdfView = pdfViewReference.get();
if (pdfView != null) {
PdfDocument pdfDocument = docSource.createDocument(pdfView.getContext(), pdfiumCore, password);
- pdfFile = new PdfFile(pdfiumCore, pdfDocument, pdfView.getPageFitPolicy(), getViewSize(pdfView),
- userPages, pdfView.isOnDualPageMode(), pdfView.isSwipeVertical(), pdfView.getSpacingPx(), pdfView.isAutoSpacingEnabled(),
- pdfView.isFitEachPage(), pdfView.isOnLandscapeOrientation());
+ pdfFile = new PdfFile(
+ pdfiumCore,
+ pdfDocument,
+ pdfView.getPageFitPolicy(),
+ getViewSize(pdfView),
+ userPages,
+ pdfView.isOnDualPageMode(),
+ pdfView.isSwipeVertical(),
+ pdfView.getSpacingPx(),
+ pdfView.isAutoSpacingEnabled(),
+ pdfView.isFitEachPage(),
+ pdfView.isOnLandscapeOrientation()
+ );
return null;
} else {
return new NullPointerException("pdfView == null");
diff --git a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java
index 51f8038b..7c015f72 100644
--- a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java
+++ b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java
@@ -206,7 +206,9 @@ enum ScrollDir {
private boolean isLandscapeOrientation = false;
- /** True if should scroll through pages vertically instead of horizontally */
+ /**
+ * True if should scroll through pages vertically instead of horizontally
+ */
private boolean swipeVertical = true;
private boolean enableSwipe = true;
@@ -807,7 +809,7 @@ void loadComplete(PdfFile pdfFile) {
this.pdfFile = pdfFile;
- if(renderingHandlerThread == null){
+ if (renderingHandlerThread == null) {
renderingHandlerThread = new HandlerThread("PDF renderer");
}
@@ -1242,9 +1244,13 @@ public boolean isOnDualPageMode() {
return dualPageMode;
}
- public boolean isOnLandscapeOrientation() { return isLandscapeOrientation; }
+ public boolean isOnLandscapeOrientation() {
+ return isLandscapeOrientation;
+ }
- public void setLandscapeOrientation(boolean landscapeOrientation) {this.isLandscapeOrientation = landscapeOrientation; }
+ public void setLandscapeOrientation(boolean landscapeOrientation) {
+ this.isLandscapeOrientation = landscapeOrientation;
+ }
public void setDualPageMode(boolean dualPageMode) {
this.dualPageMode = dualPageMode;
diff --git a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/scroll/DefaultScrollHandle.java b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/scroll/DefaultScrollHandle.java
index 3ae1f472..2faa392b 100644
--- a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/scroll/DefaultScrollHandle.java
+++ b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/scroll/DefaultScrollHandle.java
@@ -78,11 +78,7 @@ public void setupLayout(PDFView pdfView) {
}
}
- if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
- setBackgroundDrawable(background);
- } else {
- setBackground(background);
- }
+ setBackground(background);
LayoutParams lp = new LayoutParams(Util.getDP(context, width), Util.getDP(context, height));
lp.setMargins(0, 0, 0, 0);
@@ -151,8 +147,8 @@ private void calculateMiddle() {
pdfViewSize = pdfView.getHeight();
} else if (pdfView.isOnDualPageMode()){
pos = getX();
- viewSize = getWidth() / 2;
- pdfViewSize = pdfView.getWidth() / 2;
+ viewSize = getWidth() / 2f;
+ pdfViewSize = pdfView.getWidth() / 2f;
} else {
pos = getX();
viewSize = getWidth();
diff --git a/build.gradle b/build.gradle
index 0a9a0ba0..96597d9a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,13 +1,11 @@
-
buildscript {
repositories {
google()
jcenter()
+ maven { url 'https://jitpack.io' }
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.4.2'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
+ classpath 'com.android.tools.build:gradle:4.0.1'
}
}
@@ -15,5 +13,6 @@ allprojects {
repositories {
google()
jcenter()
+ maven { url 'https://jitpack.io' }
}
}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 00000000..2d8d1e4d
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1 @@
+android.useAndroidX=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 3c7abdf1..f3d88b1c 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1a59b22b..671c8396 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sun Aug 18 01:14:14 CEST 2019
+#Tue Aug 04 20:30:19 EEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/gradlew b/gradlew
index 91a7e269..2fe81a7d 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,31 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -90,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -110,10 +125,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -138,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 43a9656f..9618d8d9 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,21 +1,18 @@
-@REM
-@REM Copyright 2014 Joan Zapata
-@REM
-@REM This file is part of Android-pdfview.
-@REM
-@REM Android-pdfview is free software: you can redistribute it and/or modify
-@REM it under the terms of the GNU General Public License as published by
-@REM the Free Software Foundation, either version 3 of the License, or
-@REM (at your option) any later version.
-@REM
-@REM Android-pdfview is distributed in the hope that it will be useful,
-@REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-@REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-@REM GNU General Public License for more details.
-@REM
-@REM You should have received a copy of the GNU General Public License
-@REM along with Android-pdfview. If not, see .
-@REM
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@@ -27,14 +24,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -65,10 +62,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -79,11 +75,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/sample/build.gradle b/sample/build.gradle
index 1287b4cf..d10f0be5 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,32 +1,26 @@
-buildscript {
- repositories {
- google()
- jcenter()
- }
-}
-
-repositories {
- google()
- jcenter()
-}
-
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
- minSdkVersion 14
+ applicationId "com.pdfviewer"
+ minSdkVersion 16
targetSdkVersion 29
versionCode 3
versionName "3.0.0"
}
+ buildTypes {
+ release {
+ minifyEnabled true
+ debuggable true
+ proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
+ }
+ }
}
dependencies {
implementation project(':android-pdf-viewer')
implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'org.androidannotations:androidannotations-api:4.6.0'
- annotationProcessor "org.androidannotations:androidannotations:4.6.0"
}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index d6ce646c..d3b2dc7f 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -8,7 +8,7 @@
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light">
diff --git a/sample/src/main/java/com/github/barteksc/sample/PDFViewActivity.java b/sample/src/main/java/com/github/barteksc/sample/PDFViewActivity.java
index 040ff57a..16249772 100755
--- a/sample/src/main/java/com/github/barteksc/sample/PDFViewActivity.java
+++ b/sample/src/main/java/com/github/barteksc/sample/PDFViewActivity.java
@@ -22,13 +22,18 @@
import android.database.Cursor;
import android.graphics.Color;
import android.net.Uri;
+import android.os.Bundle;
import android.provider.OpenableColumns;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Toast;
+
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
-import androidx.appcompat.app.AppCompatActivity;
-import android.util.Log;
-import android.widget.Toast;
import com.github.barteksc.pdfviewer.PDFView;
import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
@@ -38,18 +43,8 @@
import com.github.barteksc.pdfviewer.util.FitPolicy;
import com.shockwave.pdfium.PdfDocument;
-import org.androidannotations.annotations.AfterViews;
-import org.androidannotations.annotations.EActivity;
-import org.androidannotations.annotations.NonConfigurationInstance;
-import org.androidannotations.annotations.OnActivityResult;
-import org.androidannotations.annotations.OptionsItem;
-import org.androidannotations.annotations.OptionsMenu;
-import org.androidannotations.annotations.ViewById;
-
import java.util.List;
-@EActivity(R.layout.activity_main)
-@OptionsMenu(R.menu.options)
public class PDFViewActivity extends AppCompatActivity implements OnPageChangeListener, OnLoadCompleteListener,
OnPageErrorListener {
@@ -61,20 +56,46 @@ public class PDFViewActivity extends AppCompatActivity implements OnPageChangeLi
public static final String SAMPLE_FILE = "sample.pdf";
public static final String READ_EXTERNAL_STORAGE = "android.permission.READ_EXTERNAL_STORAGE";
- @ViewById
- PDFView pdfView;
+ private PDFView pdfView;
- @NonConfigurationInstance
- Uri uri;
+ private Uri uri;
- @NonConfigurationInstance
- Integer pageNumber = 0;
+ private Integer pageNumber = 0;
- String pdfFileName;
+ private String pdfFileName;
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ initViews();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.options, menu);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.pickFile:
+ pickFile();
+
+ break;
+ }
+
+ return true;
+ }
+
+ private void initViews() {
+ pdfView = findViewById(R.id.pdfView);
+
+ afterViews();
+ }
- @OptionsItem(R.id.pickFile)
void pickFile() {
int permissionCheck = ContextCompat.checkSelfPermission(this,
READ_EXTERNAL_STORAGE);
@@ -103,7 +124,6 @@ void launchPicker() {
}
}
- @AfterViews
void afterViews() {
pdfView.setBackgroundColor(Color.LTGRAY);
if (uri != null) {
@@ -126,7 +146,7 @@ private void displayFromAsset(String assetFileName) {
.enableAnnotationRendering(true)
.onLoad(this)
.landscapeOrientation(isLandscape)
- .dualPageMode(true)
+ .dualPageMode(false)
.scrollHandle(new DefaultScrollHandle(this))
.spacing(0) // in dp
.enableSwipe(true)
@@ -156,7 +176,13 @@ private void displayFromUri(Uri uri) {
.load();
}
- @OnActivityResult(REQUEST_CODE)
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ onResult(resultCode, data);
+ }
+
public void onResult(int resultCode, Intent intent) {
if (resultCode == RESULT_OK) {
uri = intent.getData();