@@ -678,9 +678,9 @@ internal data class DiffStyle(
678678 fallback.fileHeaderHorizontalPaddingPx,
679679 density,
680680 ),
681- codeFontSizePx = json.floatSp (" codeFontSize" , fallback.codeFontSizePx, density),
681+ codeFontSizePx = json.floatDp (" codeFontSize" , fallback.codeFontSizePx, density),
682682 codeFontWeight = json.optString(" codeFontWeight" , fallback.codeFontWeight),
683- lineNumberFontSizePx = json.floatSp (
683+ lineNumberFontSizePx = json.floatDp (
684684 " lineNumberFontSize" ,
685685 fallback.lineNumberFontSizePx,
686686 density,
@@ -689,9 +689,9 @@ internal data class DiffStyle(
689689 " lineNumberFontWeight" ,
690690 fallback.lineNumberFontWeight,
691691 ),
692- hunkFontSizePx = json.floatSp (" hunkFontSize" , fallback.hunkFontSizePx, density),
692+ hunkFontSizePx = json.floatDp (" hunkFontSize" , fallback.hunkFontSizePx, density),
693693 hunkFontWeight = json.optString(" hunkFontWeight" , fallback.hunkFontWeight),
694- fileHeaderFontSizePx = json.floatSp (
694+ fileHeaderFontSizePx = json.floatDp (
695695 " fileHeaderFontSize" ,
696696 fallback.fileHeaderFontSizePx,
697697 density,
@@ -700,7 +700,7 @@ internal data class DiffStyle(
700700 " fileHeaderFontWeight" ,
701701 fallback.fileHeaderFontWeight,
702702 ),
703- fileHeaderMetaFontSizePx = json.floatSp (
703+ fileHeaderMetaFontSizePx = json.floatDp (
704704 " fileHeaderMetaFontSize" ,
705705 fallback.fileHeaderMetaFontSizePx,
706706 density,
@@ -709,7 +709,7 @@ internal data class DiffStyle(
709709 " fileHeaderMetaFontWeight" ,
710710 fallback.fileHeaderMetaFontWeight,
711711 ),
712- fileHeaderSubtextFontSizePx = json.floatSp (
712+ fileHeaderSubtextFontSizePx = json.floatDp (
713713 " fileHeaderSubtextFontSize" ,
714714 fallback.fileHeaderSubtextFontSizePx,
715715 density,
@@ -977,11 +977,7 @@ private class DiffCanvasView(context: Context) : View(context) {
977977 private fun rowHeight (row : DiffRow ): Int = when (row.kind) {
978978 " file" -> style.fileHeaderHeightPx.toInt()
979979 " notice" -> max((style.rowHeightPx * 2f ).toInt(), (44 * density).toInt())
980- " comment" -> if (collapsedCommentIds.contains(row.id)) {
981- (44 * density).toInt()
982- } else {
983- (124 * density).toInt()
984- }
980+ " comment" -> drawing.commentRowHeight(style, collapsedCommentIds.contains(row.id))
985981 " line" -> codeWrap.rowHeight(row, style.rowHeightPx.toInt())
986982 else -> style.rowHeightPx.toInt()
987983 }.coerceAtLeast(1 )
@@ -1108,6 +1104,10 @@ private class DiffCanvasView(context: Context) : View(context) {
11081104 val pathX = iconRect.right + 10f * density
11091105 val pathWidth = max(24f * density, countsX - pathX - 12f * density)
11101106 val centerY = (top + bottom) / 2f
1107+ val pathHeight = max(
1108+ 20f * density,
1109+ ceil(boldTextPaint.fontMetrics.descent - boldTextPaint.fontMetrics.ascent),
1110+ )
11111111 val displayPath = if (
11121112 ! row.previousPath.isNullOrEmpty() && row.previousPath != row.filePath
11131113 ) {
@@ -1117,7 +1117,7 @@ private class DiffCanvasView(context: Context) : View(context) {
11171117 }
11181118 return FileHeaderPathLayout (
11191119 displayPath = displayPath,
1120- rect = RectF (pathX, centerY - 10f * density , pathX + pathWidth, centerY + 10f * density ),
1120+ rect = RectF (pathX, centerY - pathHeight / 2f , pathX + pathWidth, centerY + pathHeight / 2f ),
11211121 )
11221122 }
11231123
@@ -1223,11 +1223,17 @@ private class DiffCanvasView(context: Context) : View(context) {
12231223 borderPaint.style = Paint .Style .FILL
12241224
12251225 val collapsed = collapsedCommentIds.contains(row.id)
1226+ val metrics = drawing.commentTextMetrics(style)
1227+ val titleBaseline = drawing.commentTitleBaseline(metrics)
1228+ val chevronTop = max(
1229+ 11f * density,
1230+ titleBaseline + (metrics.ascent + metrics.descent) / 2f - 8f * density
1231+ )
12261232 val chevronRect = RectF (
12271233 cardRect.left + 10f * density,
1228- cardRect.top + 11f * density ,
1234+ cardRect.top + chevronTop ,
12291235 cardRect.left + 26f * density,
1230- cardRect.top + 27f * density,
1236+ cardRect.top + chevronTop + 16f * density,
12311237 )
12321238 drawing.drawDisclosureChevron(canvas, chevronRect, theme.mutedText, collapsed)
12331239 drawing.configureUiPaint(
@@ -1240,7 +1246,7 @@ private class DiffCanvasView(context: Context) : View(context) {
12401246 canvas.drawText(
12411247 ellipsize(title, textPaint, cardRect.right - chevronRect.right - 20f * density),
12421248 chevronRect.right + 10f * density,
1243- cardRect.top + 22f * density ,
1249+ cardRect.top + titleBaseline ,
12441250 textPaint,
12451251 )
12461252 if (! collapsed) {
@@ -1253,7 +1259,7 @@ private class DiffCanvasView(context: Context) : View(context) {
12531259 cardRect.right - bodyX - 18f * density
12541260 ),
12551261 bodyX,
1256- cardRect.top + 58f * density ,
1262+ cardRect.top + drawing.commentBodyBaseline(metrics) ,
12571263 textPaint,
12581264 )
12591265 }
@@ -1541,9 +1547,6 @@ private fun JSONObject.optNullableInt(key: String): Int? =
15411547private fun JSONObject.floatDp (key : String , fallbackPx : Float , density : Float ): Float =
15421548 if (has(key)) optDouble(key).toFloat() * density else fallbackPx
15431549
1544- private fun JSONObject.floatSp (key : String , fallbackPx : Float , density : Float ): Float =
1545- if (has(key)) optDouble(key).toFloat() * density else fallbackPx
1546-
15471550@Suppress(" ReturnCount" )
15481551private fun rowIndexAtOffset (y : Int , rowOffsets : IntArray , rowCount : Int ): Int {
15491552 if (rowCount == 0 ) return 0
0 commit comments