Skip to content

Commit

Permalink
Potential fix and extra logging for crash on the PDF Screen "width an…
Browse files Browse the repository at this point in the history
…d height must be > 0".

Upping versionCode to 55
  • Loading branch information
Dima-Android committed Apr 1, 2024
1 parent ddd7f65 commit 8e13b93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import androidx.fragment.app.FragmentContainerView
import com.pspdfkit.ui.PdfThumbnailBar
import org.zotero.android.R
import org.zotero.android.architecture.ui.CustomLayoutSize
import timber.log.Timber

@Composable
fun PdfReaderPspdfKitView(uri: Uri, viewModel: PdfReaderViewModel) {
val activity = LocalContext.current as? AppCompatActivity ?: return
val annotationMaxSideSize = annotationMaxSideSize()
val fragmentManager = activity.supportFragmentManager
val layoutType = CustomLayoutSize.calculateLayoutType()
viewModel.annotationMaxSideSize = annotationMaxSideSize
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
Expand Down Expand Up @@ -60,10 +62,24 @@ fun PdfReaderPspdfKitView(uri: Uri, viewModel: PdfReaderViewModel) {

@Composable
private fun annotationMaxSideSize(): Int {
val layoutType = CustomLayoutSize.calculateLayoutType()
val context = LocalContext.current
val outValue = TypedValue()
context.resources.getValue(R.dimen.pdf_sidebar_width_percent, outValue, true)
val sidebarWidthPercentage = outValue.float
val annotationSize = Resources.getSystem().displayMetrics.widthPixels * sidebarWidthPercentage
return annotationSize.toInt()
val metricsWidthPixels = Resources.getSystem().displayMetrics.widthPixels
val annotationSize = metricsWidthPixels * sidebarWidthPercentage
val result = annotationSize.toInt()
if (result <= 0) {
val errorMessage = "PdfReaderPspdfKitView annotationMaxSideSize is $result" +
".sidebarWidthPercentage = $sidebarWidthPercentage" +
".metricsWidthPixels = $metricsWidthPixels"
Timber.e(errorMessage)
return if (layoutType.isTablet()) {
480
} else {
1080
}
}
return result
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 33

val versionCode = 54 // Must be updated on every build
val versionCode = 55 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 8e13b93

Please sign in to comment.