Skip to content

Commit

Permalink
Bugfixes for underline and freeText annotation sync.
Browse files Browse the repository at this point in the history
Hiding incomplete underline and text annotations UI from sidebar.

Upping versionCode to 100
  • Loading branch information
Dima-Android committed Sep 16, 2024
1 parent 2f45aff commit ec394d8
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.zotero.android.database.objects

enum class AnnotationType(val str: String) {
note(""),
highlight(""),
image(""),
ink(""),
underline(""),
freeText("text");
enum class AnnotationType() {
note,
highlight,
image,
ink,
underline,
text;


val kind: com.pspdfkit.annotations.AnnotationType
Expand All @@ -17,7 +17,7 @@ enum class AnnotationType(val str: String) {
image -> com.pspdfkit.annotations.AnnotationType.SQUARE
ink -> com.pspdfkit.annotations.AnnotationType.INK
underline -> com.pspdfkit.annotations.AnnotationType.UNDERLINE
freeText -> com.pspdfkit.annotations.AnnotationType.FREETEXT
text -> com.pspdfkit.annotations.AnnotationType.FREETEXT
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ object AnnotationsConfig {
AnnotationType.HIGHLIGHT,
AnnotationType.SQUARE,
AnnotationType.INK,
AnnotationType.UNDERLINE,
AnnotationType.FREETEXT,
// AnnotationType.UNDERLINE,
// AnnotationType.FREETEXT,
)
val keyKey = "Zotero:Key"
val noteAnnotationSize = Pair(22F, 22F)
Expand Down Expand Up @@ -65,7 +65,7 @@ object AnnotationsConfig {

fun colors(type: org.zotero.android.database.objects.AnnotationType): List<String> {
return when (type) {
org.zotero.android.database.objects.AnnotationType.ink, org.zotero.android.database.objects.AnnotationType.freeText -> {
org.zotero.android.database.objects.AnnotationType.ink, org.zotero.android.database.objects.AnnotationType.text -> {
listOf(
"#ffd400",
"#ff6666",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class FieldKeys {
KeyBaseKeyPair(key = sortIndex, baseKey = null),
)
}
AnnotationType.freeText -> {
AnnotationType.text -> {
return listOf(
KeyBaseKeyPair(key = type, baseKey = null),
KeyBaseKeyPair(key = comment, baseKey = null),
Expand Down Expand Up @@ -241,7 +241,7 @@ class FieldKeys {
)
}

AnnotationType.freeText -> {
AnnotationType.text -> {
return listOf(
KeyBaseKeyPair(key = Companion.type, baseKey = null),
KeyBaseKeyPair(key = comment, baseKey = null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ open class RItem : Updatable, Deletable, Syncable, RealmObject() {
jsonData[FieldKeys.Item.Annotation.Position.paths] = apiPaths
}

AnnotationType.highlight, AnnotationType.image, AnnotationType.note, AnnotationType.underline, AnnotationType.freeText -> {
AnnotationType.highlight, AnnotationType.image, AnnotationType.note, AnnotationType.underline, AnnotationType.text -> {
val rectArray = mutableListOf<List<Double>>()
this.rects.forEach { rRect ->
rectArray.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ReadAnnotationsDbRequest(
.parent(this.attachmentKey, this.libraryId)
.items(type = ItemTypes.annotation, notSyncState = ObjectSyncState.dirty)
.deleted(false)
.rawPredicate("annotationType in %@", supportedTypes)
.`in`("annotationType", supportedTypes.toTypedArray())
.sort("annotationSortIndex", Sort.ASCENDING)
.findAll()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal fun PdfAnnotationHeaderRow(
AnnotationType.image -> Drawables.area_large
AnnotationType.ink -> Drawables.ink_large
AnnotationType.underline -> Drawables.ink_large // TODO set correct icon
AnnotationType.freeText -> Drawables.ink_large// TODO set correct icon
AnnotationType.text -> Drawables.ink_large// TODO set correct icon
}
Box(modifier = Modifier.fillMaxWidth()) {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface PDFAnnotation {

}

AnnotationType.note, AnnotationType.highlight, AnnotationType.image, AnnotationType.underline, AnnotationType.freeText -> {
AnnotationType.note, AnnotationType.highlight, AnnotationType.image, AnnotationType.underline, AnnotationType.text -> {
val rects = rects(boundingBoxConverter = boundingBoxConverter)
if (rects.size == 1) {
return rects[0].rounded(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ class PdfReaderViewModel @Inject constructor(
return false
}
}
org.zotero.android.database.objects.AnnotationType.freeText -> {
org.zotero.android.database.objects.AnnotationType.text -> {
if (databaseAnnotation.item.rects.isEmpty()) {
Timber.i("PDFReaderActionHandler: ${databaseAnnotation.type} annotation ${databaseAnnotation.key} missing rects")
return false
Expand Down Expand Up @@ -1677,7 +1677,7 @@ class PdfReaderViewModel @Inject constructor(
}
}

org.zotero.android.database.objects.AnnotationType.image, org.zotero.android.database.objects.AnnotationType.freeText -> {
org.zotero.android.database.objects.AnnotationType.image, org.zotero.android.database.objects.AnnotationType.text -> {
val newBoundingBox =
annotation.boundingBox(boundingBoxConverter = annotationBoundingBoxConverter)
if (pdfAnnotation.boundingBox.rounded(3) != newBoundingBox) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal fun PdfReaderAnnotationsSidebarHeaderSection(
AnnotationType.image -> Drawables.area_large
AnnotationType.ink -> Drawables.ink_large
AnnotationType.underline -> Drawables.ink_large //TODO correct icon
AnnotationType.freeText -> Drawables.ink_large //TODO correct icon
AnnotationType.text -> Drawables.ink_large //TODO correct icon
}
Row(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class AnnotationConverter {
alpha = alpha,
boundingBoxConverter = boundingBoxConverter
)
AnnotationType.freeText -> annotation = freeTextAnnotation(
AnnotationType.text -> annotation = freeTextAnnotation(
zoteroAnnotation,
color = color,
boundingBoxConverter = boundingBoxConverter
Expand Down Expand Up @@ -366,7 +366,7 @@ class AnnotationConverter {
text = underlineAnnotation.highlightedText
paths = emptyList()
} else if (freeTextAnnotation != null) {
type = AnnotationType.freeText
type = AnnotationType.text
fontSize = annotation.textSize
rotation = annotation.rotation
paths = emptyList()
Expand Down
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 = 34

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

0 comments on commit ec394d8

Please sign in to comment.