Skip to content

Commit 4f0e46b

Browse files
coolteydbrant
andauthored
Update tab and language icon style for long text (#4429)
* Update tab and language icon style for long text * Fix lint * Remove paddings and use textViewCompat utility * Use match_parent instead * Revert: dont use match_parent * Adding padding back * Adding horizontal padding only * Set to 10 --------- Co-authored-by: Dmitry Brant <[email protected]>
1 parent aac585b commit 4f0e46b

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

app/src/main/java/org/wikipedia/views/LangCodeView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.widget.FrameLayout
1010
import androidx.annotation.ColorInt
1111
import androidx.core.content.res.use
1212
import androidx.core.view.ViewCompat
13+
import androidx.core.widget.TextViewCompat
1314
import org.wikipedia.R
1415
import org.wikipedia.databinding.ViewLangCodeBinding
1516
import org.wikipedia.language.LanguageUtil
@@ -41,8 +42,7 @@ class LangCodeView(context: Context, attrs: AttributeSet? = null) : FrameLayout(
4142

4243
fun setLangCode(langCode: String) {
4344
binding.langCodeText.text = LanguageUtil.formatLangCodeForButton(langCode.uppercase())
44-
val textSize = if (langCode.length > 2) 5f else 10f
45-
binding.langCodeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize)
45+
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(binding.langCodeText, 1, 10, 1, TypedValue.COMPLEX_UNIT_SP)
4646
}
4747

4848
fun setTextColor(@ColorInt textColor: Int) {

app/src/main/java/org/wikipedia/views/TabCountsView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.view.LayoutInflater
77
import android.view.ViewGroup
88
import android.view.animation.AnimationUtils
99
import android.widget.FrameLayout
10+
import androidx.core.widget.TextViewCompat
1011
import org.wikipedia.R
1112
import org.wikipedia.WikipediaApp
1213
import org.wikipedia.databinding.ViewTabsCountBinding
@@ -26,8 +27,7 @@ class TabCountsView(context: Context, attrs: AttributeSet? = null) : FrameLayout
2627
fun updateTabCount(animation: Boolean) {
2728
val count = WikipediaApp.instance.tabCount
2829
binding.tabsCountText.text = count.toString()
29-
val tabTextSize = if (count > 99) 5f else 10f
30-
binding.tabsCountText.setTextSize(TypedValue.COMPLEX_UNIT_SP, tabTextSize)
30+
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(binding.tabsCountText, 7, 10, 1, TypedValue.COMPLEX_UNIT_SP)
3131
if (animation) {
3232
startAnimation(AnimationUtils.loadAnimation(context, R.anim.tab_list_zoom_enter))
3333
}

app/src/main/res/layout/view_lang_code.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
<TextView
88
android:id="@+id/langCodeText"
9-
android:layout_width="19dp"
10-
android:layout_height="18dp"
9+
android:layout_width="21dp"
10+
android:layout_height="20dp"
1111
android:layout_gravity="center"
1212
android:layout_marginStart="14.5dp"
1313
android:layout_marginEnd="14.5dp"
@@ -19,5 +19,6 @@
1919
android:textAlignment="center"
2020
android:textColor="?attr/primary_color"
2121
android:textSize="10sp"
22+
android:paddingHorizontal="2dp"
2223
tools:text="ZH-\nHANT" />
2324
</merge>

app/src/main/res/layout/view_tabs_count.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
<TextView
88
android:id="@+id/tabsCountText"
9-
android:layout_width="19dp"
10-
android:layout_height="18dp"
9+
android:layout_width="21dp"
10+
android:layout_height="20dp"
1111
android:layout_gravity="center"
1212
android:layout_marginStart="14.5dp"
1313
android:layout_marginEnd="14.5dp"
@@ -19,5 +19,6 @@
1919
android:textAlignment="center"
2020
android:textColor="?attr/primary_color"
2121
android:textSize="10sp"
22+
android:paddingHorizontal="2dp"
2223
tools:text="3" />
2324
</merge>

0 commit comments

Comments
 (0)