Compare commits

...

20 Commits

Author SHA1 Message Date
Xsims c6fb2aceda Add document name in toolbar 2023-01-27 02:08:50 -05:00
Daniel Micay 7f59118453 update AndroidX appcompat library to 1.6.0 2023-01-13 19:54:54 -05:00
Daniel Micay 5b46b4c80e update Android Gradle plugin to 7.4.0 2023-01-13 19:54:29 -05:00
r3g_5z e34c727ff7 Update pdf.js to v3.2.146
Signed-off-by: r3g_5z <june@girlboss.ceo>
2023-01-09 01:20:41 -05:00
Daniel Micay 3e60cca098 add Gradle verification metadata 2023-01-09 01:11:30 -05:00
Daniel Micay 48910db7c6 silence spurious getParcelable deprecation warning 2022-12-28 12:15:34 -05:00
Daniel Micay fd510a3c19 avoid deprecated DialogFragment onActivityCreated 2022-12-28 12:08:22 -05:00
Daniel Micay b8dcc33696 remove legacy roundIcon attribute 2022-12-25 10:38:50 -05:00
Daniel Micay 45a0952296 drop non-working dependabot workaround 2022-12-25 10:14:16 -05:00
Patryk Mis aaa93a6f88 update build tools to 33.0.1 2022-12-20 04:31:08 -05:00
Daniel Micay 414d7fe3d1 update Gradle to 7.6 2022-12-09 08:48:17 -05:00
randomhydrosol 99c8c13fec update pdfjs to v3.1.81 2022-12-05 03:31:24 -05:00
loryeam 1cf1c7ec28 horizontally and vertically center canvas and text layer
Also fixes an issue where text layer is not exactly on top of the canvas when
canvas width is less than screen width (which happens often in landscape mode or
when fully zoomed out)
2022-12-05 03:20:08 -05:00
octocorvus ac4aa0bbb9 [webview] set minimum font size to 1px
This fixes an issue where some text layer divs (those with font
size < 8px) gets misaligned due to webview setting their font size
to 8px.
2022-12-04 18:32:28 -05:00
dependabot[bot] abfb212011 Bump kotlin-gradle-plugin from 1.7.21 to 1.7.22
Bumps [kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) from 1.7.21 to 1.7.22.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.21...v1.7.22)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-29 17:17:43 -05:00
dependabot[bot] a3ba77534c Bump kotlin-gradle-plugin from 1.7.20 to 1.7.21
Bumps [kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) from 1.7.20 to 1.7.21.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-08 21:58:27 -05:00
Daniel Micay ed3cf2c08f remove no-op allowBackup
This was added to silence a now removed lint check.
2022-10-29 21:11:07 -04:00
smdyv e1dd3db05a Bump material from 1.6.1 to 1.7.0 2022-10-25 15:14:35 -04:00
Daniel Micay 22bd993a75 update to JDK 19 2022-10-19 19:27:19 -04:00
dependabot[bot] a73caa5914 Bump gradle from 7.3.0 to 7.3.1
Bumps gradle from 7.3.0 to 7.3.1.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-13 17:07:42 -04:00
14 changed files with 2193 additions and 50 deletions

View File

@ -10,11 +10,11 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up JDK 18
- name: Set up JDK 19
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 18
java-version: 19
cache: gradle
- name: Build with Gradle
run: ./gradlew build --no-daemon

View File

@ -33,7 +33,7 @@ android {
}
compileSdk = 33
buildToolsVersion = "33.0.0"
buildToolsVersion = "33.0.1"
namespace = "app.grapheneos.pdfviewer"
@ -84,6 +84,6 @@ android {
}
dependencies {
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("com.google.android.material:material:1.6.1")
implementation("androidx.appcompat:appcompat:1.6.0")
implementation("com.google.android.material:material:1.7.0")
}

View File

@ -4,10 +4,8 @@
<original-package android:name="org.grapheneos.pdfviewer" />
<application android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity android:name=".PdfViewer"
android:documentLaunchMode="always"

View File

