Skip to content

Commit 8dbe837

Browse files
committed
Bug fixes
1 parent 2f457db commit 8dbe837

20 files changed

+548
-753
lines changed

app/build.gradle.kts

+21-21
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ plugins {
88
android {
99
namespace = "com.rajat.sample.pdfviewer"
1010

11-
compileSdk = 34
11+
compileSdk = 35
1212

1313
defaultConfig {
1414
applicationId = "com.rajat.sample.pdfviewer"
15-
minSdk = 21
16-
targetSdk = 34
15+
minSdk = 23
16+
targetSdk = 35
1717
versionCode = 2
1818
versionName = "1.1"
1919
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -69,27 +69,27 @@ dependencies {
6969
implementation(kotlin("stdlib"))
7070
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
7171
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
72-
implementation("androidx.core:core-ktx:1.12.0")
73-
implementation("androidx.appcompat:appcompat:1.6.1")
74-
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
75-
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
76-
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
72+
implementation("androidx.core:core-ktx:1.15.0")
73+
implementation("androidx.appcompat:appcompat:1.7.0")
74+
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
75+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
76+
implementation(platform("androidx.compose:compose-bom:2025.02.00"))
7777
implementation("androidx.compose.ui:ui-graphics")
7878
testImplementation("junit:junit:4.13.2")
79-
androidTestImplementation("androidx.test.ext:junit:1.1.5")
80-
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
79+
androidTestImplementation("androidx.test.ext:junit:1.2.1")
80+
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
8181
implementation(project(":pdfViewer"))
8282
// implementation("io.github.afreakyelf:Pdf-Viewer:2.1.1")
83-
testImplementation("androidx.test:core:1.5.0")
84-
androidTestImplementation("androidx.test:runner:1.5.2")
85-
androidTestImplementation("androidx.test:rules:1.5.0")
86-
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.5")
83+
testImplementation("androidx.test:core:1.6.1")
84+
androidTestImplementation("androidx.test:runner:1.6.2")
85+
androidTestImplementation("androidx.test:rules:1.6.1")
86+
androidTestImplementation("androidx.test.ext:junit-ktx:1.2.1")
8787

88-
implementation("androidx.recyclerview:recyclerview:1.3.2") // Check for the latest version available
88+
implementation("androidx.recyclerview:recyclerview:1.4.0") // Check for the latest version available
8989

9090
// compose
91-
implementation(platform("androidx.compose:compose-bom:2023.10.01"))
92-
androidTestImplementation(platform("androidx.compose:compose-bom:2023.10.01"))
91+
implementation(platform("androidx.compose:compose-bom:2025.02.00"))
92+
androidTestImplementation(platform("androidx.compose:compose-bom:2025.02.00"))
9393

9494
// Choose one of the following:
9595
// Material Design 3
@@ -104,18 +104,18 @@ dependencies {
104104

105105
// Android Studio Preview support
106106
implementation("androidx.compose.ui:ui-tooling-preview")
107-
androidTestImplementation(platform("androidx.compose:compose-bom:2023.10.01"))
107+
androidTestImplementation(platform("androidx.compose:compose-bom:2025.02.00"))
108108
debugImplementation("androidx.compose.ui:ui-tooling")
109109

110110
// UI Tests
111111
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
112112
debugImplementation("androidx.compose.ui:ui-test-manifest")
113-
androidTestImplementation("androidx.test.ext:junit:1.1.5")
114-
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
113+
androidTestImplementation("androidx.test.ext:junit:1.2.1")
114+
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
115115

116116

117117
// Optional - Integration with activities
118-
implementation("androidx.activity:activity-compose:1.8.2")
118+
implementation("androidx.activity:activity-compose:1.10.0")
119119

120120

121121
}

app/src/main/AndroidManifest.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@
1717
android:requestLegacyExternalStorage="true"
1818
android:roundIcon="@mipmap/ic_launcher_round"
1919
android:supportsRtl="true"
20-
android:theme="@style/AppTheme">
20+
android:theme="@style/Theme.MyApp">
2121
<activity
2222
android:name=".ComposeActivity"
2323
android:exported="false"
2424
android:label="@string/title_activity_compose"
25-
android:theme="@style/AppTheme" />
25+
android:theme="@style/Theme.MyApp"/>
2626
<activity
2727
android:name=".MainActivity"
2828
android:exported="true">
2929
<intent-filter>
3030
<action android:name="android.intent.action.MAIN" />
31-
3231
<category android:name="android.intent.category.LAUNCHER" />
3332
</intent-filter>
3433
</activity>

app/src/main/java/com/rajat/sample/pdfviewer/MainActivity.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class MainActivity : AppCompatActivity() {
1717
private lateinit var binding: ActivityMainBinding
1818

1919
private var download_file_url = "https://css4.pub/2015/usenix/example.pdf"
20-
private var large_pdf = "https://research.nhm.org/pdfs/10840/10840.pdf"
20+
// private var large_pdf = "https://research.nhm.org/pdfs/10840/10840.pdf"
21+
private var large_pdf = "https://tinyurl.com/mpn6vude"
2122
private var download_file_url1 = "https://css4.pub/2017/newsletter/drylab.pdf"
2223
private var download_file_url2 = "https://css4.pub/2015/textbook/somatosensory.pdf"
2324

+46-44
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,105 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
xmlns:tools="http://schemas.android.com/tools"
45
android:layout_width="match_parent"
5-
xmlns:app="http://schemas.android.com/apk/res-auto"
6-
android:orientation="vertical"
7-
android:gravity="center"
86
android:layout_height="match_parent"
7+
android:gravity="center"
8+
android:orientation="vertical"
99
tools:context=".MainActivity">
1010

1111
<androidx.constraintlayout.widget.ConstraintLayout
1212
android:layout_width="match_parent"
13-
android:orientation="horizontal"
14-
android:gravity="center"
1513
android:layout_height="wrap_content"
14+
android:layout_marginTop="?actionBarSize"
15+
android:gravity="center"
16+
android:orientation="horizontal"
1617
tools:context=".MainActivity">
1718

18-
<Button
19-
android:layout_marginTop="20dp"
20-
app:layout_constraintTop_toTopOf="parent"
21-
app:layout_constraintStart_toStartOf="parent"
22-
app:layout_constraintEnd_toEndOf="parent"
23-
android:layout_marginStart="30dp"
24-
android:layout_marginEnd="30dp"
25-
android:id="@+id/onlinePdf"
26-
android:backgroundTint="@color/colorPrimary"
27-
android:textColor="#ffffff"
28-
android:layout_width="0dp"
29-
android:layout_height="wrap_content"
30-
android:text="Sample Online PDF"/>
19+
<Button
20+
android:id="@+id/onlinePdf"
21+
android:layout_marginTop="?actionBarSize"
22+
android:layout_width="0dp"
23+
android:layout_height="wrap_content"
24+
android:layout_marginStart="30dp"
25+
android:layout_marginEnd="30dp"
26+
android:backgroundTint="@color/colorPrimary"
27+
android:text="Sample Online PDF"
28+
android:textColor="#ffffff"
29+
app:layout_constraintEnd_toEndOf="parent"
30+
app:layout_constraintStart_toStartOf="parent"
31+
app:layout_constraintTop_toTopOf="parent" />
3132

3233
<Button
3334
android:id="@+id/pickPdfButton"
3435
android:layout_width="0dp"
3536
android:layout_height="wrap_content"
37+
android:layout_marginStart="30dp"
38+
android:layout_marginEnd="30dp"
3639
android:backgroundTint="@color/colorPrimary"
3740
android:text="Pick PDF"
3841
android:textColor="#ffffff"
39-
app:layout_constraintTop_toBottomOf="@id/onlinePdf"
40-
app:layout_constraintStart_toStartOf="parent"
4142
app:layout_constraintEnd_toEndOf="parent"
42-
android:layout_marginStart="30dp"
43-
android:layout_marginEnd="30dp"/>
43+
app:layout_constraintStart_toStartOf="parent"
44+
app:layout_constraintTop_toBottomOf="@id/onlinePdf" />
4445

4546
<Button
4647
android:id="@+id/fromAssets"
4748
android:layout_width="0dp"
4849
android:layout_height="wrap_content"
50+
android:layout_marginStart="30dp"
51+
android:layout_marginEnd="30dp"
4952
android:backgroundTint="@color/colorPrimary"
5053
android:text="Sample from assets"
5154
android:textColor="#ffffff"
52-
app:layout_constraintTop_toBottomOf="@id/pickPdfButton"
53-
app:layout_constraintStart_toStartOf="parent"
5455
app:layout_constraintEnd_toEndOf="parent"
55-
android:layout_marginStart="30dp"
56-
android:layout_marginEnd="30dp" />
56+
app:layout_constraintStart_toStartOf="parent"
57+
app:layout_constraintTop_toBottomOf="@id/pickPdfButton" />
5758

5859
<Button
5960
android:id="@+id/openInCompose"
6061
android:layout_width="0dp"
6162
android:layout_height="wrap_content"
63+
android:layout_marginStart="30dp"
64+
android:layout_marginEnd="30dp"
6265
android:backgroundTint="@color/colorPrimary"
6366
android:text="Compose view"
6467
android:textColor="#ffffff"
65-
app:layout_constraintTop_toBottomOf="@id/fromAssets"
66-
app:layout_constraintStart_toStartOf="parent"
6768
app:layout_constraintEnd_toEndOf="parent"
68-
android:layout_marginStart="30dp"
69-
android:layout_marginEnd="30dp"/>
69+
app:layout_constraintStart_toStartOf="parent"
70+
app:layout_constraintTop_toBottomOf="@id/fromAssets" />
7071

7172

7273
<Button
7374
android:id="@+id/showInView"
7475
android:layout_width="0dp"
7576
android:layout_height="wrap_content"
77+
android:layout_marginStart="30dp"
78+
android:layout_marginEnd="30dp"
7679
android:backgroundTint="@color/colorPrimary"
7780
android:text="Show pdf in a View"
7881
android:textColor="#ffffff"
79-
app:layout_constraintTop_toBottomOf="@id/openInCompose"
80-
app:layout_constraintStart_toStartOf="parent"
8182
app:layout_constraintEnd_toEndOf="parent"
82-
android:layout_marginStart="30dp"
83-
android:layout_marginEnd="30dp"/>
83+
app:layout_constraintStart_toStartOf="parent"
84+
app:layout_constraintTop_toBottomOf="@id/openInCompose" />
8485

8586

8687
</androidx.constraintlayout.widget.ConstraintLayout>
8788

8889

89-
<LinearLayout android:layout_width="match_parent"
90-
android:orientation="horizontal"
91-
android:gravity="center"
92-
android:layout_marginTop="40dp"
90+
<LinearLayout
91+
android:layout_width="match_parent"
9392
android:layout_height="match_parent"
93+
android:layout_marginTop="40dp"
94+
android:gravity="center"
95+
android:orientation="horizontal"
9496
tools:context=".MainActivity">
9597

96-
<com.rajat.pdfviewer.PdfRendererView
97-
android:id="@+id/pdfView"
98-
android:layout_width="match_parent"
99-
android:layout_height="match_parent"
100-
app:pdfView_divider="@drawable/pdf_viewer_divider"
101-
app:pdfView_showDivider="false" />
98+
<com.rajat.pdfviewer.PdfRendererView
99+
android:id="@+id/pdfView"
100+
android:layout_width="match_parent"
101+
android:layout_height="match_parent"
102+
app:pdfView_divider="@drawable/pdf_viewer_divider"
103+
app:pdfView_showDivider="false" />
102104
</LinearLayout>
103105
</LinearLayout>

app/src/main/res/values/styles.xml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<resources>
2-
3-
42
<style name="Theme.PdfView.SelectedTheme" parent="@style/Theme.PdfView.Light">
53
<item name="pdfView_showToolbar">true</item>
6-
<item name="pdfView_actionBarTint">@color/colorPrimary</item>
4+
<item name="pdfView_actionBarTint">@color/design_default_color_error</item>
75
<item name="pdfView_downloadIconTint">#ffffff</item>
86
<item name="pdfView_enableLoadingForPages">true</item>
97
<item name="pdfView_titleTextStyle">@style/actionBarTitleAppearance</item>

app/src/main/res/values/themes.xml

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
4-
<!-- Base application theme. -->
5-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
6-
<!-- Customize your theme here. -->
7-
<item name="colorPrimary">@color/colorPrimary</item>
8-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
9-
<item name="colorAccent">@color/colorAccent</item>
3+
<style name="Theme.MyApp" parent="Theme.Material3.DayNight">
4+
<item name="colorPrimary">#616062</item>
5+
<item name="colorOnPrimary">#FFFFFF</item>
6+
<item name="colorSurface">#121212</item>
7+
<item name="colorOnSurface">#EAEAEA</item>
108
</style>
11-
129
</resources>

build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
plugins {
3-
id("com.android.application") version "8.2.0" apply false
3+
id("com.android.application") version "8.8.1" apply false
44
id("org.jetbrains.kotlin.android") version "1.9.20" apply false
5-
id("com.android.library") version "8.2.0" apply false
5+
id("com.android.library") version "8.8.1" apply false
66
}

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip

pdfViewer/build.gradle.kts

+17-16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ android {
1414
compileSdk = 34
1515

1616
defaultConfig {
17-
minSdk = 21
17+
minSdk = 23
1818
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1919
consumerProguardFiles("consumer-rules.pro")
2020
}
@@ -54,30 +54,31 @@ dependencies {
5454
val kotlin_version = "1.9.21"
5555
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
5656
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
57-
implementation("androidx.core:core-ktx:1.12.0")
58-
implementation("androidx.appcompat:appcompat:1.6.1")
59-
implementation("androidx.recyclerview:recyclerview:1.3.2")
60-
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
57+
implementation("androidx.core:core-ktx:1.15.0")
58+
implementation("androidx.appcompat:appcompat:1.7.0")
59+
implementation("androidx.recyclerview:recyclerview:1.4.0")
60+
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
6161
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
6262
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
63-
implementation("com.google.android.material:material:1.11.0")
63+
implementation("com.google.android.material:material:1.12.0")
6464
testImplementation("junit:junit:4.13.2")
65-
androidTestImplementation("androidx.test.ext:junit:1.1.5")
66-
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
65+
androidTestImplementation("androidx.test.ext:junit:1.2.1")
66+
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
6767
// ViewModel
68-
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
69-
implementation("androidx.activity:activity-ktx:1.8.1")
68+
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
69+
implementation("androidx.activity:activity-ktx:1.10.0")
7070
// compose
71-
implementation(platform("androidx.compose:compose-bom:2023.10.01"))
72-
androidTestImplementation(platform("androidx.compose:compose-bom:2023.10.01"))
73-
implementation("androidx.compose.ui:ui:1.6.4")
71+
implementation(platform("androidx.compose:compose-bom:2025.02.00"))
72+
androidTestImplementation(platform("androidx.compose:compose-bom:2025.02.00"))
73+
implementation("androidx.compose.ui:ui:1.7.8")
7474
// Android Studio Preview support
75-
implementation("androidx.compose.ui:ui-tooling-preview:1.6.4")
76-
debugImplementation("androidx.compose.ui:ui-tooling:1.6.4")
75+
implementation("androidx.compose.ui:ui-tooling-preview:1.7.8")
76+
debugImplementation("androidx.compose.ui:ui-tooling:1.7.8")
7777
// UI Tests
7878
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
7979
debugImplementation("androidx.compose.ui:ui-test-manifest")
80-
implementation("androidx.activity:activity-compose:1.8.2")
80+
implementation("androidx.activity:activity-compose:1.10.0")
81+
implementation("com.squareup.okhttp3:okhttp:4.12.0")
8182
}
8283

8384
mavenPublishing {

pdfViewer/src/main/java/com/rajat/pdfviewer/HeaderData.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import android.os.Parcelable
44
import kotlinx.parcelize.Parcelize
55

66
@Parcelize
7-
data class HeaderData(val headers: Map<String, String> = emptyMap()) : Parcelable
7+
data class HeaderData(val headers: Map<String, String> = emptyMap()) : Parcelable

0 commit comments

Comments
 (0)