Skip to content

Commit 4f53175

Browse files
committed
Simplified the isRtlQuote method.
1 parent 8e50737 commit 4f53175

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/spans/AztecQuoteSpan.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import android.graphics.Canvas
2121
import android.graphics.Color
2222
import android.graphics.Paint
2323
import android.graphics.Rect
24+
import android.support.v4.text.TextDirectionHeuristicCompat
2425
import android.support.v4.text.TextDirectionHeuristicsCompat
2526
import android.support.v4.text.TextUtilsCompat
2627
import android.support.v4.view.ViewCompat
2728
import android.text.Layout
2829
import android.text.Spanned
29-
import android.text.TextUtils
3030
import android.text.style.LineBackgroundSpan
3131
import android.text.style.LineHeightSpan
3232
import android.text.style.QuoteSpan
@@ -126,11 +126,13 @@ class AztecQuoteSpan(
126126
}
127127

128128
private fun isRtlQuote(text: CharSequence, start: Int, end: Int): Boolean {
129-
return if (start == end || TextUtils.isEmpty(text) || text.substring(start, end) == "\n") {
130-
TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL
131-
} else {
132-
TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR.isRtl(text, start, end - start)
133-
}
129+
val textDirectionHeuristic: TextDirectionHeuristicCompat =
130+
if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL) {
131+
TextDirectionHeuristicsCompat.FIRSTSTRONG_RTL
132+
} else {
133+
TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR
134+
}
135+
return textDirectionHeuristic.isRtl(text, start, end - start)
134136
}
135137

136138
}

0 commit comments

Comments
 (0)