Skip to content

Commit 44931bc

Browse files
committed
refactor: add underline util
1 parent 77e7c76 commit 44931bc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/StudyCountsView.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import android.widget.LinearLayout
2424
import android.widget.TextView
2525
import com.ichi2.anki.databinding.ViewStudyCountsBinding
2626
import com.ichi2.anki.libanki.sched.Counts
27+
import com.ichi2.utils.UiUtil
2728

2829
/**
2930
* Displays New, Learn, and Review counts.
@@ -47,9 +48,7 @@ class StudyCountsView : LinearLayout {
4748
}
4849
text =
4950
if (counts.activeQueue == queue) {
50-
SpannableString(newText).apply {
51-
setSpan(UnderlineSpan(), 0, length, 0)
52-
}
51+
UiUtil.underline(newText)
5352
} else {
5453
newText
5554
}

AnkiDroid/src/main/java/com/ichi2/utils/UiUtil.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package com.ichi2.utils
1818
import android.app.Dialog
1919
import android.graphics.Typeface
2020
import android.text.Spannable
21+
import android.text.SpannableString
2122
import android.text.SpannableStringBuilder
2223
import android.text.style.StyleSpan
24+
import android.text.style.UnderlineSpan
2325
import android.view.ViewGroup
2426
import android.widget.Spinner
2527

@@ -30,6 +32,11 @@ object UiUtil {
3032
return str
3133
}
3234

35+
fun underline(string: String): Spannable =
36+
SpannableString(string).apply {
37+
setSpan(UnderlineSpan(), 0, length, 0)
38+
}
39+
3340
fun Spinner.setSelectedValue(value: Any?) {
3441
for (position in 0 until this.adapter.count) {
3542
if (this.adapter.getItem(position) != value) continue

0 commit comments

Comments
 (0)