fix: default to old cast method for now

This commit is contained in:
rebelonion 2024-02-08 06:23:51 -06:00
parent bfe4d69b8a
commit 4aa88244ed
6 changed files with 68 additions and 11 deletions

View file

@ -1079,17 +1079,17 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
//Cast
if (PrefManager.getVal(PrefName.Cast)) {
playerView.findViewById<MediaRouteButton>(R.id.exo_cast).apply {
playerView.findViewById<CustomCastButton>(R.id.exo_cast).apply {
visibility = View.VISIBLE
if(PrefManager.getVal(PrefName.UseInternalCast)) {
try {
CastButtonFactory.setUpMediaRouteButton(context, this)
dialogFactory = CustomCastThemeFactory()
} catch (e: Exception) {
isCastApiAvailable = false
}
setOnLongClickListener {
cast()
true
} else {
setCastCallback { cast() }
}
}
}
@ -2004,3 +2004,31 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
}
}
}
class CustomCastButton : MediaRouteButton {
private var castCallback: (() -> Unit)? = null
fun setCastCallback(castCallback: () -> Unit) {
this.castCallback = castCallback
}
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet, castCallback: () -> Unit) : super(context, attrs) {
this.castCallback = castCallback
}
override fun performClick(): Boolean {
return if (PrefManager.getVal(PrefName.UseInternalCast)) {
super.performClick()
} else {
castCallback?.let { it() }
true
}
}
}

View file

@ -234,6 +234,11 @@ class PlayerSettingsActivity : AppCompatActivity() {
PrefManager.setVal(PrefName.Cast, isChecked)
}
binding.playerSettingsInternalCast.isChecked = PrefManager.getVal(PrefName.UseInternalCast)
binding.playerSettingsInternalCast.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.UseInternalCast, isChecked)
}
binding.playerSettingsRotate.isChecked = PrefManager.getVal(PrefName.RotationPlayer)
binding.playerSettingsRotate.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.RotationPlayer, isChecked)

View file

@ -94,6 +94,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
SeekTime(Pref(Location.Player, Int::class, 10)),
SkipTime(Pref(Location.Player, Int::class, 85)),
Cast(Pref(Location.Player, Boolean::class, true)),
UseInternalCast(Pref(Location.Player, Boolean::class, false)),
Pip(Pref(Location.Player, Boolean::class, true)),
RotationPlayer(Pref(Location.Player, Boolean::class, true)),
ContinuedAnime(Pref(Location.Player, List::class, listOf<String>())),

View file

@ -1072,6 +1072,28 @@
</com.google.android.material.materialswitch.MaterialSwitch>
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/playerSettingsInternalCast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="false"
android:drawableStart="@drawable/ic_round_cast_24"
android:drawablePadding="16dp"
android:elegantTextHeight="true"
android:fontFamily="@font/poppins_bold"
android:minHeight="64dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/try_internal_cast_experimental"
android:textAlignment="viewStart"
android:textColor="@color/bg_opp"
app:cornerRadius="0dp"
app:drawableTint="?attr/colorPrimary"
app:showText="false"
app:thumbTint="@color/button_switch_track">
</com.google.android.material.materialswitch.MaterialSwitch>
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/playerSettingsRotate"
android:layout_width="match_parent"

View file

@ -151,7 +151,7 @@
app:srcCompat="@drawable/ic_round_screen_rotation_alt_24"
tools:ignore="ContentDescription,SpeakableTextPresentCheck" />
<androidx.mediarouter.app.MediaRouteButton
<ani.dantotsu.media.anime.CustomCastButton
android:id="@+id/exo_cast"
android:layout_width="wrap_content"
android:layout_height="48dp"

View file

@ -655,5 +655,6 @@
<string name="pinned_sources">Pinned Sources</string>
<string name="import_export_settings">Import/Export Settings</string>
<string name="import_settings">Import Settings</string>
<string name="try_internal_cast_experimental">Try Internal Cast (Experimental)</string>
</resources>