@@ -177,16 +177,15 @@ abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter
177177 tvLineContent.typeface = options.font
178178
179179 val isLine = viewType == ViewHolderType .Line .viewType
180- val viewHeight = if (isLine) R .dimen.line_height else R .dimen.line_border_height
181- lineView.layoutParams.height = context.resources.getDimension(viewHeight).toInt()
182-
183- if (isLine) {
180+ options.format.apply {
181+ val height = if (isLine) lineHeight else borderHeight
182+ lineView.layoutParams.height = dpToPx(context, height)
183+ }
184+ return if (isLine) {
184185 val holder = LineViewHolder (lineView)
185186 holder.setIsRecyclable(false )
186- return holder
187- } else {
188- return BorderViewHolder (lineView)
189- }
187+ holder
188+ } else BorderViewHolder (lineView)
190189 }
191190
192191 override fun onBindViewHolder (holder : ViewHolder , pos : Int ) {
@@ -213,14 +212,17 @@ abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter
213212
214213 @SuppressLint(" SetTextI18n" )
215214 private fun setupLine (pos : Int , line : String , holder : ViewHolder ) {
215+ val fontSize = options.format.fontSize
216+
217+ holder.tvLineContent.textSize = fontSize
216218 holder.tvLineContent.text = html(line)
217219 holder.tvLineContent.setTextColor(options.theme.noteColor.color())
218220
219221 if (options.shortcut && pos == MaxShortcutLines ) {
220- holder.tvLineNum.textSize = 10f
222+ holder.tvLineNum.textSize = fontSize * Format . ShortcutScale
221223 holder.tvLineNum.text = context.getString(R .string.dots)
222224 } else {
223- holder.tvLineNum.textSize = 12f
225+ holder.tvLineNum.textSize = fontSize
224226 holder.tvLineNum.text = " ${pos + 1 } "
225227 }
226228 }
@@ -313,6 +315,7 @@ data class Options(
313315 var language : String? = null ,
314316 var theme : ColorThemeData = ColorTheme .DEFAULT .theme(),
315317 var font : Typeface = FontCache .get(context).getTypeface(context),
318+ var format : Format = Format .Compact ,
316319 var shadows : Boolean = false ,
317320 var shortcut : Boolean = false ,
318321 var shortcutNote : String = context.getString(R .string.show_all),
@@ -401,3 +404,21 @@ data class Options(
401404 fun get (context : Context ) = Options (context)
402405 }
403406}
407+
408+ data class Format (val scaleFactor : Float = 1f ,
409+ val lineHeight : Int = (LineHeight * scaleFactor).toInt(),
410+ val borderHeight : Int = (BorderHeight * scaleFactor).toInt(),
411+ val fontSize : Float = FontSize .toFloat()) {
412+
413+ companion object Default {
414+ private const val LineHeight = 18
415+ private const val BorderHeight = 3
416+ private const val FontSize = 12
417+
418+ internal const val ShortcutScale = 0.83f
419+
420+ val ExtraCompact = Format (0.88f )
421+ val Compact = Format ()
422+ val Medium = Format (1.33f )
423+ }
424+ }
0 commit comments