Merge remote-tracking branch 'upstream/master'

This commit is contained in:
jmir1 2021-11-27 19:23:56 +01:00
commit 1fdfd6a204
2 changed files with 18 additions and 2 deletions

View file

@ -1,13 +1,27 @@
package eu.kanade.tachiyomi.widget package eu.kanade.tachiyomi.widget
import android.content.Context import android.content.Context
import android.text.InputType
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.EditText
import android.widget.NumberPicker import android.widget.NumberPicker
import androidx.core.view.doOnLayout
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.findDescendant
class MinMaxNumberPicker @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : class MinMaxNumberPicker @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
NumberPicker(context, attrs) { NumberPicker(context, attrs) {
override fun setDisplayedValues(displayedValues: Array<out String>?) {
super.setDisplayedValues(displayedValues)
// Disable keyboard input when a value that can't be auto-filled with number exists
val notNumberValue = displayedValues?.find { it.getOrNull(0)?.digitToIntOrNull() == null }
if (notNumberValue != null) {
descendantFocusability = FOCUS_BLOCK_DESCENDANTS
}
}
init { init {
if (attrs != null) { if (attrs != null) {
val ta = context.obtainStyledAttributes(attrs, R.styleable.MinMaxNumberPicker, 0, 0) val ta = context.obtainStyledAttributes(attrs, R.styleable.MinMaxNumberPicker, 0, 0)
@ -18,5 +32,9 @@ class MinMaxNumberPicker @JvmOverloads constructor(context: Context, attrs: Attr
ta.recycle() ta.recycle()
} }
} }
doOnLayout {
findDescendant<EditText>()?.setRawInputType(InputType.TYPE_CLASS_NUMBER)
}
} }
} }

View file

@ -22,7 +22,6 @@
android:id="@+id/portrait_columns" android:id="@+id/portrait_columns"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
app:max="10" app:max="10"
app:min="0" /> app:min="0" />
@ -44,7 +43,6 @@
android:id="@+id/landscape_columns" android:id="@+id/landscape_columns"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
app:max="10" app:max="10"
app:min="0" /> app:min="0" />