mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Use bottom dialogs for synopsis (#709)
* Use bottom dialogs for synopsis * Add bottomTextDialog
This commit is contained in:
parent
504258bf15
commit
e4ba852007
3 changed files with 68 additions and 19 deletions
|
@ -17,7 +17,6 @@ import android.view.animation.DecelerateInterpolator
|
|||
import android.widget.AbsListView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.NestedScrollView
|
||||
|
@ -66,6 +65,7 @@ import com.lagradost.cloudstream3.utils.AppUtils.openBrowser
|
|||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogInstant
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogText
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
||||
import com.lagradost.cloudstream3.utils.UIHelper
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||
|
@ -681,14 +681,13 @@ open class ResultFragmentPhone : FullScreenPlayer() {
|
|||
resultPoster.setImage(d.posterImage)
|
||||
resultPosterBackground.setImage(d.posterBackgroundImage)
|
||||
resultDescription.setTextHtml(d.plotText)
|
||||
resultDescription.setOnClickListener { view ->
|
||||
// todo bottom view?
|
||||
view.context?.let { ctx ->
|
||||
val builder: AlertDialog.Builder =
|
||||
AlertDialog.Builder(ctx, R.style.AlertDialogCustom)
|
||||
builder.setMessage(d.plotText.asString(ctx).html())
|
||||
.setTitle(d.plotHeaderText.asString(ctx))
|
||||
.show()
|
||||
resultDescription.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
activity.showBottomDialogText(
|
||||
d.titleText.asString(activity),
|
||||
d.plotText.asString(activity).html(),
|
||||
{}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -879,16 +878,11 @@ open class ResultFragmentPhone : FullScreenPlayer() {
|
|||
setRecommendations(recommendations, null)
|
||||
}
|
||||
observe(viewModel.episodeSynopsis) { description ->
|
||||
// TODO bottom dialog
|
||||
view.context?.let { ctx ->
|
||||
val builder: AlertDialog.Builder =
|
||||
AlertDialog.Builder(ctx, R.style.AlertDialogCustom)
|
||||
builder.setMessage(description.html())
|
||||
.setTitle(R.string.synopsis)
|
||||
.setOnDismissListener {
|
||||
viewModel.releaseEpisodeSynopsis()
|
||||
}
|
||||
.show()
|
||||
activity?.let { activity ->
|
||||
activity.showBottomDialogText(
|
||||
activity.getString(R.string.synopsis),
|
||||
description.html()
|
||||
) { viewModel.releaseEpisodeSynopsis() }
|
||||
}
|
||||
}
|
||||
context?.let { ctx ->
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.lagradost.cloudstream3.utils
|
|||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.text.Spanned
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.AbsListView
|
||||
|
@ -19,6 +20,7 @@ import androidx.core.view.marginRight
|
|||
import androidx.core.view.marginTop
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.BottomTextDialogBinding
|
||||
import com.lagradost.cloudstream3.databinding.BottomSelectionDialogBinding
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
|
@ -363,4 +365,24 @@ object SingleSelectionHelper {
|
|||
dismissCallback
|
||||
)
|
||||
}
|
||||
|
||||
fun Activity.showBottomDialogText(
|
||||
title: String,
|
||||
text: Spanned,
|
||||
dismissCallback: () -> Unit
|
||||
) {
|
||||
val binding = BottomTextDialogBinding.inflate(layoutInflater)
|
||||
val dialog = BottomSheetDialog(this)
|
||||
|
||||
dialog.setContentView(binding.root)
|
||||
|
||||
binding.dialogTitle.text = title
|
||||
binding.dialogText.text = text
|
||||
|
||||
dialog.setOnDismissListener {
|
||||
dismissCallback.invoke()
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
|
|
33
app/src/main/res/layout/bottom_text_dialog.xml
Normal file
33
app/src/main/res/layout/bottom_text_dialog.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_title"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textStyle="bold"
|
||||
android:textSize="20sp"
|
||||
android:textColor="?attr/textColor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_rowWeight="1"
|
||||
tools:text="Test"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_text"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:paddingTop="10dp"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_rowWeight="1" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue