Added profile bg and fixed some sources (#483)
Co-authored-by: Blatzar <>
|
@ -58,7 +58,7 @@ open class DoodLaExtractor : ExtractorApi() {
|
|||
val quality = Regex("\\d{3,4}p").find(response0.substringAfter("<title>").substringBefore("</title>"))?.groupValues?.get(0)
|
||||
return listOf(
|
||||
ExtractorLink(
|
||||
trueUrl,
|
||||
this.name,
|
||||
this.name,
|
||||
trueUrl,
|
||||
mainUrl,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -30,7 +30,7 @@ open class Tantifilm : ExtractorApi() {
|
|||
val jsonvideodata = parseJson<TantifilmJsonData>(response)
|
||||
return jsonvideodata.data.map {
|
||||
ExtractorLink(
|
||||
it.file+".${it.type}",
|
||||
this.name,
|
||||
this.name,
|
||||
it.file+".${it.type}",
|
||||
mainUrl,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<QualityDataHelper.QualityProfile>,
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
BIN
app/src/main/res/drawable/profile_bg_blue.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
app/src/main/res/drawable/profile_bg_dark_blue.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
app/src/main/res/drawable/profile_bg_orange.jpg
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
app/src/main/res/drawable/profile_bg_pink.jpg
Normal file
After Width: | Height: | Size: 115 KiB |
BIN
app/src/main/res/drawable/profile_bg_purple.jpg
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
app/src/main/res/drawable/profile_bg_red.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
app/src/main/res/drawable/profile_bg_teal.jpg
Normal file
After Width: | Height: | Size: 126 KiB |
|
@ -1,5 +1,5 @@
|
|||
<?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:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -7,8 +7,10 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/profile_text_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
|
@ -43,14 +45,18 @@
|
|||
android:id="@+id/profiles_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/profile_button_bar"
|
||||
android:layout_below="@+id/profile_text_bar"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:itemCount="4"
|
||||
tools:listitem="@layout/player_quality_profile_item" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/profile_button_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_margin="10dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:gravity="end|bottom"
|
||||
|
@ -60,8 +66,8 @@
|
|||
android:id="@+id/selected_item_holder"
|
||||
android:layout_width="0dp"
|
||||
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
|
||||
android:id="@+id/edit_btt"
|
||||
|
@ -96,4 +102,4 @@
|
|||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -1,42 +1,66 @@
|
|||
<?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:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/card_view"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:backgroundTint="?attr/primaryGrayBackground"
|
||||
app:cardCornerRadius="@dimen/rounded_image_radius">
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false">
|
||||
|
||||
<View
|
||||
android:id="@+id/outline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/outline"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/card_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintDimensionRatio="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:backgroundTint="?attr/primaryGrayBackground"
|
||||
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">
|
||||
|
||||
<TextView
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/profile_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:padding="10dp"
|
||||
tools:text="@string/mobile_data" />
|
||||
<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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_is_wifi"
|
||||
style="@style/DubButton"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/wifi" />
|
||||
<View
|
||||
android:id="@+id/outline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/outline"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_is_mobile_data"
|
||||
style="@style/DubButton"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/mobile_data" />
|
||||
<TextView
|
||||
android:id="@+id/profile_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:padding="10dp"
|
||||
android:textSize="16sp"
|
||||
tools:text="@string/mobile_data" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
<TextView
|
||||
android:id="@+id/text_is_wifi"
|
||||
style="@style/DubButton"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/wifi"
|
||||
android:textColor="@color/textColor" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_is_mobile_data"
|
||||
style="@style/DubButton"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/mobile_data"
|
||||
android:textColor="@color/textColor" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/profiles_click_settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_rowWeight="1"
|
||||
|
@ -49,8 +50,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/outline_drawable"
|
||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:minWidth="140dp"
|
||||
|
|
|
@ -140,6 +140,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:inputType="text"
|
||||
android:maxLength="32"
|
||||
android:layout_marginHorizontal="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:textColor="?attr/textColor"
|
||||
|
|
|
@ -675,4 +675,5 @@
|
|||
\n\nNOTE: If the sum is 10 or more the player will automatically skip loading when that link is loaded!
|
||||
</string>
|
||||
<string name="qualities">Qualities</string>
|
||||
<string name="profile_background_des">Profile background</string>
|
||||
</resources>
|
||||
|
|