Skip to content

Commit

Permalink
Update example to PSPDFKit for Android 2024.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit authored and PSPDFKit committed Sep 18, 2024
1 parent 1be5177 commit 496efe2
Show file tree
Hide file tree
Showing 47 changed files with 391 additions and 552 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PSPDFKit for Android Example - Jetpack Compose PDF Viewer
# PSPDFKit for Android Example - Simple Jetpack Compose Example App

An example app demonstrating [PSPDFKit for Android](https://pspdfkit.com/pdf-sdk/android/)'s composable API in the `com.pspdfkit.jetpack.compose` package.
A simple example app demonstrating [PSPDFKit for Android](https://pspdfkit.com/pdf-sdk/android/)'s composable API in the `com.pspdfkit.jetpack.compose` package.

## Prerequisites

Expand Down
12 changes: 5 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.compose")
id("com.google.devtools.ksp")
}

android {
namespace = "com.pspdfkit.example.compose"
namespace = "com.pspdfkit.example"
compileSdk = 35

defaultConfig {
applicationId = namespace
minSdk = 21
minSdk = 31
targetSdk = compileSdk
versionCode = 1
versionName = "1.0"
Expand All @@ -37,9 +38,6 @@ android {
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.14"
}
lint {
warningsAsErrors = true
disable.add("ObsoleteLintCustomCheck")
Expand All @@ -52,7 +50,7 @@ dependencies {

// PSPDFKit is integrated from the PSPDFKit Maven repository. See the `repositories` block at the beginning
// of this file, which shows how to set up the repository in your app.
implementation("com.pspdfkit:pspdfkit:2024.5.1")
implementation("com.pspdfkit:pspdfkit:2024.6.0")


implementation("androidx.datastore:datastore-preferences:1.1.1")
Expand All @@ -66,7 +64,7 @@ dependencies {
implementation("androidx.room:room-ktx:$roomVersion")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.activity:activity-compose:1.9.0")
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
implementation(platform("androidx.compose:compose-bom:2024.09.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
Expand Down
8 changes: 3 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:name=".App"
Expand All @@ -11,8 +10,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Compose"
tools:targetApi="31">
android:theme="@style/Theme.Compose">
<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -25,4 +23,4 @@
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example.compose
package com.pspdfkit.example

import android.app.Application
import com.pspdfkit.example.compose.di.database
import com.pspdfkit.example.compose.di.repository
import com.pspdfkit.example.compose.di.viewModel
import com.pspdfkit.example.di.database
import com.pspdfkit.example.di.repository
import com.pspdfkit.example.di.viewModel
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/com/pspdfkit/example/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright © 2024 PSPDFKit GmbH. All rights reserved.
*
* The PSPDFKit Sample applications are licensed with a modified BSD license.
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import com.pspdfkit.example.ui.components.Root

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { Root() }
}
}
13 changes: 0 additions & 13 deletions app/src/main/java/com/pspdfkit/example/compose/MainActivity.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example.compose.data.local
package com.pspdfkit.example.data.local

import androidx.room.Dao
import androidx.room.Database
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.RoomDatabase
import com.pspdfkit.example.compose.models.HistoryTable
import com.pspdfkit.example.models.HistoryTable
import kotlinx.coroutines.flow.Flow

/** Database class required to hold pdf access history */
@Database(version = 1, entities = [HistoryTable::class])
@Database(version = 1, entities = [HistoryTable::class], exportSchema = false)
abstract class AppDatabase : RoomDatabase() {
abstract fun historyDao(): HistoryDao
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example.compose.data.repository
package com.pspdfkit.example.data.repository

import android.content.Context
import android.graphics.Bitmap
import android.net.Uri
import androidx.collection.LruCache
import androidx.compose.ui.unit.dp
import com.pspdfkit.document.PdfDocumentLoader
import com.pspdfkit.example.compose.utils.calculateBitmapSize
import com.pspdfkit.example.utils.calculateBitmapSize
import com.pspdfkit.utils.Size
import java.io.File
/** Repository to hold all the tasks related to bitmap processing */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example.compose.data.repository
package com.pspdfkit.example.data.repository

import android.content.Context
import com.pspdfkit.example.compose.data.local.HistoryDao
import com.pspdfkit.example.compose.models.HistoryTable
import com.pspdfkit.example.compose.models.HistoryType.LOCAL
import com.pspdfkit.example.compose.models.HistoryType.RECENT
import com.pspdfkit.example.compose.models.local
import com.pspdfkit.example.compose.utils.DEMO_DOCUMENT_ASSET_NAME
import com.pspdfkit.example.compose.utils.copyFile
import com.pspdfkit.example.compose.utils.doesLocalFileExists
import com.pspdfkit.example.compose.utils.getFile
import com.pspdfkit.example.compose.utils.getWorkingDir
import com.pspdfkit.example.data.local.HistoryDao
import com.pspdfkit.example.models.HistoryTable
import com.pspdfkit.example.models.HistoryType.LOCAL
import com.pspdfkit.example.models.HistoryType.RECENT
import com.pspdfkit.example.models.local
import com.pspdfkit.example.utils.DEMO_DOCUMENT_ASSET_NAME
import com.pspdfkit.example.utils.copyFile
import com.pspdfkit.example.utils.doesLocalFileExists
import com.pspdfkit.example.utils.getFile
import com.pspdfkit.example.utils.getWorkingDir
import kotlinx.coroutines.flow.MutableStateFlow

/** [MainRepository] mostly manages all the functions related to Main screen */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example.compose.data.repository
package com.pspdfkit.example.data.repository

import com.pspdfkit.example.compose.data.local.HistoryDao
import com.pspdfkit.example.data.local.HistoryDao

/** [PdfRepository] holds functionality related to pdf. */
class PdfRepository(private val historyDao: HistoryDao) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example.compose.data.repository
package com.pspdfkit.example.data.repository

import android.content.Context
import androidx.datastore.preferences.core.edit
import com.pspdfkit.example.compose.data.local.HistoryDao
import com.pspdfkit.example.compose.utils.dataStore
import com.pspdfkit.example.compose.utils.getWorkingDir
import com.pspdfkit.example.compose.utils.isDarkKey
import com.pspdfkit.example.compose.utils.isDynamicKey
import com.pspdfkit.example.data.local.HistoryDao
import com.pspdfkit.example.utils.dataStore
import com.pspdfkit.example.utils.getWorkingDir
import com.pspdfkit.example.utils.isDarkKey
import com.pspdfkit.example.utils.isDynamicKey

/** [SettingsRepository] contains all the functionality related to settings. */
class SettingsRepository(private val context: Context, private val historyDao: HistoryDao) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* Please see License for details. This notice may not be removed from this file.
*/

package com.pspdfkit.example.compose.di
package com.pspdfkit.example.di

import android.content.Context
import androidx.room.Room
import com.pspdfkit.example.compose.data.local.AppDatabase
import com.pspdfkit.example.compose.data.local.HistoryDao
import com.pspdfkit.example.compose.models.HistoryTable
import com.pspdfkit.example.data.local.AppDatabase
import com.pspdfkit.example.data.local.HistoryDao
import com.pspdfkit.example.models.HistoryTable

/** [getDb] provides [AppDatabase] instance. */
fun getDb(context: Context): AppDatabase {
Expand Down
Loading

0 comments on commit 496efe2

Please sign in to comment.