diff --git a/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt b/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt index 05a3ef7618..f5ddfb93af 100644 --- a/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt +++ b/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt @@ -129,8 +129,9 @@ class BcSmartspaceCard @JvmOverloads constructor( fun setTitle(title: CharSequence?, contentDescription: CharSequence?, hasIcon: Boolean) { val titleView = titleTextView ?: return - val isRTL = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL - titleView.textAlignment = if (isRTL) TEXT_ALIGNMENT_TEXT_END else TEXT_ALIGNMENT_TEXT_START + val isRtlLayout = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL + val isRtlText = isStringRTL(title.toString()) + titleView.textAlignment = if (isRtlLayout && !isRtlText) TEXT_ALIGNMENT_TEXT_END else TEXT_ALIGNMENT_TEXT_START titleView.text = title titleView.setCompoundDrawablesRelative( if (hasIcon) iconDrawable else null, null, @@ -148,6 +149,14 @@ class BcSmartspaceCard @JvmOverloads constructor( } } + private fun isStringRTL(string: String): Boolean { + if (TextUtils.isEmpty(string)) { + return false + } + val c = string[0] + return c.code in 0x590..0x6ff + } + private fun setSubtitle(subtitle: CharSequence?, charSequence2: CharSequence?) { val subtitleView = subtitleTextView ?: return subtitleView.text = subtitle diff --git a/lawnchair/src/app/lawnchair/smartspace/IcuDateTextView.kt b/lawnchair/src/app/lawnchair/smartspace/IcuDateTextView.kt index 7f669b7a93..5ee285d227 100644 --- a/lawnchair/src/app/lawnchair/smartspace/IcuDateTextView.kt +++ b/lawnchair/src/app/lawnchair/smartspace/IcuDateTextView.kt @@ -61,7 +61,6 @@ class IcuDateTextView @JvmOverloads constructor( if (isShown) { val timeText = getTimeText(updateFormatter) if (text != timeText) { - textAlignment = if (shouldAlignToTextEnd()) TEXT_ALIGNMENT_TEXT_END else TEXT_ALIGNMENT_TEXT_START text = timeText contentDescription = timeText }