minicast color

This commit is contained in:
LagradOst 2021-06-16 02:15:07 +02:00
parent 881ee223c2
commit 93fe31f014
6 changed files with 52 additions and 5 deletions

View file

@ -1,18 +1,34 @@
package com.lagradost.cloudstream3.ui package com.lagradost.cloudstream3.ui
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.util.AttributeSet
import android.view.View import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.core.content.ContextCompat
import com.google.android.gms.cast.framework.media.widget.MiniControllerFragment import com.google.android.gms.cast.framework.media.widget.MiniControllerFragment
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.UIHelper.adjustAlpha import com.lagradost.cloudstream3.UIHelper.adjustAlpha
import com.lagradost.cloudstream3.UIHelper.colorFromAttribute import com.lagradost.cloudstream3.UIHelper.colorFromAttribute
import com.lagradost.cloudstream3.UIHelper.toPx import com.lagradost.cloudstream3.UIHelper.toPx
class MyMiniControllerFragment : MiniControllerFragment() { class MyMiniControllerFragment : MiniControllerFragment() {
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)
}
super.onInflate(context, attributeSet, bundle)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@ -20,12 +36,17 @@ class MyMiniControllerFragment : MiniControllerFragment() {
try { try {
val progressBar: ProgressBar? = view.findViewById(R.id.progressBar) val progressBar: ProgressBar? = view.findViewById(R.id.progressBar)
val containerAll: LinearLayout? = view.findViewById(R.id.container_all) val containerAll: LinearLayout? = view.findViewById(R.id.container_all)
val containerCurrent: RelativeLayout? = view.findViewById(R.id.container_current)
context?.let { ctx -> context?.let { ctx ->
progressBar?.setBackgroundColor(adjustAlpha(ctx.colorFromAttribute(R.attr.colorPrimary), 0.35f)) progressBar?.setBackgroundColor(adjustAlpha(ctx.colorFromAttribute(R.attr.colorPrimary), 0.35f))
val params = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 2.toPx) val params = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 2.toPx)
progressBar?.layoutParams = params progressBar?.layoutParams = params
if (currentColor != 0) {
containerCurrent?.setBackgroundColor(currentColor)
}
} }
val child = containerAll?.getChildAt(0) val child = containerAll?.getChildAt(0)
child?.alpha = 0f // REMOVE GRADIENT child?.alpha = 0f // REMOVE GRADIENT

View file

@ -26,6 +26,7 @@ import com.google.android.gms.cast.framework.CastContext
import com.google.android.gms.cast.framework.CastState import com.google.android.gms.cast.framework.CastState
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.UIHelper.colorFromAttribute
import com.lagradost.cloudstream3.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.UIHelper.isCastApiAvailable import com.lagradost.cloudstream3.UIHelper.isCastApiAvailable
import com.lagradost.cloudstream3.UIHelper.popupMenu import com.lagradost.cloudstream3.UIHelper.popupMenu
@ -122,6 +123,18 @@ class ResultFragment : Fragment() {
override fun onDestroy() { override fun onDestroy() {
//requireActivity().viewModelStore.clear() // REMEMBER THE CLEAR //requireActivity().viewModelStore.clear() // REMEMBER THE CLEAR
super.onDestroy() super.onDestroy()
activity?.let {
it.window?.navigationBarColor =
it.colorFromAttribute(R.attr.darkBackground)
}
}
override fun onResume() {
super.onResume()
activity?.let {
it.window?.navigationBarColor =
it.colorFromAttribute(R.attr.bitDarkerGrayBackground)
}
} }
private var currentPoster: String? = null private var currentPoster: String? = null
@ -245,7 +258,7 @@ class ResultFragment : Fragment() {
it.popupMenuNoIcons( it.popupMenuNoIcons(
items = WatchType.values() items = WatchType.values()
.map { watchType -> Pair(watchType.internalId, watchType.stringRes) }, .map { watchType -> Pair(watchType.internalId, watchType.stringRes) },
//.map { watchType -> Triple(watchType.internalId, watchType.iconRes, watchType.stringRes) }, //.map { watchType -> Triple(watchType.internalId, watchType.iconRes, watchType.stringRes) },
) { ) {
context?.let { localContext -> context?.let { localContext ->
viewModel.updateWatchStatus(localContext, WatchType.fromInternalId(this.itemId)) viewModel.updateWatchStatus(localContext, WatchType.fromInternalId(this.itemId))

View file

@ -44,6 +44,7 @@
> >
<!--com.google.android.gms.cast.framework.media.widget.MiniControllerFragment--> <!--com.google.android.gms.cast.framework.media.widget.MiniControllerFragment-->
<fragment <fragment
app:customCastBackgroundColor="?attr/darkBackground"
app:castControlButtons="@array/cast_mini_controller_control_buttons" app:castControlButtons="@array/cast_mini_controller_control_buttons"
android:id="@+id/cast_mini_controller" android:id="@+id/cast_mini_controller"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -229,9 +229,12 @@
/> />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
<LinearLayout android:layout_gravity="bottom" android:layout_width="match_parent" <LinearLayout
android:layout_height="wrap_content"> android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<fragment <fragment
app:customCastBackgroundColor="?attr/bitDarkerGrayBackground"
app:castControlButtons="@array/cast_mini_controller_control_buttons" app:castControlButtons="@array/cast_mini_controller_control_buttons"
android:id="@+id/cast_mini_controller" android:id="@+id/cast_mini_controller"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -2,6 +2,15 @@
<resources> <resources>
<declare-styleable name="FlowLayout_Layout"/> <declare-styleable name="FlowLayout_Layout"/>
<declare-styleable name="FlowLayout_Layout_layout_space"/> <declare-styleable name="FlowLayout_Layout_layout_space"/>
<declare-styleable name="CustomCast">
<attr name="customCastBackgroundColor" format="color"/>
</declare-styleable>
<style name="customCastDefColor">
<item name="customCastBackgroundColor">?attr/colorPrimary</item>
</style>
<declare-styleable name="MainColors"> <declare-styleable name="MainColors">
<attr name="colorPrimary" format="color"/> <attr name="colorPrimary" format="color"/>
<attr name="colorSearch" format="color"/> <attr name="colorSearch" format="color"/>

View file

@ -147,7 +147,7 @@
<item name="castTitleTextAppearance">@style/TextAppearance.AppCompat.Subhead</item> <item name="castTitleTextAppearance">@style/TextAppearance.AppCompat.Subhead</item>
<item name="castSubtitleTextAppearance">@style/TextAppearance.AppCompat.Caption</item> <item name="castSubtitleTextAppearance">@style/TextAppearance.AppCompat.Caption</item>
<item name="castBackground">?attr/darkBackground</item> <!--CHECK--> <item name="castBackground">@color/transparent</item> <!--CHECK bitDarkerGrayBackground darkBackground-->
<item name="castProgressBarColor">?attr/colorPrimary</item> <item name="castProgressBarColor">?attr/colorPrimary</item>
<item name="castStopButtonDrawable">@drawable/cast_ic_mini_controller_stop</item>' <item name="castStopButtonDrawable">@drawable/cast_ic_mini_controller_stop</item>'
<item name="castLargeStopButtonDrawable">@drawable/cast_ic_mini_controller_stop_large</item> <item name="castLargeStopButtonDrawable">@drawable/cast_ic_mini_controller_stop_large</item>