Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't allow DrawView to resize
  • Loading branch information
seadowg committed Mar 11, 2026
commit 821e2958f70e2c79a34fadd48a1a0a4adf321c54
10 changes: 7 additions & 3 deletions draw/src/main/java/org/odk/collect/draw/DrawView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DrawView(context: Context, attrs: AttributeSet?) : View(context, attrs) {

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
resetImage(w, h)
setImage(w, h)
}

override fun onDraw(canvas: Canvas) {
Expand Down Expand Up @@ -107,7 +107,7 @@ class DrawView(context: Context, attrs: AttributeSet?) : View(context, attrs) {

fun reset() {
val metrics = resources.displayMetrics
resetImage(metrics.widthPixels, metrics.heightPixels)
setImage(metrics.widthPixels, metrics.heightPixels)
}

fun setColor(color: Int) {
Expand Down Expand Up @@ -168,7 +168,11 @@ class DrawView(context: Context, attrs: AttributeSet?) : View(context, attrs) {
paint.color = originalColor
}

private fun resetImage(w: Int, h: Int) {
private fun setImage(w: Int, h: Int) {
if (::bitmap.isInitialized) {
return
}

val backgroundBitmapFile = File(imagePath)
if (backgroundBitmapFile.exists()) {
bitmap = ImageFileUtils.getBitmapScaledToDisplay(backgroundBitmapFile, h, w, true)!!
Expand Down