fixed rolling cache + update UI text color

This commit is contained in:
reduplicated 2022-12-03 22:55:53 +01:00
parent 42d1dd9f7d
commit 2222a1b07b
13 changed files with 349 additions and 341 deletions

View file

@ -1,6 +1,7 @@
package com.lagradost.cloudstream3.ui package com.lagradost.cloudstream3.ui
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.unixTime
import com.lagradost.cloudstream3.APIHolder.unixTimeMS import com.lagradost.cloudstream3.APIHolder.unixTimeMS
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.logError
@ -31,26 +32,47 @@ class APIRepository(val api: MainAPI) {
return data.isEmpty() || data == "[]" || data == "about:blank" return data.isEmpty() || data == "[]" || data == "about:blank"
} }
private val cacheHash: HashMap<Pair<String, String>, LoadResponse> = hashMapOf() data class SavedLoadResponse(
val unixTime: Long,
val response: LoadResponse,
val hash: Pair<String, String>
)
private val cache: ArrayList<SavedLoadResponse> = arrayListOf()
private var cacheIndex: Int = 0
const val cacheSize = 20
} }
val hasMainPage = api.hasMainPage val hasMainPage = api.hasMainPage
val providerType = api.providerType
val name = api.name val name = api.name
val mainUrl = api.mainUrl val mainUrl = api.mainUrl
val mainPage = api.mainPage val mainPage = api.mainPage
val hasQuickSearch = api.hasQuickSearch val hasQuickSearch = api.hasQuickSearch
val vpnStatus = api.vpnStatus val vpnStatus = api.vpnStatus
val providerType = api.providerType
suspend fun load(url: String): Resource<LoadResponse> { suspend fun load(url: String): Resource<LoadResponse> {
return safeApiCall { return safeApiCall {
if (isInvalidData(url)) throw ErrorLoadingException() if (isInvalidData(url)) throw ErrorLoadingException()
val fixedUrl = api.fixUrl(url) val fixedUrl = api.fixUrl(url)
val key = Pair(api.name, url) val lookingForHash = Pair(api.name, fixedUrl)
cacheHash[key] ?: api.load(fixedUrl)?.also {
// we cache 20 responses because ppl often go back to the same shit + 20 because I dont want to cause too much memory leak for (item in cache) {
if (cacheHash.size > 20) cacheHash.remove(cacheHash.keys.random()) // 10 min save
cacheHash[key] = it if (item.hash == lookingForHash && (unixTime - item.unixTime) < 60 * 10) {
return@safeApiCall item.response
}
}
api.load(fixedUrl)?.also { response ->
val add = SavedLoadResponse(unixTime, response, lookingForHash)
if (cache.size > cacheSize) {
cache[cacheIndex] = add // rolling cache
cacheIndex = (cacheIndex + 1) % cacheSize
} else {
cache.add(add)
}
} ?: throw ErrorLoadingException() } ?: throw ErrorLoadingException()
} }
} }

View file

