From 611ecbb552392a874daef97f74c78c33abfb8329 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Fri, 16 Apr 2021 23:15:11 -0400 Subject: [PATCH] Material spinner view now defaults to max lines --- .../tachiyomi/widget/MaterialSpinnerView.kt | 26 +++++++++++++++---- .../main/res/layout/material_spinner_view.xml | 3 +-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt index e181c29279..2730879588 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt @@ -59,7 +59,11 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att } } - private val binding = MaterialSpinnerViewBinding.inflate(LayoutInflater.from(context), this, false) + private val binding = MaterialSpinnerViewBinding.inflate( + LayoutInflater.from(context), + this, + false + ) init { addView(binding.root) @@ -71,7 +75,7 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att val entries = (a.getTextArray(R.styleable.MaterialSpinnerView_android_entries) ?: emptyArray()).map { it.toString() } this.entries = entries - val maxLines = a.getInt(R.styleable.MaterialSpinnerView_android_maxLines, 1) + val maxLines = a.getInt(R.styleable.MaterialSpinnerView_android_maxLines, Int.MAX_VALUE) binding.titleView.maxLines = maxLines this.entries = entries @@ -142,7 +146,11 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att } } - fun bindToIntPreference(pref: Preference, @ArrayRes intValuesResource: Int, block: ((Int) -> Unit)? = null) { + fun bindToIntPreference( + pref: Preference, + @ArrayRes intValuesResource: Int, + block: ((Int) -> Unit)? = null + ) { this.pref = pref prefOffset = 0 val intValues = resources.getStringArray(intValuesResource).map { it.toIntOrNull() } @@ -173,7 +181,11 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att return popup } - private fun makeSettingsPopup(preference: Preference, intValues: List, block: ((Int) -> Unit)? = null): PopupMenu { + private fun makeSettingsPopup( + preference: Preference, + intValues: List, + block: ((Int) -> Unit)? = null + ): PopupMenu { val popup = popup() // Set a listener so we are notified if a menu item is clicked popup.setOnMenuItemClickListener { menuItem -> @@ -185,7 +197,11 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att return popup } - private fun makeSettingsPopup(preference: Preference, offset: Int = 0, block: ((Int) -> Unit)? = null): PopupMenu { + private fun makeSettingsPopup( + preference: Preference, + offset: Int = 0, + block: ((Int) -> Unit)? = null + ): PopupMenu { val popup = popup() // Set a listener so we are notified if a menu item is clicked popup.setOnMenuItemClickListener { menuItem -> diff --git a/app/src/main/res/layout/material_spinner_view.xml b/app/src/main/res/layout/material_spinner_view.xml index 2d8de088fd..1d0033c680 100644 --- a/app/src/main/res/layout/material_spinner_view.xml +++ b/app/src/main/res/layout/material_spinner_view.xml @@ -15,7 +15,6 @@ android:layout_marginEnd="24dp" android:layout_marginBottom="12dp" android:ellipsize="end" - android:maxLines="2" android:textColor="?android:attr/textColorPrimary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/halfway_point" @@ -37,7 +36,7 @@ app:layout_constraintTop_toTopOf="parent" android:ellipsize="end" app:layout_constraintHorizontal_chainStyle="spread_inside" - tools:text="Details dsfdsfsdfs df sfs dfsf er sd" /> + tools:text="Details that are so long we need to" />