Change characters left color to red when negative (#1952)

* Change characters left color to red when negative

* Use val for the integers, optimize variable assignment

* Added tusky_red color

* remove extra line typo

* make characters left bold

* change red hue

* fix typo
This commit is contained in:
Vignesh Kumar 2020-10-13 22:00:06 +05:30 committed by Alibek Omarov
parent dbb28017e3
commit 8d9a54e8ea
3 changed files with 11 additions and 1 deletions

View File

@ -929,7 +929,15 @@ class ComposeActivity : BaseActivity(),
}
private fun updateVisibleCharactersLeft() {
composeCharactersLeftView.text = String.format(Locale.getDefault(), "%d", maximumTootCharacters - calculateTextLength())
val remainingLength = maximumTootCharacters - calculateTextLength();
composeCharactersLeftView.text = String.format(Locale.getDefault(), "%d", remainingLength)
val textColor = if (remainingLength < 0) {
ContextCompat.getColor(this, R.color.tusky_red)
} else {
ThemeUtils.getColor(this, android.R.attr.textColorTertiary)
}
composeCharactersLeftView.setTextColor(textColor)
}
private fun onContentWarningChanged() {

View File

@ -451,6 +451,7 @@
android:textSize="?attr/status_text_medium"
android:layout_toLeftOf="@+id/composePreviewButton"
android:layout_centerVertical="true"
android:textStyle="bold"
tools:text="500" />
<com.google.android.material.button.MaterialButton

View File

@ -6,6 +6,7 @@
<color name="tusky_orange_light">#fab207</color>
<color name="tusky_green">#19a341</color>
<color name="tusky_green_light">#25d069</color>
<color name="tusky_red">#DF1553</color>
<color name="red">#f00</color>
<color name="white">#fff</color>