@ -443,6 +443,7 @@ class HomeFragment : Fragment() {
home_main_poster_recyclerview?.isVisible = visible home_main_poster_recyclerview?.isVisible = visible
} }
@SuppressLint("NotifyDataSetChanged") // we need to notify to change poster
private fun fixGrid() { private fun fixGrid() {
activity?.getSpanCount()?.let { activity?.getSpanCount()?.let {
currentSpan = it currentSpan = it
@ -465,6 +466,7 @@ class HomeFragment : Fragment() {
override fun onConfigurationChanged(newConfig: Configuration) { override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
(home_preview_viewpager?.adapter as? HomeScrollAdapter)?.notifyDataSetChanged()
fixGrid() fixGrid()
} }

View file

@ -1,5 +1,6 @@
package com.lagradost.cloudstream3.ui.home package com.lagradost.cloudstream3.ui.home
import android.content.res.Configuration
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -16,7 +17,7 @@ class HomeScrollAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var items: MutableList<LoadResponse> = mutableListOf() private var items: MutableList<LoadResponse> = mutableListOf()
var hasMoreItems: Boolean = false var hasMoreItems: Boolean = false
fun getItem(position: Int) : LoadResponse? { fun getItem(position: Int): LoadResponse? {
return items.getOrNull(position) return items.getOrNull(position)
} }
@ -59,6 +60,10 @@ class HomeScrollAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
fun bind(card: LoadResponse) { fun bind(card: LoadResponse) {
card.apply { card.apply {
val isHorizontal =
itemView.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
val posterUrl = if (isHorizontal) backgroundPosterUrl ?: posterUrl else posterUrl
?: backgroundPosterUrl
itemView.home_scroll_preview_tags?.text = tags?.joinToString("") ?: "" itemView.home_scroll_preview_tags?.text = tags?.joinToString("") ?: ""
itemView.home_scroll_preview_tags?.isGone = tags.isNullOrEmpty() itemView.home_scroll_preview_tags?.isGone = tags.isNullOrEmpty()
itemView.home_scroll_preview?.setImage(posterUrl, posterHeaders) itemView.home_scroll_preview?.setImage(posterUrl, posterHeaders)

View file

@ -16,8 +16,6 @@ import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog
import com.lagradost.cloudstream3.utils.SubtitleHelper import com.lagradost.cloudstream3.utils.SubtitleHelper
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
import kotlin.reflect.jvm.internal.impl.descriptors.deserialization.PlatformDependentDeclarationFilter.All
class SettingsProviders : PreferenceFragmentCompat() { class SettingsProviders : PreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

View file

@ -323,6 +323,7 @@
app:iconifiedByDefault="true" app:iconifiedByDefault="true"
app:queryBackground="@color/transparent" app:queryBackground="@color/transparent"
app:queryHint="@string/search" app:queryHint="@string/search"
app:closeIcon="@drawable/ic_baseline_close_24"
app:searchIcon="@drawable/search_icon" app:searchIcon="@drawable/search_icon"
tools:ignore="RtlSymmetry" /> tools:ignore="RtlSymmetry" />
@ -405,11 +406,11 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<View <View
android:id="@+id/home_fix_padding" android:id="@+id/home_fix_padding"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp"> android:layout_height="0dp"></View>
</View>
<!-- <!--
All padding in home_watch_holder is determined in runtime All padding in home_watch_holder is determined in runtime
This is because the home poster can be invisible which forces This is because the home poster can be invisible which forces

View file

@ -26,10 +26,7 @@
android:contentDescription="@string/search_poster_img_des" /> android:contentDescription="@string/search_poster_img_des" />
<TextView <TextView
tools:text="@string/quality_hd" style="@style/TypeButton" />
android:id="@+id/text_quality"
style="@style/SearchBox"
android:background="@drawable/type_bg_color" />
<!-- <!--
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"

View file

@ -3,71 +3,71 @@
<!-- android:layout_width="114dp" <!-- android:layout_width="114dp"
android:layout_height="180dp"--> android:layout_height="180dp"-->
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.cardview.widget.CardView 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:foreground="@drawable/outline_drawable" android:id="@+id/background_card"
android:layout_margin="2dp" android:layout_width="114dp"
android:layout_width="114dp" android:layout_height="180dp"
android:layout_height="180dp" android:layout_margin="2dp"
android:layout_marginBottom="2dp" android:layout_marginBottom="2dp"
android:elevation="10dp" android:elevation="10dp"
app:cardCornerRadius="@dimen/rounded_image_radius" android:foreground="@drawable/outline_drawable"
android:id="@+id/background_card" app:cardBackgroundColor="?attr/primaryGrayBackground"
app:cardBackgroundColor="?attr/primaryGrayBackground"> app:cardCornerRadius="@dimen/rounded_image_radius">
<ImageView <ImageView
android:duplicateParentState="true" android:id="@+id/imageView"
android:id="@+id/imageView" android:layout_width="match_parent"
tools:src="@drawable/example_poster" android:layout_height="match_parent"
android:scaleType="centerCrop" android:contentDescription="@string/search_poster_img_des"
android:layout_width="match_parent" android:duplicateParentState="true"
android:layout_height="match_parent" android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:foreground="?android:attr/selectableItemBackgroundBorderless" android:scaleType="centerCrop"
android:contentDescription="@string/search_poster_img_des" /> tools:src="@drawable/example_poster" />
<ImageView <ImageView
android:focusable="false" android:id="@+id/title_shadow"
android:clickable="false" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="50dp"
android:layout_height="50dp" android:layout_gravity="bottom"
android:id="@+id/title_shadow" android:clickable="false"
android:src="@drawable/title_shadow" android:focusable="false"
android:layout_gravity="bottom" android:src="@drawable/title_shadow"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
tools:text="The Perfect Run" android:id="@+id/imageText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_gravity="bottom"
android:layout_gravity="bottom" android:ellipsize="end"
android:paddingBottom="5dp" android:gravity="center"
android:paddingTop="5dp" android:maxLines="2"
android:textColor="@color/textColor" android:paddingStart="5dp"
android:id="@+id/imageText" android:paddingTop="5dp"
android:textStyle="bold" android:paddingEnd="5dp"
android:maxLines="2" android:paddingBottom="5dp"
android:paddingStart="5dp" android:textColor="@color/textColor"
android:paddingEnd="5dp" android:textStyle="bold"
android:ellipsize="end" /> tools:text="The Perfect Run" />
<ImageView <ImageView
android:id="@+id/search_item_download_play" android:id="@+id/search_item_download_play"
android:layout_gravity="center" android:layout_width="60dp"
android:src="@drawable/play_button" android:layout_height="60dp"
android:layout_width="60dp" android:layout_gravity="center"
android:layout_height="60dp" /> android:src="@drawable/play_button" />
<androidx.core.widget.ContentLoadingProgressBar <androidx.core.widget.ContentLoadingProgressBar
android:layout_marginBottom="-1.5dp" android:id="@+id/watchProgress"
android:id="@+id/watchProgress" style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:progressTint="?attr/colorPrimary" android:layout_width="match_parent"
android:progressBackgroundTint="?attr/colorPrimary" android:layout_height="5dp"
style="@android:style/Widget.Material.ProgressBar.Horizontal" android:layout_gravity="bottom"
android:layout_width="match_parent" android:layout_marginBottom="-1.5dp"
tools:progress="50" android:progressBackgroundTint="?attr/colorPrimary"
android:layout_gravity="bottom" android:progressTint="?attr/colorPrimary"
android:layout_height="5dp" /> tools:progress="50" />
<!--<View <!--<View
android:id="@+id/search_result_lang" android:id="@+id/search_result_lang"
@ -86,17 +86,13 @@
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp"> android:layout_height="30dp">
</ImageView>--> </ImageView>-->
<TextView <TextView android:id="@+id/text_quality" style="@style/TypeButton" />
tools:text="@string/quality_hd"
android:id="@+id/text_quality"
style="@style/SearchBox"
android:background="@drawable/type_bg_color" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_gravity="end" android:layout_height="match_parent"
android:layout_width="match_parent" android:layout_gravity="end"
android:layout_height="match_parent"> android:orientation="vertical">
<!-- <!--
<ImageView android:id="@+id/text_is_dub" android:tint="?attr/colorPrimary" <ImageView android:id="@+id/text_is_dub" android:tint="?attr/colorPrimary"
@ -105,27 +101,23 @@
</ImageView>--> </ImageView>-->
<TextView <TextView
android:text="@string/app_dubbed_text" android:id="@+id/text_is_dub"
android:id="@+id/text_is_dub" style="@style/DubButton"
style="@style/SearchBox" android:layout_gravity="end" />
android:layout_gravity="end"
android:background="@drawable/dub_bg_color" />
<TextView <TextView
android:id="@+id/text_is_sub" android:id="@+id/text_is_sub"
android:text="@string/app_subbed_text" style="@style/SubButton"
style="@style/SearchBox" android:layout_gravity="end" />
android:layout_gravity="end"
android:background="@drawable/sub_bg_color" />
<TextView <TextView
tools:visibility="visible" android:id="@+id/text_flag"
android:visibility="gone" style="@style/SearchBox"
android:textSize="20sp" android:layout_gravity="end"
android:id="@+id/text_flag" android:background="@color/transparent"
tools:text="🇸🇪" android:textSize="20sp"
style="@style/SearchBox" android:visibility="gone"
android:layout_gravity="end" tools:text="🇸🇪"
android:background="@color/transparent" /> tools:visibility="visible" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View file

@ -5,58 +5,58 @@
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.cardview.widget.CardView 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:backgroundTint="@color/transparent" android:id="@+id/background_card"
android:foreground="@drawable/outline_drawable" android:layout_width="wrap_content"
app:cardElevation="0dp" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_margin="2dp"
app:cardCornerRadius="@dimen/rounded_image_radius" android:backgroundTint="@color/transparent"
android:layout_margin="2dp" android:foreground="@drawable/outline_drawable"
android:id="@+id/background_card" app:cardCornerRadius="@dimen/rounded_image_radius"
android:layout_width="wrap_content"> app:cardElevation="0dp">
<LinearLayout <LinearLayout
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content"> android:orientation="vertical">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/image_holder" android:id="@+id/image_holder"
android:layout_width="114dp" android:layout_width="114dp"
android:layout_height="180dp" android:layout_height="180dp"
android:elevation="10dp" android:elevation="10dp"
app:cardCornerRadius="@dimen/rounded_image_radius" app:cardBackgroundColor="?attr/primaryGrayBackground"
app:cardBackgroundColor="?attr/primaryGrayBackground"> app:cardCornerRadius="@dimen/rounded_image_radius">
<ImageView <ImageView
android:duplicateParentState="true" android:id="@+id/imageView"
android:id="@+id/imageView" android:layout_width="match_parent"
tools:src="@drawable/example_poster" android:layout_height="match_parent"
android:scaleType="centerCrop" android:contentDescription="@string/search_poster_img_des"
android:layout_width="match_parent" android:duplicateParentState="true"
android:layout_height="match_parent" android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:foreground="?android:attr/selectableItemBackgroundBorderless" android:scaleType="centerCrop"
android:contentDescription="@string/search_poster_img_des" /> tools:src="@drawable/example_poster" />
<ImageView <ImageView
android:id="@+id/search_item_download_play" android:id="@+id/search_item_download_play"
android:layout_gravity="center" android:layout_width="60dp"
android:src="@drawable/play_button" android:layout_height="60dp"
android:layout_width="60dp" android:layout_gravity="center"
android:layout_height="60dp" /> android:src="@drawable/play_button" />
<androidx.core.widget.ContentLoadingProgressBar <androidx.core.widget.ContentLoadingProgressBar
android:layout_marginBottom="-1.5dp" android:id="@+id/watchProgress"
android:id="@+id/watchProgress" style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:progressTint="?attr/colorPrimary" android:layout_width="match_parent"
android:progressBackgroundTint="?attr/colorPrimary" android:layout_height="5dp"
style="@android:style/Widget.Material.ProgressBar.Horizontal" android:layout_gravity="bottom"
android:layout_width="match_parent" android:layout_marginBottom="-1.5dp"
tools:progress="50" android:progressBackgroundTint="?attr/colorPrimary"
android:layout_gravity="bottom" android:progressTint="?attr/colorPrimary"
android:layout_height="5dp" /> tools:progress="50" />
<!--<View <!--<View
android:id="@+id/search_result_lang" android:id="@+id/search_result_lang"
@ -75,17 +75,13 @@
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp"> android:layout_height="30dp">
</ImageView>--> </ImageView>-->
<TextView <TextView android:id="@+id/text_quality" style="@style/TypeButton" />
tools:text="@string/quality_hd"
android:id="@+id/text_quality"
style="@style/SearchBox"
android:background="@drawable/type_bg_color" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_gravity="end" android:layout_height="match_parent"
android:layout_width="match_parent" android:layout_gravity="end"
android:layout_height="match_parent"> android:orientation="vertical">
<!-- <!--
<ImageView android:id="@+id/text_is_dub" android:tint="?attr/colorPrimary" <ImageView android:id="@+id/text_is_dub" android:tint="?attr/colorPrimary"
@ -94,46 +90,42 @@
</ImageView>--> </ImageView>-->
<TextView <TextView
android:text="@string/app_dubbed_text" android:id="@+id/text_is_dub"
android:id="@+id/text_is_dub" style="@style/DubButton"
style="@style/SearchBox" android:layout_gravity="end" />
android:layout_gravity="end"
android:background="@drawable/dub_bg_color" />
<TextView <TextView
android:id="@+id/text_is_sub" android:id="@+id/text_is_sub"
android:text="@string/app_subbed_text" style="@style/SubButton"
style="@style/SearchBox" android:layout_gravity="end" />
android:layout_gravity="end"
android:background="@drawable/sub_bg_color" />
<TextView <TextView
tools:visibility="visible" android:id="@+id/text_flag"
android:visibility="gone" style="@style/SearchBox"
android:textSize="20sp" android:layout_gravity="end"
android:id="@+id/text_flag" android:background="@color/transparent"
tools:text="🇸🇪" android:textSize="20sp"
style="@style/SearchBox" android:visibility="gone"
android:layout_gravity="end" tools:text="🇸🇪"
android:background="@color/transparent" /> tools:visibility="visible" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<TextView <TextView
tools:text="The Perfect Run\nThe Perfect Run\nhello" android:id="@+id/imageText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="13sp" android:layout_gravity="bottom"
android:gravity="center" android:ellipsize="end"
android:layout_gravity="bottom" android:gravity="center"
android:paddingBottom="5dp" android:maxLines="2"
android:paddingTop="5dp" android:minLines="2"
android:textColor="?attr/textColor" android:paddingStart="5dp"
android:id="@+id/imageText" android:paddingTop="5dp"
android:minLines="2" android:paddingEnd="5dp"
android:maxLines="2" android:paddingBottom="5dp"
android:paddingStart="5dp" android:textColor="?attr/textColor"
android:paddingEnd="5dp" android:textSize="13sp"
android:ellipsize="end" /> tools:text="The Perfect Run\nThe Perfect Run\nhello" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View file

@ -1,98 +1,89 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" 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"
android:layout_width="match_parent" android:id="@+id/search_result_root"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="wrap_content"
android:foreground="@drawable/outline_drawable" android:clickable="true"
android:focusable="true" android:focusable="true"
android:clickable="true" android:foreground="@drawable/outline_drawable"
android:id="@+id/search_result_root"> android:orientation="vertical">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_margin="2dp" android:id="@+id/background_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_marginBottom="2dp"
android:elevation="10dp"
app:cardBackgroundColor="?attr/primaryGrayBackground"
app:cardCornerRadius="@dimen/rounded_image_radius">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="2dp" android:contentDescription="@string/search_poster_img_des"
android:elevation="10dp" android:duplicateParentState="true"
app:cardCornerRadius="@dimen/rounded_image_radius" android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:id="@+id/background_card" android:scaleType="centerCrop" />
app:cardBackgroundColor="?attr/primaryGrayBackground">
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/title_shadow"
android:layout_width="match_parent"
android:duplicateParentState="true" android:layout_height="50dp"
android:scaleType="centerCrop" android:layout_gravity="bottom"
android:layout_width="match_parent" android:clickable="false"
android:layout_height="match_parent" android:focusable="false"
android:foreground="?android:attr/selectableItemBackgroundBorderless" android:src="@drawable/title_shadow"
android:contentDescription="@string/search_poster_img_des" /> tools:ignore="ContentDescription" />
<ImageView
android:focusable="false"
android:clickable="false"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/title_shadow"
android:src="@drawable/title_shadow"
android:layout_gravity="bottom"
tools:ignore="ContentDescription" />
<TextView <TextView
android:id="@+id/imageText" android:id="@+id/imageText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_gravity="bottom"
android:layout_gravity="bottom" android:ellipsize="end"
android:paddingBottom="5dp" android:gravity="center"
android:paddingTop="5dp" android:maxLines="2"
android:textColor="@color/textColor" android:paddingStart="5dp"
android:textStyle="bold" android:paddingTop="5dp"
android:maxLines="2" android:paddingEnd="5dp"
android:paddingStart="5dp" android:paddingBottom="5dp"
android:paddingEnd="5dp" android:textColor="@color/textColor"
android:ellipsize="end" /> android:textStyle="bold" />
<TextView <TextView android:id="@+id/text_quality" style="@style/TypeButton" />
tools:text="@string/quality_hd"
android:id="@+id/text_quality"
android:textColor="@color/textColor"
style="@style/SearchBox"
android:background="@drawable/type_bg_color" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:orientation="vertical">
<TextView
android:id="@+id/text_is_dub"
style="@style/DubButton"
android:layout_gravity="end" />
<TextView
android:id="@+id/text_is_sub"
style="@style/SubButton"
android:layout_gravity="end" />
<TextView
android:id="@+id/text_flag"
style="@style/SearchBox"
android:layout_gravity="end" android:layout_gravity="end"
android:layout_width="match_parent" android:background="@color/transparent"
android:layout_height="match_parent"> android:textSize="20sp"
android:visibility="gone"
<TextView tools:text="🇸🇪"
android:text="@string/app_dubbed_text" tools:visibility="visible" />
android:id="@+id/text_is_dub"
android:layout_gravity="end"
style="@style/SearchBox"
android:background="@drawable/dub_bg_color" />
<TextView
android:id="@+id/text_is_sub"
android:text="@string/app_subbed_text"
android:layout_gravity="end"
style="@style/SearchBox"
android:background="@drawable/sub_bg_color" />
<TextView
tools:visibility="visible"
android:visibility="gone"
android:textSize="20sp"
android:id="@+id/text_flag"
tools:text="🇸🇪"
style="@style/SearchBox"
android:layout_gravity="end"
android:background="@color/transparent" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View file

@ -1,90 +1,81 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" 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"
android:layout_width="match_parent" android:id="@+id/search_result_root"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="wrap_content"
android:foreground="@drawable/outline_drawable" android:clickable="true"
android:focusable="true" android:focusable="true"
android:clickable="true" android:foreground="@drawable/outline_drawable"
android:id="@+id/search_result_root"> android:orientation="vertical">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_margin="2dp" android:id="@+id/background_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="2dp" android:layout_margin="2dp"
android:elevation="10dp" android:layout_marginBottom="2dp"
app:cardCornerRadius="@dimen/rounded_image_radius" android:elevation="10dp"
android:id="@+id/background_card" app:cardBackgroundColor="?attr/primaryGrayBackground"
app:cardBackgroundColor="?attr/primaryGrayBackground"> app:cardCornerRadius="@dimen/rounded_image_radius">
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView"
tools:src="@drawable/example_poster" android:layout_width="match_parent"
android:duplicateParentState="true" android:layout_height="match_parent"
android:scaleType="centerCrop" android:contentDescription="@string/search_poster_img_des"
android:layout_width="match_parent" android:duplicateParentState="true"
android:layout_height="match_parent" android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:foreground="?android:attr/selectableItemBackgroundBorderless" android:scaleType="centerCrop"
android:contentDescription="@string/search_poster_img_des" /> tools:src="@drawable/example_poster" />
<TextView <TextView android:id="@+id/text_quality" style="@style/TypeButton" />
tools:text="@string/quality_hd"
android:id="@+id/text_quality"
android:textColor="@color/textColor"
style="@style/SearchBox"
android:background="@drawable/type_bg_color" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:orientation="vertical">
<TextView
android:id="@+id/text_is_dub"
style="@style/DubButton"
android:layout_gravity="end" />
<TextView
android:id="@+id/text_is_sub"
style="@style/SubButton"
android:layout_gravity="end" />
<TextView
android:id="@+id/text_flag"
style="@style/SearchBox"
android:layout_gravity="end" android:layout_gravity="end"
android:layout_width="match_parent" android:background="@color/transparent"
android:layout_height="match_parent"> android:textSize="20sp"
android:visibility="gone"
<TextView tools:text="🇸🇪"
android:text="@string/app_dubbed_text" tools:visibility="visible" />
android:id="@+id/text_is_dub"
android:layout_gravity="end"
style="@style/SearchBox"
android:background="@drawable/dub_bg_color" />
<TextView
android:id="@+id/text_is_sub"
android:text="@string/app_subbed_text"
android:layout_gravity="end"
style="@style/SearchBox"
android:background="@drawable/sub_bg_color" />
<TextView
tools:visibility="visible"
android:visibility="gone"
android:textSize="20sp"
android:id="@+id/text_flag"
tools:text="🇸🇪"
style="@style/SearchBox"
android:layout_gravity="end"
android:background="@color/transparent" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<TextView <TextView
tools:text="The Perfect Run\nThe Perfect Run" android:id="@+id/imageText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="13sp" android:layout_gravity="bottom"
android:gravity="center" android:ellipsize="end"
android:layout_gravity="bottom" android:gravity="center"
android:paddingBottom="5dp" android:maxLines="2"
android:paddingTop="5dp" android:minLines="2"
android:textColor="?attr/textColor" android:paddingStart="5dp"
android:id="@+id/imageText" android:paddingTop="5dp"
android:minLines="2" android:paddingEnd="5dp"
android:maxLines="2" android:paddingBottom="5dp"
android:paddingStart="5dp" android:textColor="?attr/textColor"
android:paddingEnd="5dp" android:textSize="13sp"
android:ellipsize="end" /> tools:text="The Perfect Run\nThe Perfect Run" />
</LinearLayout> </LinearLayout>

View file

@ -25,13 +25,13 @@
<color name="whiteText">#FFF</color> <color name="whiteText">#FFF</color>
<color name="blackText">#000</color> <color name="blackText">#000</color>
<color name="dubColor">#3d50fa</color> <!--3b65f5 f18c82 8294F1--> <color name="dubColorText">#121950</color> <!--3b65f5 f18c82 8294F1-->
<color name="amoledModeLight">#121213</color> <color name="amoledModeLight">#121213</color>
<color name="dubColorBg">#3B65F5</color> <color name="dubColorBg">#3B65F5</color>
<color name="subColor">#F54A3B</color> <!--F53B66 FA3D79--> <color name="subColorText">#571711</color> <!--F53B66 FA3D79-->
<color name="subColorBg">#F53B66</color> <color name="subColorBg">#F53B66</color>
<color name="typeColor">#3BF585</color> <color name="typeColorText">#BEC8FF</color>
<color name="typeColorBg">?attr/colorPrimaryDark</color> <color name="typeColorBg">?attr/colorPrimaryDark</color>
<color name="adultColor">#FF6F63</color> <!-- same as sub color --> <color name="adultColor">#FF6F63</color> <!-- same as sub color -->

View file

@ -16,5 +16,4 @@
<integer name="loading_time">2000</integer> <integer name="loading_time">2000</integer>
<dimen name="storage_radius">3dp</dimen> <dimen name="storage_radius">3dp</dimen>
</resources> </resources>

View file

@ -97,6 +97,24 @@
<item name="white">@color/white</item> <item name="white">@color/white</item>
<item name="colorOnPrimary">@color/whiteText</item> <item name="colorOnPrimary">@color/whiteText</item>
</style> </style>
<style name="DubButton" parent="@style/SearchBox">
<item name="android:background">@drawable/dub_bg_color</item>
<item name="android:text">@string/app_dubbed_text</item>
<item name="android:textColor">@color/dubColorText</item>
</style>
<style name="SubButton" parent="@style/SearchBox">
<item name="android:background">@drawable/sub_bg_color</item>
<item name="android:text">@string/app_subbed_text</item>
<item name="android:textColor">@color/subColorText</item>
</style>
<style name="TypeButton" parent="@style/SearchBox">
<item name="android:background">@drawable/type_bg_color</item>
<item name="android:text">@string/quality_hd</item>
<item name="android:textColor">@color/typeColorText</item>
</style>
<style name="LightMode"> <style name="LightMode">
<item name="primaryGrayBackground">@color/lightPrimaryGrayBackground</item> <item name="primaryGrayBackground">@color/lightPrimaryGrayBackground</item>
@ -461,10 +479,10 @@
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginBottom">5dp</item> <item name="android:layout_marginBottom">5dp</item>
<item name="android:paddingLeft">10dp</item> <item name="android:paddingLeft">7dp</item>
<item name="android:paddingRight">10dp</item> <item name="android:paddingRight">7dp</item>
<item name="android:paddingTop">5dp</item> <item name="android:paddingTop">3dp</item>
<item name="android:paddingBottom">5dp</item> <item name="android:paddingBottom">3dp</item>
<item name="android:textSize">12sp</item> <item name="android:textSize">12sp</item>
<item name="textColor">@color/textColor</item> <item name="textColor">@color/textColor</item>
<item name="android:textColor">@color/textColor</item> <item name="android:textColor">@color/textColor</item>