1
0
Fork 0

For #10083: Adjust thumb offset to thumb circumference to avoid cutoff

master
mcarare 2020-04-21 19:05:38 +03:00 committed by Emily Kager
parent 6afcd2cee6
commit 3c5d8d31ea
1 changed files with 6 additions and 0 deletions

View File

@ -37,6 +37,8 @@ import androidx.preference.PreferenceViewHolder
import org.mozilla.fenix.R
import java.text.NumberFormat
import kotlin.math.PI
import kotlin.math.roundToInt
/**
* Preference based on android.preference.SeekBarPreference but uses support preference as a base.
@ -54,6 +56,7 @@ import java.text.NumberFormat
* Other [SeekBar] specific attributes (e.g. `title, summary, defaultValue, min, max`)
* can be set directly on the preference widget layout.
*/
@SuppressWarnings("LargeClass")
class TextPercentageSeekBarPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
@ -268,6 +271,9 @@ class TextPercentageSeekBarPreference @JvmOverloads constructor(
updateExampleTextValue(mSeekBarValue)
updateLabelValue(mSeekBarValue)
mSeekBar?.isEnabled = isEnabled
mSeekBar?.let {
it.thumbOffset = it.thumb.intrinsicWidth.div(2 * PI).roundToInt()
}
}
override fun onSetInitialValue(initialValue: Any?) {