Skip to content

Commit dae0857

Browse files
chore(deps): bump the gradle-minor-and-patch group with 3 updates (#2465)
* chore(deps): bump the gradle-minor-and-patch group with 3 updates Bumps the gradle-minor-and-patch group with 3 updates: [gradle-wrapper](https://github.com/gradle/gradle), com.android.application and com.android.library. Updates `gradle-wrapper` from 9.8.1 to 9.8.2 - [Release notes](https://github.com/gradle/gradle/releases) - [Commits](gradle/gradle@v9.8.1...v9.8.2) Updates `com.android.application` from 9.4.1 to 9.5.0 Updates `com.android.library` from 9.4.1 to 9.5.0 Updates `com.android.library` from 9.4.1 to 9.5.0 --- updated-dependencies: - dependency-name: gradle-wrapper dependency-version: 9.8.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: gradle-minor-and-patch - dependency-name: com.android.application dependency-version: 9.5.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: gradle-minor-and-patch - dependency-name: com.android.library dependency-version: 9.5.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: gradle-minor-and-patch - dependency-name: com.android.library dependency-version: 9.5.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: gradle-minor-and-patch ... Signed-off-by: dependabot[bot] <support@github.com> * fix(reviewer): save review screenshots off the main thread AGP 9.5 lint flags the bitmap write in the Save buttons (ThreadConstraint). The repository now writes the PNG on its IO scope before saving the evaluation. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Enrique López Mañas <eenriquelopez@gmail.com>
1 parent d6fb811 commit dae0857

4 files changed

Lines changed: 22 additions & 21 deletions

File tree

‎ApiDemos/project/reviewer/src/main/java/com/example/reviewer/repository/SampleReviewRepository.kt‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import android.app.Activity
2020
import android.content.ActivityNotFoundException
2121
import android.content.Context
2222
import android.content.Intent
23+
import android.graphics.Bitmap
2324
import android.util.Log
2425
import android.widget.Toast
2526
import com.example.common_ui.catalog.Framework
@@ -32,6 +33,7 @@ import com.example.reviewer.compose.ReviewerActivity
3233
import com.example.reviewer.db.SampleCatalogDatabase
3334
import com.example.reviewer.db.SampleEvaluationDao
3435
import com.example.reviewer.db.SampleEvaluationEntity
36+
import com.example.reviewer.ui.ScreenCaptureHelper
3537
import kotlinx.coroutines.CoroutineScope
3638
import kotlinx.coroutines.Dispatchers
3739
import kotlinx.coroutines.SupervisorJob
@@ -131,16 +133,27 @@ class SampleReviewRepository private constructor(
131133
}
132134
}
133135

136+
/**
137+
* Saves an evaluation in the background. A [screenshot] is written to a PNG file off the
138+
* main thread first, and its path takes the place of [screenshotPath].
139+
*/
134140
fun saveEvaluation(
135141
targetFqcn: String,
136142
status: ReviewStatus,
137143
notes: String,
138144
metadata: SampleItem,
139145
screenshotPath: String? = null,
146+
screenshot: Bitmap? = null,
140147
onComplete: (() -> Unit)? = null,
141148
) {
142149
coroutineScope.launch {
143-
saveEvaluationDirect(targetFqcn, status, notes, metadata, screenshotPath, syncToCounterpart = true)
150+
val ctx = context
151+
val path = if (screenshot != null && ctx != null) {
152+
ScreenCaptureHelper.saveBitmap(ctx, screenshot, metadata.id).absolutePath
153+
} else {
154+
screenshotPath
155+
}
156+
saveEvaluationDirect(targetFqcn, status, notes, metadata, path, syncToCounterpart = true)
144157
withContext(Dispatchers.Main) {
145158
onComplete?.invoke()
146159
}

‎ApiDemos/project/reviewer/src/main/java/com/example/reviewer/ui/ReviewEvaluationDialog.kt‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -480,15 +480,9 @@ object ReviewEvaluationDialog {
480480
layoutParams = params
481481
setOnClickListener {
482482
val notes = input.text.toString().trim()
483-
var screenshotPath: String? = null
484-
if (canvasView != null) {
485-
val finalBitmap = canvasView.createAnnotatedBitmap() ?: capturedBitmap
486-
if (finalBitmap != null) {
487-
val savedFile = ScreenCaptureHelper.saveBitmap(activity, finalBitmap, sample.id)
488-
screenshotPath = savedFile.absolutePath
489-
}
490-
}
491-
repository.saveEvaluation(targetFqcn, status, notes, sample, screenshotPath) {
483+
// The PNG is written by the repository on its IO scope, not on the main thread.
484+
val screenshot = canvasView?.let { it.createAnnotatedBitmap() ?: capturedBitmap }
485+
repository.saveEvaluation(targetFqcn, status, notes, sample, screenshot = screenshot) {
492486
dialog.dismiss()
493487
showUndoSnackbar(activity, targetFqcn, sample, framework, status, repository)
494488
}
@@ -507,15 +501,9 @@ object ReviewEvaluationDialog {
507501
layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1.35f)
508502
setOnClickListener {
509503
val notes = input.text.toString().trim()
510-
var screenshotPath: String? = null
511-
if (canvasView != null) {
512-
val finalBitmap = canvasView.createAnnotatedBitmap() ?: capturedBitmap
513-
if (finalBitmap != null) {
514-
val savedFile = ScreenCaptureHelper.saveBitmap(activity, finalBitmap, sample.id)
515-
screenshotPath = savedFile.absolutePath
516-
}
517-
}
518-
repository.saveEvaluation(targetFqcn, status, notes, sample, screenshotPath) {
504+
// The PNG is written by the repository on its IO scope, not on the main thread.
505+
val screenshot = canvasView?.let { it.createAnnotatedBitmap() ?: capturedBitmap }
506+
repository.saveEvaluation(targetFqcn, status, notes, sample, screenshot = screenshot) {
519507
dialog.dismiss()
520508
advanceToNextUnchecked(activity, sample, framework, repository)
521509
}

‎gradle/libs.versions.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
# Project Configuration
3-
androidGradlePlugin = "9.4.1"
3+
androidGradlePlugin = "9.5.0"
44
minSdk = "24"
55
compileSdk = "37"
66
targetSdk = "37"

‎gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip
44
networkTimeout=10000
55
retries=0
66
retryBackOffMs=500

0 commit comments

Comments
 (0)