From c2ba8dc7e4cc1e9d15ed9c4f77e73332e279d5f0 Mon Sep 17 00:00:00 2001 From: Jace <54625750+Jacekun@users.noreply.github.com> Date: Mon, 21 Mar 2022 07:25:25 +0800 Subject: [PATCH] [Feature] View poster image on fullscreen, when its clicked or tapped. (#824) * View poster image on fullscreen, when its clicked or tapped. * fix missing string * inflate dialog from context * changed inflation to alertdialog custom dialog * [skip ci] remove unused imports * various changes * additional change * xml changes * Update ResultFragment.kt Co-authored-by: Osten <11805592+LagradOst@users.noreply.github.com> --- .../cloudstream3/ui/result/ResultFragment.kt | 33 ++++++++++++++++--- app/src/main/res/layout/result_poster.xml | 18 ++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/layout/result_poster.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 bc13a387..3c9d4f19 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 @@ -17,11 +17,13 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import android.view.ViewGroup +import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog import androidx.core.content.FileProvider +import androidx.core.graphics.drawable.toBitmap import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.core.widget.NestedScrollView @@ -1358,9 +1360,32 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio result_meta_site?.text = d.apiName - if (!d.posterUrl.isNullOrEmpty()) { - result_poster?.setImage(d.posterUrl) - result_poster_blur?.setImageBlur(d.posterUrl, 10, 3) + val posterImageLink = d.posterUrl + if (!posterImageLink.isNullOrEmpty()) { + result_poster?.setImage(posterImageLink) + result_poster_blur?.setImageBlur(posterImageLink, 10, 3) + //Full screen view of Poster image + result_poster_holder?.setOnClickListener { + try { + context?.let { ctx -> + val bitmap = result_poster.drawable.toBitmap() + val sourceBuilder = AlertDialog.Builder(ctx) + sourceBuilder.setView(R.layout.result_poster) + + val sourceDialog = sourceBuilder.create() + sourceDialog.show() + + sourceDialog.findViewById(R.id.imgPoster)?.apply { + setImageBitmap(bitmap) + setOnClickListener { + sourceDialog.dismissSafe() + } + } + } + } catch (e: Exception) { + logError(e) + } + } } else { result_poster?.setImageResource(R.drawable.default_cover) result_poster_blur?.setImageResource(R.drawable.default_cover) @@ -1681,4 +1706,4 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio override fun onGestureRegionsUpdate(gestureRegions: List) { result_overlapping_panels?.setChildGestureRegions(gestureRegions) } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/result_poster.xml b/app/src/main/res/layout/result_poster.xml new file mode 100644 index 00000000..f87b5b4e --- /dev/null +++ b/app/src/main/res/layout/result_poster.xml @@ -0,0 +1,18 @@ + + + + \ 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 fd7b0676..566f3516 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -429,4 +429,5 @@ Background Source + Poster Image