@ -1,24 +1,36 @@
html, body {
height: 100%;
}
body, canvas {
padding: 0;
margin: 0;
}
canvas {
margin: auto;
display: block;
}
body {
background-color: #c0c0c0;
}
#container {
width: 100%;
height: 100%;
display: grid;
place-items: center;
}
#container canvas, #container .textLayer {
/* overlay child elements on top of each other */
grid-row-start: 1;
grid-column-start: 1;
}
canvas, .textLayer {
display: inline-block;
position: relative;
}
.textLayer {
position: absolute;
text-align: initial;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
opacity: 0.2;
line-height: 1;

View File

@ -7,8 +7,10 @@
<script src="pdf.js"></script>
</head>
<body>
<canvas id="content"></canvas>
<div id="text" class="textLayer"></div>
<div id="container">
<canvas id="content"></canvas>
<div id="text" class="textLayer"></div>
</div>
<script src="viewer.js"></script>
</body>
</html>

View File

@ -252,6 +252,7 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
settings.setAllowFileAccess(false);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setJavaScriptEnabled(true);
settings.setMinimumFontSize(1);
CookieManager.getInstance().setAcceptCookie(false);
@ -385,7 +386,9 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
if (savedInstanceState != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
mUri = savedInstanceState.getParcelable(STATE_URI);
@SuppressWarnings("deprecation")
final Uri uri = savedInstanceState.getParcelable(STATE_URI);
mUri = uri;
} else {
mUri = savedInstanceState.getParcelable(STATE_URI, Uri.class);
}
@ -437,6 +440,15 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
return mPasswordPromptFragment;
}
private void setToolbarTitleWithDocumentName() {
String documentName = getCurrentDocumentName();
if (documentName != null && !documentName.isEmpty()) {
getSupportActionBar().setTitle(documentName);
} else {
getSupportActionBar().setTitle(R.string.app_name);
}
}
@Override
protected void onResume() {
super.onResume();
@ -468,6 +480,7 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
@Override
public void onLoadFinished(@NonNull Loader<List<CharSequence>> loader, List<CharSequence> data) {
mDocumentProperties = data;
setToolbarTitleWithDocumentName();
LoaderManager.getInstance(this).destroyLoader(DocumentPropertiesLoader.ID);
}

View File

@ -22,23 +22,19 @@ public class JumpToPageFragment extends DialogFragment {
private NumberPicker mPicker;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
mPicker.setMinValue(savedInstanceState.getInt(STATE_PICKER_MIN));
mPicker.setMaxValue(savedInstanceState.getInt(STATE_PICKER_MAX));
mPicker.setValue(savedInstanceState.getInt(STATE_PICKER_CUR));
}
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mPicker = new NumberPicker(getActivity());
mPicker.setMinValue(1);
mPicker.setMaxValue(((PdfViewer)requireActivity()).mNumPages);
mPicker.setValue(((PdfViewer)requireActivity()).mPage);
if (savedInstanceState != null) {
mPicker.setMinValue(savedInstanceState.getInt(STATE_PICKER_MIN));
mPicker.setMaxValue(savedInstanceState.getInt(STATE_PICKER_MAX));
mPicker.setValue(savedInstanceState.getInt(STATE_PICKER_CUR));
} else {
mPicker.setMinValue(1);
mPicker.setMaxValue(((PdfViewer)requireActivity()).mNumPages);
mPicker.setValue(((PdfViewer)requireActivity()).mPage);
}
final FrameLayout layout = new FrameLayout(getActivity());
layout.addView(mPicker, new FrameLayout.LayoutParams(

View File

@ -1,17 +1,11 @@
buildscript {
repositories {
// dependabot cannot handle google()
maven {
url = uri("https://dl.google.com/dl/android/maven2")
}
// dependabot cannot handle mavenCentral()
maven {
url = uri("https://repo.maven.apache.org/maven2")
}
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
classpath("com.android.tools.build:gradle:7.4.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22")
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

12
gradlew vendored
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@ -80,10 +80,10 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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"'
@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac

1
gradlew.bat vendored
View File

@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@ -1 +1 @@
Subproject commit cc3d3bf299ae11f8f72ae8d64cbf19b340f9a996
Subproject commit 5f07d5a4159bb99eee2f6143d1297f03b45bba58