From db3e23621a8903c88b71f9521ab4e74226ddda4f Mon Sep 17 00:00:00 2001 From: reduplicated <110570621+reduplicated@users.noreply.github.com> Date: Fri, 19 Aug 2022 20:28:03 +0200 Subject: [PATCH] fixed UI --- .../ui/settings/extensions/PluginAdapter.kt | 21 ++++++++---- .../lagradost/cloudstream3/utils/AppUtils.kt | 2 +- .../cloudstream3/utils/SubtitleHelper.kt | 6 ++-- app/src/main/res/layout/repository_item.xml | 32 +++++++++++-------- app/src/main/res/values/colors.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt index f27c53e4..8fa18b0c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt @@ -12,9 +12,11 @@ import androidx.recyclerview.widget.RecyclerView import com.lagradost.cloudstream3.PROVIDER_STATUS_DOWN import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.plugins.PluginManager +import com.lagradost.cloudstream3.ui.result.setText +import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.utils.AppUtils.html import com.lagradost.cloudstream3.utils.GlideApp -import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso +import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTwoLettersToLanguage import com.lagradost.cloudstream3.utils.UIHelper.setImage import com.lagradost.cloudstream3.utils.UIHelper.toPx import kotlinx.android.synthetic.main.repository_item.view.* @@ -93,8 +95,9 @@ class PluginAdapter( Assert.assertEquals(512, findClosestBase2(700)) } - val iconSize by lazy { - findClosestBase2(32.toPx, 16, 512) + private val iconSizeExact = 32.toPx + private val iconSize by lazy { + findClosestBase2(iconSizeExact, 16, 512) } } @@ -105,7 +108,8 @@ class PluginAdapter( data: PluginViewData, ) { val metadata = data.plugin.second - val alpha = if (metadata.status == PROVIDER_STATUS_DOWN) 0.6f else 1f + val disabled = metadata.status == PROVIDER_STATUS_DOWN + val alpha = if (disabled) 0.6f else 1f itemView.main_text?.alpha = alpha itemView.sub_text?.alpha = alpha @@ -157,6 +161,9 @@ class PluginAdapter( metadata.iconUrl?.replace( "%size%", "$iconSize" + )?.replace( + "%exact_size%", + "$iconSizeExact" ), null, errorImageDrawable = R.drawable.ic_baseline_extension_24 @@ -170,7 +177,8 @@ class PluginAdapter( if (metadata.language != null) { itemView.lang_icon?.isVisible = true - itemView.lang_icon.text = getFlagFromIso(metadata.language) + //itemView.lang_icon.text = getFlagFromIso(metadata.language) + itemView.lang_icon.text = fromTwoLettersToLanguage(metadata.language) } else { itemView.lang_icon?.isVisible = false } @@ -182,8 +190,7 @@ class PluginAdapter( } else { itemView.ext_filesize?.isVisible = false } - - itemView.main_text?.text = metadata.name + itemView.main_text.setText(if(disabled) txt(R.string.single_plugin_disabled, metadata.name) else txt(metadata.name)) itemView.sub_text?.isGone = metadata.description.isNullOrBlank() itemView.sub_text?.text = metadata.description.html() } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt index 9a9d370a..9b75fe14 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt @@ -75,7 +75,7 @@ object AppUtils { val layoutManager = this.layoutManager as? LinearLayoutManager? val adapter = adapter - return if (layoutManager == null || adapter == null) false else layoutManager.findLastCompletelyVisibleItemPosition() < adapter.itemCount - 2 + return if (layoutManager == null || adapter == null) false else layoutManager.findLastCompletelyVisibleItemPosition() < adapter.itemCount - 7 // bit more than 1 to make it more seamless } //fun Context.deleteFavorite(data: SearchResponse) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt index 0d761560..13b72664 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt @@ -138,14 +138,14 @@ object SubtitleHelper { private fun getFlagFromIsoShort(flagAscii: String?): String? { if (flagAscii.isNullOrBlank() || flagAscii.length < 2) return null - try { + return try { val firstChar: Int = Character.codePointAt(flagAscii, 0) + offset val secondChar: Int = Character.codePointAt(flagAscii, 1) + offset - return (String(Character.toChars(firstChar)) + String(Character.toChars(secondChar))) + (String(Character.toChars(firstChar)) + String(Character.toChars(secondChar))) } catch (e: Exception) { logError(e) - return null + null } } diff --git a/app/src/main/res/layout/repository_item.xml b/app/src/main/res/layout/repository_item.xml index edae9904..8da3d58c 100644 --- a/app/src/main/res/layout/repository_item.xml +++ b/app/src/main/res/layout/repository_item.xml @@ -30,6 +30,7 @@ android:id="@+id/main_text" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="?attr/textColor" android:textSize="16sp" tools:text="Test repository" /> @@ -42,9 +43,10 @@ @@ -53,17 +55,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" + android:layout_marginStart="5dp" android:text="v1" - android:visibility="gone" - tools:visibility="visible" /> - - @@ -72,9 +66,19 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_marginStart="8dp" - android:layout_weight="1" + android:layout_marginStart="5dp" android:text="100MB" + android:textColor="?attr/grayTextColor" + android:visibility="gone" + tools:visibility="visible" /> + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 04c11d22..d745c7a1 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -31,7 +31,7 @@ #3BF585 ?attr/colorPrimaryDark - #F54A3B + #FF6F63 #80FFFFFF #32FFFFFF diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 47d4c11c..873de287 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -602,4 +602,5 @@ Uppercase all subtitles Download all plugins from this repository? + %s (Disabled)