Skip to content

Commit

Permalink
Update example to Nutrient for Android 2024.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutrient authored and Nutrient committed Nov 21, 2024
1 parent 6733209 commit 7f0b5ec
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ android {

dependencies {

// PSPDFKit is integrated from the PSPDFKit Maven repository. See the `repositories` block at the beginning
// Nutrient is integrated from the Nutrient 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.7.0")
implementation("com.pspdfkit:pspdfkit:2024.8.0")


implementation("androidx.datastore:datastore-preferences:1.1.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@ import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.outlined.Square
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
Expand All @@ -44,6 +50,7 @@ import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import com.pspdfkit.compose.theme.MainToolbarColors
import com.pspdfkit.compose.theme.ToolbarPopupColors
import com.pspdfkit.compose.theme.UiTheme
import com.pspdfkit.compose.theme.getUiColors
import com.pspdfkit.configuration.activity.PdfActivityConfiguration
import com.pspdfkit.configuration.activity.UserInterfaceViewMode
Expand Down Expand Up @@ -92,7 +99,7 @@ fun PdfUI(pdf: File, context: Context, theme: Int, isDark: Boolean, navigateTo:
val localDensity = LocalDensity.current
val pdfActivityConfiguration = PdfActivityConfiguration
.Builder(context)
.disableDefaultToolbar()
.defaultToolbarEnabled(false)
.setUserInterfaceViewMode(UserInterfaceViewMode.USER_INTERFACE_VIEW_MODE_AUTOMATIC)
.themeMode(ThemeMode.DEFAULT)
.themeDark(R.style.PSPDFCompose_Theme_Dark)
Expand Down Expand Up @@ -150,6 +157,29 @@ fun PdfUI(pdf: File, context: Context, theme: Int, isDark: Boolean, navigateTo:
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back", tint = it)
}
},
overFlowActions = {
Row(
Modifier.clickable {
documentState.documentConnection.showToolbarMenu.invoke(false)
Toast.makeText(context, "Custom Action Button Clicked", Toast.LENGTH_LONG).show()
}.padding(horizontal = 16.dp, vertical = 13.dp)
) {
Icon(imageVector = Icons.Outlined.Square, contentDescription = "Custom Action", tint = it)
Spacer(modifier = Modifier.width(8.dp))
Text(text = "Custom Action", color = UiTheme.colors.mainToolbar.textColor)
}
/*
For Material 2 use this
DropdownMenuItem(onClick = {
documentState.documentConnection.showToolbarMenu.invoke(false)
Toast.makeText(context, "Custom Action Button Clicked", Toast.LENGTH_LONG).show()
}) {
Icon(imageVector = Icons.Outlined.Square, contentDescription = "Custom Action", tint = it)
Spacer(modifier = Modifier.width(8.dp))
Text(text = "Custom Action", color = UiTheme.colors.mainToolbar.textColor)
}
*/
},
onHeightChanged = { height ->
toolbarHeight = with(localDensity) { height.toDp() }
}
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
// The PSPDFKit library is loaded from the PSPDFKit Maven repository, added by this configuration.
maven(url = "https://customers.pspdfkit.com/maven/")
// The Nutrient library is loaded from the Nutrient Maven repository, added by this configuration.
maven(url = "https://my.nutrient.io/maven/")
}

versionCatalogs {
Expand Down

0 comments on commit 7f0b5ec

Please sign in to comment.