diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/DoodExtractor.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/DoodExtractor.kt index 0d94eb08..24495a40 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/DoodExtractor.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/DoodExtractor.kt @@ -58,7 +58,7 @@ open class DoodLaExtractor : ExtractorApi() { val quality = Regex("\\d{3,4}p").find(response0.substringAfter("").substringBefore(""))?.groupValues?.get(0) return listOf( ExtractorLink( - trueUrl, + this.name, this.name, trueUrl, mainUrl, diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt index 2adc00d5..3d046267 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt @@ -58,7 +58,7 @@ open class GuardareStream : ExtractorApi() { jsonVideoData.data.forEach { callback.invoke( ExtractorLink( - it.file + ".${it.type}", + this.name, this.name, it.file + ".${it.type}", mainUrl, diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Tantifilm.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/Tantifilm.kt index d721dea8..13aa48c6 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/Tantifilm.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/Tantifilm.kt @@ -30,7 +30,7 @@ open class Tantifilm : ExtractorApi() { val jsonvideodata = parseJson(response) return jsonvideodata.data.map { ExtractorLink( - it.file+".${it.type}", + this.name, this.name, it.file+".${it.type}", mainUrl, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt index 58c50cab..e20a07fa 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt @@ -684,7 +684,7 @@ class GeneratorPlayer : FullScreenPlayer() { } setProfileName(currentQualityProfile) - sourceDialog.source_settings_btt.setOnClickListener { + sourceDialog.profiles_click_settings.setOnClickListener { val activity = activity ?: return@setOnClickListener QualityProfileDialog( activity, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt index b7289aba..ff84c1f5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt @@ -1,18 +1,26 @@ package com.lagradost.cloudstream3.ui.player.source_priority import android.content.res.ColorStateList -import android.graphics.Paint import android.graphics.Typeface -import android.text.style.StyleSpan import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.ImageView import android.widget.TextView +import androidx.core.content.ContextCompat +import androidx.core.content.res.ResourcesCompat import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.ui.result.UiImage 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( override val items: MutableList, @@ -46,11 +54,23 @@ class ProfilesAdapter( inner class ProfilesViewHolder( itemView: View, ) : 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) { val priorityText: TextView = itemView.profile_text + val profileBg: ImageView = itemView.profile_image_background val wifiText: TextView = itemView.text_is_wifi val dataText: TextView = itemView.text_is_mobile_data val outline: View = itemView.outline + val cardView: View = itemView.card_view priorityText.text = item.name.asString(itemView.context) dataText.isVisible = item.type == QualityDataHelper.QualityProfileType.Data @@ -58,11 +78,26 @@ class ProfilesAdapter( fun setCurrentItem() { val prevIndex = currentItem?.first + // Prevent UI bug when re-selecting the item quickly + if (prevIndex == index) { + return + } currentItem = index to item clickCallback.invoke(prevIndex, index) } + 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 = if (item.id == usedProfile) { @@ -73,7 +108,7 @@ class ProfilesAdapter( priorityText.setTypeface(null, textStyle) - itemView.setOnClickListener { + cardView.setOnClickListener { setCurrentItem() } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/QualityDataHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/QualityDataHelper.kt index 28fbb101..96249db4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/QualityDataHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/QualityDataHelper.kt @@ -26,7 +26,7 @@ object QualityDataHelper { /** * 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. diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt index 81ef8d57..f2eca5b8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt @@ -72,7 +72,7 @@ sealed class UiImage { fun ImageView?.setImage(value: UiImage?, fadeIn: Boolean = true) { when (value) { - is UiImage.Image -> setImageImage(value,fadeIn) + is UiImage.Image -> setImageImage(value, fadeIn) is UiImage.Drawable -> setImageDrawable(value) null -> { this?.isVisible = false @@ -88,7 +88,7 @@ fun ImageView?.setImageImage(value: UiImage.Image, fadeIn: Boolean = true) { fun ImageView?.setImageDrawable(value: UiImage.Drawable) { if (this == null) return this.isVisible = true - setImageResource(value.resId) + this.setImage(UiImage.Drawable(value.resId)) } @JvmName("imgNull") diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt index c300d615..7d798204 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt @@ -44,12 +44,13 @@ import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.load.model.GlideUrl import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import com.bumptech.glide.request.RequestListener +import com.bumptech.glide.request.RequestOptions.bitmapTransform import com.bumptech.glide.request.target.Target import com.lagradost.cloudstream3.R 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.isTvSettings -import com.lagradost.cloudstream3.utils.GlideOptions.bitmapTransform import jp.wasabeef.glide.transformations.BlurTransformation import kotlin.math.roundToInt @@ -188,11 +189,30 @@ object UIHelper { fadeIn: Boolean = true, colorCallback: ((Palette) -> Unit)? = null ): 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 { val builder = GlideApp.with(this) - .load(GlideUrl(url) { headers ?: emptyMap() }) + .load(glideImage) .skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.ALL).let { req -> if (fadeIn) @@ -211,7 +231,13 @@ object UIHelper { isFirstResource: Boolean ): Boolean { resource?.toBitmapOrNull() - ?.let { bitmap -> createPaletteAsync(url, bitmap, colorCallback) } + ?.let { bitmap -> + createPaletteAsync( + identifier, + bitmap, + colorCallback + ) + } return false } diff --git a/app/src/main/res/drawable/profile_bg_blue.jpg b/app/src/main/res/drawable/profile_bg_blue.jpg new file mode 100644 index 00000000..e573439b Binary files /dev/null and b/app/src/main/res/drawable/profile_bg_blue.jpg differ diff --git a/app/src/main/res/drawable/profile_bg_dark_blue.jpg b/app/src/main/res/drawable/profile_bg_dark_blue.jpg new file mode 100644 index 00000000..c6482bc7 Binary files /dev/null and b/app/src/main/res/drawable/profile_bg_dark_blue.jpg differ diff --git a/app/src/main/res/drawable/profile_bg_orange.jpg b/app/src/main/res/drawable/profile_bg_orange.jpg new file mode 100644 index 00000000..ea638c8b Binary files /dev/null and b/app/src/main/res/drawable/profile_bg_orange.jpg differ diff --git a/app/src/main/res/drawable/profile_bg_pink.jpg b/app/src/main/res/drawable/profile_bg_pink.jpg new file mode 100644 index 00000000..63473fe0 Binary files /dev/null and b/app/src/main/res/drawable/profile_bg_pink.jpg differ diff --git a/app/src/main/res/drawable/profile_bg_purple.jpg b/app/src/main/res/drawable/profile_bg_purple.jpg new file mode 100644 index 00000000..15723dba Binary files /dev/null and b/app/src/main/res/drawable/profile_bg_purple.jpg differ diff --git a/app/src/main/res/drawable/profile_bg_red.jpg b/app/src/main/res/drawable/profile_bg_red.jpg new file mode 100644 index 00000000..6a27ff31 Binary files /dev/null and b/app/src/main/res/drawable/profile_bg_red.jpg differ diff --git a/app/src/main/res/drawable/profile_bg_teal.jpg b/app/src/main/res/drawable/profile_bg_teal.jpg new file mode 100644 index 00000000..75ef777b Binary files /dev/null and b/app/src/main/res/drawable/profile_bg_teal.jpg differ diff --git a/app/src/main/res/layout/player_quality_profile_dialog.xml b/app/src/main/res/layout/player_quality_profile_dialog.xml index 640eb90b..7bd7a680 100644 --- a/app/src/main/res/layout/player_quality_profile_dialog.xml +++ b/app/src/main/res/layout/player_quality_profile_dialog.xml @@ -1,5 +1,5 @@ - + android:layout_weight="1" + android:alpha="0.5"> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/player_quality_profile_item.xml b/app/src/main/res/layout/player_quality_profile_item.xml index ad2a29a0..3fad69ac 100644 --- a/app/src/main/res/layout/player_quality_profile_item.xml +++ b/app/src/main/res/layout/player_quality_profile_item.xml @@ -1,42 +1,66 @@ - + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:focusable="false"> - + - + - + - + - \ No newline at end of file + + + + + + diff --git a/app/src/main/res/layout/player_select_source_and_subs.xml b/app/src/main/res/layout/player_select_source_and_subs.xml index 4aefb5cb..550b08d5 100644 --- a/app/src/main/res/layout/player_select_source_and_subs.xml +++ b/app/src/main/res/layout/player_select_source_and_subs.xml @@ -22,6 +22,7 @@ android:orientation="vertical"> Qualities + Profile background