From 318230dd09bbd2413ad9bfdf9852e4e16e8ce9fd Mon Sep 17 00:00:00 2001 From: C10udburst <18114966+C10udburst@users.noreply.github.com> Date: Fri, 19 Aug 2022 10:59:11 +0200 Subject: [PATCH] UI improvements - add file size to plugin entries. - move flag, version and +18 around - make icon size compatible with stuff other than google favicons --- .../cloudstream3/plugins/PluginManager.kt | 3 +- .../cloudstream3/plugins/RepositoryManager.kt | 2 + .../ui/settings/extensions/PluginAdapter.kt | 19 +++-- app/src/main/res/layout/repository_item.xml | 82 +++++++++++-------- app/src/main/res/values/colors.xml | 2 + 5 files changed, 65 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt index d66a6d56..cab3b197 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt @@ -57,7 +57,8 @@ data class PluginData( null, null, null, - null + null, + File(this.filePath).length() ) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt index ea60459d..0f6e0368 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt @@ -60,6 +60,8 @@ data class SitePlugin( @JsonProperty("tvTypes") val tvTypes: List?, @JsonProperty("language") val language: String?, @JsonProperty("iconUrl") val iconUrl: String?, + // Automatically generated by the gradle plugin + @JsonProperty("fileSize") val fileSize: Long?, ) 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 670270ba..f27c53e4 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 @@ -1,8 +1,7 @@ package com.lagradost.cloudstream3.ui.settings.extensions -import android.content.res.Resources +import android.text.format.Formatter.formatShortFileSize import android.util.Log -import android.util.TypedValue import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -95,7 +94,7 @@ class PluginAdapter( } val iconSize by lazy { - findClosestBase2(24.toPx, 16, 512) + findClosestBase2(32.toPx, 16, 512) } } @@ -156,9 +155,9 @@ class PluginAdapter( if (itemView.entry_icon?.setImage(//itemView.entry_icon?.height ?: metadata.iconUrl?.replace( - "&sz=24", - "&sz=$iconSize" - ), // lazy fix for better resolution + "%size%", + "$iconSize" + ), null, errorImageDrawable = R.drawable.ic_baseline_extension_24 ) != true @@ -176,6 +175,14 @@ class PluginAdapter( itemView.lang_icon?.isVisible = false } + + if (metadata.fileSize != null) { + itemView.ext_filesize?.isVisible = true + itemView.ext_filesize?.text = formatShortFileSize(itemView.context, metadata.fileSize) + } else { + itemView.ext_filesize?.isVisible = false + } + itemView.main_text?.text = metadata.name itemView.sub_text?.isGone = metadata.description.isNullOrBlank() itemView.sub_text?.text = metadata.description.html() diff --git a/app/src/main/res/layout/repository_item.xml b/app/src/main/res/layout/repository_item.xml index 26976b9b..edae9904 100644 --- a/app/src/main/res/layout/repository_item.xml +++ b/app/src/main/res/layout/repository_item.xml @@ -5,45 +5,45 @@ android:id="@+id/repository_item_root" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:nextFocusRight="@id/action_button" android:background="?attr/selectableItemBackground" - android:padding="20dp"> + android:nextFocusRight="@id/action_button" + android:orientation="horizontal" + android:padding="12dp"> + + - - @@ -53,9 +53,28 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_marginStart="8dp" android:text="v1" - android:textColor="@color/colorPrimaryGrey" + android:visibility="gone" + tools:visibility="visible" /> + + + + @@ -70,39 +89,30 @@ tools:text="https://github.com/..." /> - - + tools:visibility="visible" /> + android:nextFocusLeft="@id/repository_item_root" + android:padding="12dp" + tools:src="@drawable/ic_baseline_add_24" /> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4a9a9cd1..04c11d22 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -31,6 +31,8 @@ #3BF585 ?attr/colorPrimaryDark + #F54A3B + #80FFFFFF #32FFFFFF