From 3b67f339b12829b9757be1949803617440422911 Mon Sep 17 00:00:00 2001 From: Vignesh Kumar Date: Tue, 13 Oct 2020 22:00:06 +0530 Subject: [PATCH] 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 --- .../tusky/components/compose/ComposeActivity.kt | 10 +++++++++- app/src/main/res/layout/activity_compose.xml | 1 + app/src/main/res/values/colors.xml | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt index 1cc8e01c7..d448a6620 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt @@ -682,7 +682,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() { diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index abff95023..355841d98 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -327,6 +327,7 @@ android:layout_height="wrap_content" android:textColor="?android:textColorTertiary" android:textSize="?attr/status_text_medium" + android:textStyle="bold" tools:text="500" /> #fab207 #19a341 #25d069 + #DF1553 #fff #000