Skip to content

Commit

Permalink
Merge branch 'release/12.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
panasetskaya committed Feb 4, 2025
2 parents 1a9cdf1 + 03e3dde commit efe83ac
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 11 deletions.
5 changes: 0 additions & 5 deletions app/apollo/apollo-octopus-public/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ hedvig {
mapScalar("Date", "kotlinx.datetime.LocalDate", "com.apollographql.adapter.datetime.KotlinxLocalDateAdapter")
mapScalar("DateTime", "kotlinx.datetime.Instant", "com.apollographql.adapter.datetime.KotlinxInstantAdapter")
mapScalar("Instant", "kotlinx.datetime.Instant", "com.apollographql.adapter.datetime.KotlinxInstantAdapter")
mapScalar(
"Markdown",
"com.hedvig.android.core.markdown.MarkdownString",
"com.hedvig.android.apollo.octopus.MarkdownStringAdapter",
)
mapScalarToKotlinString("UUID")
mapScalarToKotlinString("Url")
mapScalarToKotlinString("FlowContext")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ extend schema

extend type Member @typePolicy(keyFields: "id")

extend type Chat @typePolicy(keyFields: "id")
extend interface ChatMessage @typePolicy(keyFields: "id")
extend type Contract @typePolicy(keyFields: "id")
extend type Claim @typePolicy(keyFields: "id")
Expand Down
2 changes: 1 addition & 1 deletion app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
applicationId = "com.hedvig"

versionCode = 43
versionName = "12.9.9"
versionName = "12.10.0"

vectorDrawables.useSupportLibrary = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import com.hedvig.android.database.di.databaseModule
import com.hedvig.android.datadog.core.addDatadogConfiguration
import com.hedvig.android.datadog.core.di.datadogModule
import com.hedvig.android.datadog.demo.tracking.di.datadogDemoTrackingModule
import com.hedvig.android.design.system.hedvig.pdfrenderer.PdfDecoder
import com.hedvig.android.feature.addon.purchase.di.addonPurchaseModule
import com.hedvig.android.feature.change.tier.di.chooseTierModule
import com.hedvig.android.feature.chat.di.chatModule
Expand Down Expand Up @@ -285,6 +286,7 @@ private val coilModule = module {
} else {
add(GifDecoder.Factory())
}
add(PdfDecoder.Factory())
}.memoryCache {
MemoryCache.Builder(applicationContext).build()
}.diskCache {
Expand Down
2 changes: 1 addition & 1 deletion app/app/src/release/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<string name="APP_NAME" translatable="false">Hedvig</string>

<string name="DEEP_LINK_DOMAIN_HOST_OLD" translatable="false">hedvig.page.link</string>
<string name="DEEP_LINK_DOMAIN_HOST" translatable="false">hedvig.com</string>
<string name="DEEP_LINK_DOMAIN_HOST" translatable="false">www.hedvig.com</string>

<string name="OCTOPUS_GRAPHQL_URL" translatable="false">https://apollo-router.prod.hedvigit.com</string>
<string name="WEB_BASE_URL" translatable="false">https://www.hedvig.com</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.hedvig.android.design.system.hedvig.pdfrenderer

import android.graphics.Bitmap
import android.graphics.pdf.PdfRenderer
import android.os.ParcelFileDescriptor
import androidx.core.graphics.drawable.toDrawable
import coil.ImageLoader
import coil.decode.DecodeResult
import coil.decode.Decoder
import coil.decode.ImageSource
import coil.fetch.SourceResult
import coil.request.Options

class PdfDecoder(
private val source: ImageSource,
private val options: Options,
) : Decoder {
override suspend fun decode(): DecodeResult {
val context = options.context
val pdfRenderer = PdfRenderer(
ParcelFileDescriptor.open(
source.file().toFile(),
ParcelFileDescriptor.MODE_READ_ONLY,
),
)
val page = pdfRenderer.openPage(0)

val bitmap = Bitmap.createBitmap(
page.width * 2,
page.height * 2,
Bitmap.Config.ARGB_8888,
)
page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY)
page.close()
pdfRenderer.close()

return DecodeResult(
drawable = bitmap.toDrawable(context.resources),
isSampled = false,
)
}

class Factory : Decoder.Factory {
override fun create(result: SourceResult, options: Options, imageLoader: ImageLoader): Decoder? {
if (!isApplicable(result)) return null
return PdfDecoder(result.source, options)
}

private fun isApplicable(result: SourceResult): Boolean = result.mimeType == MIME_TYPE_PDF
}

companion object {
private const val MIME_TYPE_PDF = "application/pdf"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,17 @@ private fun ChatBubble(
)
}

CbmChatMessage.ChatMessageFile.MimeType.PDF, // todo chat: consider rendering PDFs inline in the chat
CbmChatMessage.ChatMessageFile.MimeType.PDF -> {
ChatAsyncImage(
model = chatMessage.url,
imageLoader = imageLoader,
cacheKey = chatMessage.id,
modifier = Modifier.clickable {
openUrl(chatMessage.url)
},
)
}

CbmChatMessage.ChatMessageFile.MimeType.MP4, // todo chat: consider rendering videos inline in the chat
CbmChatMessage.ChatMessageFile.MimeType.OTHER,
-> {
Expand All @@ -458,7 +468,11 @@ private fun ChatBubble(
}

is CbmChatMessage.ChatMessageGif -> {
ChatAsyncImage(model = chatMessage.gifUrl, imageLoader = imageLoader, cacheKey = chatMessage.gifUrl)
ChatAsyncImage(
model = chatMessage.gifUrl,
imageLoader = imageLoader,
cacheKey = chatMessage.gifUrl,
)
}

is CbmChatMessage.FailedToBeSent -> {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ coil = "2.7.0"
composeRichtext = "1.0.0-alpha02"
coreLibraryDesugaring = "2.1.4"
coroutines = "1.10.1"
datadog = "2.17.0"
datadog = "2.18.0"
dependencyAnalysis = "2.8.0"
firebaseCrashlyticsBuildtools = "3.0.2"
hedvigAuthlib = "1.4.3"
Expand Down

0 comments on commit efe83ac

Please sign in to comment.