2021-06-14 00:00:29 +00:00
|
|
|
package com.lagradost.cloudstream3.ui
|
|
|
|
|
2021-06-16 00:15:07 +00:00
|
|
|
import android.content.Context
|
2021-06-14 00:00:29 +00:00
|
|
|
import android.os.Bundle
|
2021-06-16 00:15:07 +00:00
|
|
|
import android.util.AttributeSet
|
2021-06-14 00:00:29 +00:00
|
|
|
import android.view.View
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
import android.widget.ProgressBar
|
|
|
|
import android.widget.RelativeLayout
|
|
|
|
import com.google.android.gms.cast.framework.media.widget.MiniControllerFragment
|
|
|
|
import com.lagradost.cloudstream3.R
|
2021-07-30 01:14:53 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.UIHelper.adjustAlpha
|
|
|
|
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
|
|
|
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
2021-06-14 00:00:29 +00:00
|
|
|
|
2021-06-16 00:15:07 +00:00
|
|
|
|
2021-06-14 00:00:29 +00:00
|
|
|
class MyMiniControllerFragment : MiniControllerFragment() {
|
2021-06-16 00:15:07 +00:00
|
|
|
var currentColor: Int = 0
|
|
|
|
|
|
|
|
// I KNOW, KINDA SPAGHETTI SOLUTION, BUT IT WORKS
|
|
|
|
override fun onInflate(context: Context, attributeSet: AttributeSet, bundle: Bundle?) {
|
|
|
|
val obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.CustomCast, 0, 0)
|
|
|
|
if (obtainStyledAttributes.hasValue(R.styleable.CustomCast_customCastBackgroundColor)) {
|
|
|
|
currentColor = obtainStyledAttributes.getColor(R.styleable.CustomCast_customCastBackgroundColor, 0)
|
|
|
|
}
|
2021-08-29 18:42:44 +00:00
|
|
|
obtainStyledAttributes.recycle()
|
2021-06-16 00:15:07 +00:00
|
|
|
super.onInflate(context, attributeSet, bundle)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-14 00:00:29 +00:00
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
|
|
// SEE https://github.com/dandar3/android-google-play-services-cast-framework/blob/master/res/layout/cast_mini_controller.xml
|
|
|
|
try {
|
|
|
|
val progressBar: ProgressBar? = view.findViewById(R.id.progressBar)
|
|
|
|
val containerAll: LinearLayout? = view.findViewById(R.id.container_all)
|
2021-06-16 00:15:07 +00:00
|
|
|
val containerCurrent: RelativeLayout? = view.findViewById(R.id.container_current)
|
2021-06-14 00:00:29 +00:00
|
|
|
|
|
|
|
context?.let { ctx ->
|
|
|
|
progressBar?.setBackgroundColor(adjustAlpha(ctx.colorFromAttribute(R.attr.colorPrimary), 0.35f))
|
|
|
|
val params = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 2.toPx)
|
|
|
|
|
|
|
|
progressBar?.layoutParams = params
|
2021-06-16 00:15:07 +00:00
|
|
|
|
|
|
|
if (currentColor != 0) {
|
|
|
|
containerCurrent?.setBackgroundColor(currentColor)
|
|
|
|
}
|
2021-06-14 00:00:29 +00:00
|
|
|
}
|
|
|
|
val child = containerAll?.getChildAt(0)
|
|
|
|
child?.alpha = 0f // REMOVE GRADIENT
|
|
|
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
// JUST IN CASE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|