Skip to content
Snippets Groups Projects
Commit 33c68f62 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Mitigate the seekbar UI issue on kitkat

(cherry picked from commit ace69802)
parent 95f0f771
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,6 @@
android:id="@+id/equalizer_seek"
android:layout_width="0dp"
android:layout_height="0dp"
android:progressDrawable="@drawable/po_seekbar"
android:splitTrack="false"
android:thumb="@drawable/seekbar_thumb" />
</org.videolan.vlc.gui.view.VerticalSeekBarContainer>
......
......@@ -6,18 +6,32 @@ import android.util.AttributeSet
import android.view.KeyEvent
import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatSeekBar
import androidx.core.content.ContextCompat
import org.videolan.vlc.R
class VerticalSeekBar : AppCompatSeekBar {
private var listener: OnSeekBarChangeListener? = null
var fromUser = false
constructor(context: Context) : super(context) {
initialize()
}
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
initialize()
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
initialize()
}
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
private fun initialize() {
//The custom drawable looks not great for kitkat. So we use the default one to mitigate the issue
if (Build.VERSION.SDK_INT >= 21) {
progressDrawable = ContextCompat.getDrawable(context, R.drawable.po_seekbar)
}
}
override fun onTouchEvent(event: MotionEvent): Boolean {
......
......@@ -5,6 +5,7 @@ import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import kotlin.math.max
class VerticalSeekBarContainer @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr) {
......@@ -22,8 +23,8 @@ class VerticalSeekBarContainer @JvmOverloads constructor(context: Context, attrs
val hPadding = paddingLeft + paddingRight
val vPadding = paddingTop + paddingBottom
seekBar.measure(
MeasureSpec.makeMeasureSpec(Math.max(0, h - vPadding), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(Math.max(0, w - hPadding), MeasureSpec.AT_MOST))
MeasureSpec.makeMeasureSpec(max(0, h - vPadding), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(max(0, w - hPadding), MeasureSpec.AT_MOST))
}
applyViewRotation(w, h)
......@@ -66,10 +67,10 @@ class VerticalSeekBarContainer @JvmOverloads constructor(context: Context, attrs
val seekBarMeasuredHeight = seekBar.measuredHeight
val hPadding = paddingLeft + paddingRight
val vPadding = paddingTop + paddingBottom
val hOffset = (Math.max(0, w - hPadding) - seekBarMeasuredHeight) / 2f
val hOffset = (max(0, w - hPadding) - seekBarMeasuredHeight) / 2f
val lp = seekBar.layoutParams
lp.width = Math.max(0, h - vPadding)
lp.width = max(0, h - vPadding)
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT
seekBar.layoutParams = lp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment