From f0df8ec39120bc1ea9434443cbd5c19aabfc90e2 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Sat, 26 Jun 2021 19:03:22 +0200 Subject: [PATCH] sum UI --- .../cloudstream3/ui/result/ResultFragment.kt | 53 +++++++++----- app/src/main/res/drawable/play_button.xml | 25 +++++++ app/src/main/res/layout/fragment_result.xml | 52 +++++++------- app/src/main/res/layout/result_episode.xml | 3 - .../main/res/layout/result_episode_large.xml | 71 +++++++++++++++++++ app/src/main/res/values/dimens.xml | 3 +- app/src/main/res/values/strings.xml | 2 + 7 files changed, 165 insertions(+), 44 deletions(-) create mode 100644 app/src/main/res/drawable/play_button.xml create mode 100644 app/src/main/res/layout/result_episode_large.xml diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index bda55be9..fd6bb98c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -5,19 +5,22 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle +import android.text.Spannable +import android.text.SpannableString +import android.text.SpannableStringBuilder import android.view.LayoutInflater import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import android.view.ViewGroup -import android.widget.FrameLayout import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.coordinatorlayout.widget.CoordinatorLayout +import androidx.core.content.ContextCompat +import androidx.core.text.color import androidx.core.widget.NestedScrollView import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentActivity import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -35,7 +38,6 @@ import com.lagradost.cloudstream3.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.UIHelper.getStatusBarHeight import com.lagradost.cloudstream3.UIHelper.isCastApiAvailable import com.lagradost.cloudstream3.UIHelper.popCurrentPage -import com.lagradost.cloudstream3.UIHelper.popupMenu import com.lagradost.cloudstream3.UIHelper.popupMenuNoIcons import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.observe @@ -246,10 +248,10 @@ class ResultFragment : Fragment() { getApiFromName(apiName).instantLinkLoading } else false - var dialog : AlertDialog? = null + var dialog: AlertDialog? = null val currentLoad = currentLoadingCount - if(!skipLoading) { + if (!skipLoading) { val builder = AlertDialog.Builder(requireContext(), R.style.AlertDialogCustomTransparent) val customLayout = layoutInflater.inflate(R.layout.dialog_loading, null) builder.setView(customLayout) @@ -384,11 +386,36 @@ class ResultFragment : Fragment() { startActivity(Intent.createChooser(i, d.name)) } - if (d.year != null) { - result_year.visibility = VISIBLE - result_year.text = d.year.toString() + val metadataInfoArray = ArrayList>() + if (d is AnimeLoadResponse) { + val status = when (d.showStatus) { + null -> null + ShowStatus.Ongoing -> "Ongoing" + ShowStatus.Completed -> "Completed" + } + if (status != null) { + metadataInfoArray.add(Pair("Status", status)) + } + } + if (d.year != null) metadataInfoArray.add(Pair("Year", d.year.toString())) + val rating = d.rating + if (rating != null) metadataInfoArray.add(Pair("Rating", + "%.2f/10.0".format(rating.toFloat() / 10f).replace(",", "."))) + val duration = d.duration + if (duration != null) metadataInfoArray.add(Pair("Duration", duration)) + + if (metadataInfoArray.size > 0) { + result_metadata.visibility = VISIBLE + val text = SpannableStringBuilder() + val grayColor = ContextCompat.getColor(requireContext(), R.color.grayTextColor) + val textColor = ContextCompat.getColor(requireContext(), R.color.textColor) + for (meta in metadataInfoArray) { + text.color(grayColor) { append("${meta.first}: ") } + .color(textColor) { append("${meta.second}\n") } + } + result_metadata.text = text } else { - result_year.visibility = GONE + result_metadata.visibility = GONE } if (d.posterUrl != null) { @@ -481,7 +508,7 @@ activity?.startActivityForResult(vlcIntent, REQUEST_CODE) result_tag.removeAllViews() result_tag_holder.visibility = GONE - result_status.visibility = GONE + // result_status.visibility = GONE val tags = d.tags if (tags == null) { @@ -528,12 +555,6 @@ activity?.startActivityForResult(vlcIntent, REQUEST_CODE) when (d) { is AnimeLoadResponse -> { - result_status.visibility = VISIBLE - result_status.text = when (d.showStatus) { - null -> "" - ShowStatus.Ongoing -> "Ongoing" - ShowStatus.Completed -> "Completed" - } // val preferEnglish = true //val titleName = (if (preferEnglish) d.engName else d.japName) ?: d.name diff --git a/app/src/main/res/drawable/play_button.xml b/app/src/main/res/drawable/play_button.xml new file mode 100644 index 00000000..04886b6e --- /dev/null +++ b/app/src/main/res/drawable/play_button.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/app/src/main/res/layout/fragment_result.xml b/app/src/main/res/layout/fragment_result.xml index be21ed4d..de709564 100644 --- a/app/src/main/res/layout/fragment_result.xml +++ b/app/src/main/res/layout/fragment_result.xml @@ -63,7 +63,8 @@ - + @@ -145,33 +149,33 @@ tools:text="The Perfect Run The Perfect Run The Perfect Run" android:id="@+id/result_title" android:textSize="20sp" - android:textStyle="bold" + android:textStyle="normal" android:textColor="?attr/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content"> + + - - - - + - - - \ No newline at end of file diff --git a/app/src/main/res/layout/result_episode_large.xml b/app/src/main/res/layout/result_episode_large.xml new file mode 100644 index 00000000..de2973a9 --- /dev/null +++ b/app/src/main/res/layout/result_episode_large.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 38c87f8c..ae146164 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -2,7 +2,8 @@ 16dp 16dp - 1dp + 5dp 0dp 2dp + 15dp \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 371ed63a..d4d7a345 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,4 +34,6 @@ Pick Source Retry connection… Go Back + Episode Poster + Play Episode \ No newline at end of file