Added profile bg and fixed some sources (#483)

Co-authored-by: Blatzar <>
This commit is contained in:
LagradOst 2023-06-12 16:45:18 +00:00 committed by GitHub
parent 805158ad14
commit 06dc909205
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 148 additions and 56 deletions

View file

@ -58,7 +58,7 @@ open class DoodLaExtractor : ExtractorApi() {
val quality = Regex("\\d{3,4}p").find(response0.substringAfter("<title>").substringBefore("</title>"))?.groupValues?.get(0) val quality = Regex("\\d{3,4}p").find(response0.substringAfter("<title>").substringBefore("</title>"))?.groupValues?.get(0)
return listOf( return listOf(
ExtractorLink( ExtractorLink(
trueUrl, this.name,
this.name, this.name,
trueUrl, trueUrl,
mainUrl, mainUrl,

View file

@ -58,7 +58,7 @@ open class GuardareStream : ExtractorApi() {
jsonVideoData.data.forEach { jsonVideoData.data.forEach {
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
it.file + ".${it.type}", this.name,
this.name, this.name,
it.file + ".${it.type}", it.file + ".${it.type}",
mainUrl, mainUrl,

View file

@ -30,7 +30,7 @@ open class Tantifilm : ExtractorApi() {
val jsonvideodata = parseJson<TantifilmJsonData>(response) val jsonvideodata = parseJson<TantifilmJsonData>(response)
return jsonvideodata.data.map { return jsonvideodata.data.map {
ExtractorLink( ExtractorLink(
it.file+".${it.type}", this.name,
this.name, this.name,
it.file+".${it.type}", it.file+".${it.type}",
mainUrl, mainUrl,

View file

@ -684,7 +684,7 @@ class GeneratorPlayer : FullScreenPlayer() {
} }
setProfileName(currentQualityProfile) setProfileName(currentQualityProfile)
sourceDialog.source_settings_btt.setOnClickListener { sourceDialog.profiles_click_settings.setOnClickListener {
val activity = activity ?: return@setOnClickListener val activity = activity ?: return@setOnClickListener
QualityProfileDialog( QualityProfileDialog(
activity, activity,

View file

@ -1,18 +1,26 @@
package com.lagradost.cloudstream3.ui.player.source_priority package com.lagradost.cloudstream3.ui.player.source_priority
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Paint
import android.graphics.Typeface import android.graphics.Typeface
import android.text.style.StyleSpan
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.ui.result.UiImage
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
import kotlinx.android.synthetic.main.player_quality_profile_item.view.* import com.lagradost.cloudstream3.utils.UIHelper.setImage
import kotlinx.android.synthetic.main.player_quality_profile_item.view.card_view
import kotlinx.android.synthetic.main.player_quality_profile_item.view.outline
import kotlinx.android.synthetic.main.player_quality_profile_item.view.profile_image_background
import kotlinx.android.synthetic.main.player_quality_profile_item.view.profile_text
import kotlinx.android.synthetic.main.player_quality_profile_item.view.text_is_mobile_data
import kotlinx.android.synthetic.main.player_quality_profile_item.view.text_is_wifi
class ProfilesAdapter( class ProfilesAdapter(
override val items: MutableList<QualityDataHelper.QualityProfile>, override val items: MutableList<QualityDataHelper.QualityProfile>,
@ -46,11 +54,23 @@ class ProfilesAdapter(
inner class ProfilesViewHolder( inner class ProfilesViewHolder(
itemView: View, itemView: View,
) : RecyclerView.ViewHolder(itemView) { ) : RecyclerView.ViewHolder(itemView) {
private val art = listOf(
R.drawable.profile_bg_teal,
R.drawable.profile_bg_blue,
R.drawable.profile_bg_dark_blue,
R.drawable.profile_bg_purple,
R.drawable.profile_bg_pink,
R.drawable.profile_bg_red,
R.drawable.profile_bg_orange,
)
fun bind(item: QualityDataHelper.QualityProfile, index: Int) { fun bind(item: QualityDataHelper.QualityProfile, index: Int) {
val priorityText: TextView = itemView.profile_text val priorityText: TextView = itemView.profile_text
val profileBg: ImageView = itemView.profile_image_background
val wifiText: TextView = itemView.text_is_wifi val wifiText: TextView = itemView.text_is_wifi
val dataText: TextView = itemView.text_is_mobile_data val dataText: TextView = itemView.text_is_mobile_data
val outline: View = itemView.outline val outline: View = itemView.outline
val cardView: View = itemView.card_view
priorityText.text = item.name.asString(itemView.context) priorityText.text = item.name.asString(itemView.context)
dataText.isVisible = item.type == QualityDataHelper.QualityProfileType.Data dataText.isVisible = item.type == QualityDataHelper.QualityProfileType.Data
@ -58,11 +78,26 @@ class ProfilesAdapter(
fun setCurrentItem() { fun setCurrentItem() {
val prevIndex = currentItem?.first val prevIndex = currentItem?.first
// Prevent UI bug when re-selecting the item quickly
if (prevIndex == index) {
return
}
currentItem = index to item currentItem = index to item
clickCallback.invoke(prevIndex, index) clickCallback.invoke(prevIndex, index)
} }
outline.isVisible = currentItem?.second?.id == item.id outline.isVisible = currentItem?.second?.id == item.id
profileBg.setImage(UiImage.Drawable(art[index % art.size]), null, false) { palette ->
val color = palette.getDarkVibrantColor(
ContextCompat.getColor(
itemView.context,
R.color.dubColorBg
)
)
wifiText.backgroundTintList = ColorStateList.valueOf(color)
dataText.backgroundTintList = ColorStateList.valueOf(color)
}
val textStyle = val textStyle =
if (item.id == usedProfile) { if (item.id == usedProfile) {
@ -73,7 +108,7 @@ class ProfilesAdapter(
priorityText.setTypeface(null, textStyle) priorityText.setTypeface(null, textStyle)
itemView.setOnClickListener { cardView.setOnClickListener {
setCurrentItem() setCurrentItem()
} }
} }

View file

@ -26,7 +26,7 @@ object QualityDataHelper {
/** /**
* Must be higher than amount of QualityProfileTypes * Must be higher than amount of QualityProfileTypes
**/ **/
private const val PROFILE_COUNT = 10 private const val PROFILE_COUNT = 7
/** /**
* Unique guarantees that there will always be one of this type in the profile list. * Unique guarantees that there will always be one of this type in the profile list.

View file

@ -88,7 +88,7 @@ fun ImageView?.setImageImage(value: UiImage.Image, fadeIn: Boolean = true) {
fun ImageView?.setImageDrawable(value: UiImage.Drawable) { fun ImageView?.setImageDrawable(value: UiImage.Drawable) {
if (this == null) return if (this == null) return
this.isVisible = true this.isVisible = true
setImageResource(value.resId) this.setImage(UiImage.Drawable(value.resId))
} }
@JvmName("imgNull") @JvmName("imgNull")

View file

@ -44,12 +44,13 @@ import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.load.model.GlideUrl import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions.bitmapTransform
import com.bumptech.glide.request.target.Target import com.bumptech.glide.request.target.Target
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.result.UiImage
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.utils.GlideOptions.bitmapTransform
import jp.wasabeef.glide.transformations.BlurTransformation import jp.wasabeef.glide.transformations.BlurTransformation
import kotlin.math.roundToInt import kotlin.math.roundToInt
@ -188,11 +189,30 @@ object UIHelper {
fadeIn: Boolean = true, fadeIn: Boolean = true,
colorCallback: ((Palette) -> Unit)? = null colorCallback: ((Palette) -> Unit)? = null
): Boolean { ): Boolean {
if (this == null || url.isNullOrBlank()) return false if (url.isNullOrBlank()) return false
this.setImage(UiImage.Image(url, headers, errorImageDrawable), errorImageDrawable, fadeIn, colorCallback)
return true
}
fun ImageView?.setImage(
uiImage: UiImage?,
@DrawableRes
errorImageDrawable: Int? = null,
fadeIn: Boolean = true,
colorCallback: ((Palette) -> Unit)? = null
): Boolean {
if (this == null || uiImage == null) return false
val (glideImage, identifier) =
(uiImage as? UiImage.Drawable)?.resId?.let {
it to it.toString()
} ?: (uiImage as? UiImage.Image)?.let { image ->
GlideUrl(image.url) { image.headers ?: emptyMap() } to image.url
} ?: return false
return try { return try {
val builder = GlideApp.with(this) val builder = GlideApp.with(this)
.load(GlideUrl(url) { headers ?: emptyMap() }) .load(glideImage)
.skipMemoryCache(true) .skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.ALL).let { req -> .diskCacheStrategy(DiskCacheStrategy.ALL).let { req ->
if (fadeIn) if (fadeIn)
@ -211,7 +231,13 @@ object UIHelper {
isFirstResource: Boolean isFirstResource: Boolean
): Boolean { ): Boolean {
resource?.toBitmapOrNull() resource?.toBitmapOrNull()
?.let { bitmap -> createPaletteAsync(url, bitmap, colorCallback) } ?.let { bitmap ->
createPaletteAsync(
identifier,
bitmap,
colorCallback
)
}
return false return false
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -7,8 +7,10 @@
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/profile_text_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -43,14 +45,18 @@
android:id="@+id/profiles_recyclerview" android:id="@+id/profiles_recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/profile_button_bar"
android:layout_below="@+id/profile_text_bar"
android:orientation="horizontal" android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="4" tools:itemCount="4"
tools:listitem="@layout/player_quality_profile_item" /> tools:listitem="@layout/player_quality_profile_item" />
<LinearLayout <LinearLayout
android:id="@+id/profile_button_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="10dp" android:layout_margin="10dp"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:gravity="end|bottom" android:gravity="end|bottom"
@ -60,8 +66,8 @@
android:id="@+id/selected_item_holder" android:id="@+id/selected_item_holder"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:alpha="0.5" android:layout_weight="1"
android:layout_weight="1"> android:alpha="0.5">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/edit_btt" android:id="@+id/edit_btt"
@ -96,4 +102,4 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </RelativeLayout>

View file

@ -1,14 +1,34 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:focusable="false">
<androidx.cardview.widget.CardView
android:id="@+id/card_view" android:id="@+id/card_view"
android:layout_width="150dp" android:layout_width="0dp"
android:layout_height="150dp" android:layout_height="0dp"
app:layout_constraintDimensionRatio="1"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:backgroundTint="?attr/primaryGrayBackground" android:backgroundTint="?attr/primaryGrayBackground"
app:cardCornerRadius="@dimen/rounded_image_radius"> android:foreground="?attr/selectableItemBackgroundBorderless"
app:cardCornerRadius="@dimen/rounded_image_radius"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/profile_image_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.4"
android:contentDescription="@string/profile_background_des"
android:scaleType="centerCrop" />
<View <View
android:id="@+id/outline" android:id="@+id/outline"
@ -19,24 +39,28 @@
tools:visibility="visible" /> tools:visibility="visible" />
<TextView <TextView
android:layout_gravity="center"
android:id="@+id/profile_text" android:id="@+id/profile_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:layout_gravity="center"
android:gravity="center"
android:padding="10dp" android:padding="10dp"
android:textSize="16sp"
tools:text="@string/mobile_data" /> tools:text="@string/mobile_data" />
<TextView <TextView
android:id="@+id/text_is_wifi" android:id="@+id/text_is_wifi"
style="@style/DubButton" style="@style/DubButton"
android:layout_gravity="end" android:layout_gravity="end"
android:text="@string/wifi" /> android:text="@string/wifi"
android:textColor="@color/textColor" />
<TextView <TextView
android:id="@+id/text_is_mobile_data" android:id="@+id/text_is_mobile_data"
style="@style/DubButton" style="@style/DubButton"
android:layout_gravity="end" android:layout_gravity="end"
android:text="@string/mobile_data" /> android:text="@string/mobile_data"
android:textColor="@color/textColor" />
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -22,6 +22,7 @@
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/profiles_click_settings"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_rowWeight="1" android:layout_rowWeight="1"
@ -49,8 +50,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/outline_drawable"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:gravity="center" android:gravity="center"
android:minWidth="140dp" android:minWidth="140dp"

View file

@ -140,6 +140,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:inputType="text" android:inputType="text"
android:maxLength="32" android:maxLength="32"
android:layout_marginHorizontal="?android:attr/listPreferredItemPaddingStart"
android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:textColor="?attr/textColor" android:textColor="?attr/textColor"

View file

@ -675,4 +675,5 @@
\n\nNOTE: If the sum is 10 or more the player will automatically skip loading when that link is loaded! \n\nNOTE: If the sum is 10 or more the player will automatically skip loading when that link is loaded!
</string> </string>
<string name="qualities">Qualities</string> <string name="qualities">Qualities</string>
<string name="profile_background_des">Profile background</string>
</resources> </resources>