fixed bottom dialog style + bugfix

This commit is contained in:
LagradOst 2022-08-03 03:02:08 +02:00
parent a99713fe0c
commit d763b4a7aa
30 changed files with 103 additions and 55 deletions

View File

@ -680,6 +680,7 @@ class ResultFragment : ResultTrailerPlayer() {
val d = meta.value
result_sync_episodes?.progress = currentSyncProgress * 1000
setSyncMaxEpisodes(d.totalEpisodes)
viewModel.setMeta(d, syncModel.getSyncs())
}
is Resource.Loading -> {
@ -904,7 +905,6 @@ class ResultFragment : ResultTrailerPlayer() {
}
observe(viewModel.selectPopup) { popup ->
println("POPUPSTATUS:$popup")
when (popup) {
is Some.Success -> {
popupDialog?.dismissSafe(activity)
@ -917,10 +917,10 @@ class ResultFragment : ResultTrailerPlayer() {
act.showBottomDialogInstant(
options, title, {
popupDialog = null
pop.callback(context ?: return@showBottomDialogInstant, null)
pop.callback(null)
}, {
popupDialog = null
pop.callback(context ?: return@showBottomDialogInstant, it)
pop.callback(it)
}
)
}
@ -938,7 +938,7 @@ class ResultFragment : ResultTrailerPlayer() {
when (load) {
is Some.Success -> {
if(loadingDialog?.isShowing != true) {
if (loadingDialog?.isShowing != true) {
loadingDialog?.dismissSafe(activity)
loadingDialog = null
}
@ -999,7 +999,6 @@ class ResultFragment : ResultTrailerPlayer() {
}
observe(viewModel.rangeSelections) { range ->
println("RANGE:$range")
result_episode_select?.setOnClickListener { view ->
view?.context?.let { ctx ->
val names = range

View File

@ -17,6 +17,7 @@ import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.getId
import com.lagradost.cloudstream3.APIHolder.unixTime
import com.lagradost.cloudstream3.CommonActivity.getCastSession
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.LoadResponse.Companion.getAniListId
import com.lagradost.cloudstream3.LoadResponse.Companion.getMalId
@ -37,6 +38,7 @@ import com.lagradost.cloudstream3.ui.player.SubtitleData
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
import com.lagradost.cloudstream3.utils.AppUtils.isAppInstalled
import com.lagradost.cloudstream3.utils.AppUtils.isConnectedToChromecast
import com.lagradost.cloudstream3.utils.CastHelper.startCast
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
@ -234,26 +236,23 @@ sealed class SelectPopup {
data class SelectArray(
val text: UiText,
val options: Int,
val map: Int?,
val options: List<Pair<UiText, Int>>,
val callback: (Int?) -> Unit
) : SelectPopup()
}
fun SelectPopup.callback(context: Context, input: Int?) {
val ret = transformResult(context, input)
fun SelectPopup.callback(index: Int?) {
val ret = transformResult(index)
return when (this) {
is SelectPopup.SelectArray -> callback(ret)
is SelectPopup.SelectText -> callback(ret)
}
}
fun SelectPopup.transformResult(context: Context, input: Int?): Int? {
fun SelectPopup.transformResult(input: Int?): Int? {
if (input == null) return null
return when (this) {
is SelectPopup.SelectArray -> context.resources.getIntArray(map ?: return input)
.getOrNull(input)
?: input
is SelectPopup.SelectArray -> options.getOrNull(input)?.second
is SelectPopup.SelectText -> input
}
}
@ -268,11 +267,7 @@ fun SelectPopup.getTitle(context: Context): String {
fun SelectPopup.getOptions(context: Context): List<String> {
return when (this) {
is SelectPopup.SelectArray -> {
val cmap = this.map?.let { context.resources.getIntArray(it) }
context.resources.getStringArray(options).toList().filterIndexed { index, s ->
true
}
this.options.map { it.first.asString(context) }
}
is SelectPopup.SelectText -> options.map { it.asString(context) }
}
@ -637,7 +632,7 @@ class ResultViewModel2 : ViewModel() {
parentId: Int,
url: String,
) {
safeApiCall {
ioSafe {
val generator = RepoLinkGenerator(listOf(episode))
val currentLinks = mutableSetOf<ExtractorLink>()
val currentSubs = mutableSetOf<SubtitleData>()
@ -657,7 +652,15 @@ class ResultViewModel2 : ViewModel() {
Toast.LENGTH_SHORT
)
}
return@safeApiCall
return@ioSafe
} else {
Coroutines.main {
CommonActivity.showToast(
activity,
R.string.download_started,
Toast.LENGTH_SHORT
)
}
}
startDownload(
@ -784,17 +787,16 @@ class ResultViewModel2 : ViewModel() {
)
}
@JvmName("postPopupArray")
private fun postPopup(
text: UiText,
options: Int,
values: Int,
options: List<Pair<UiText, Int>>,
callback: suspend (Int?) -> Unit
) {
_selectPopup.postValue(
some(SelectPopup.SelectArray(
text,
options,
values
) { value ->
viewModelScope.launch {
_selectPopup.value = Some.None
@ -893,6 +895,10 @@ class ResultViewModel2 : ViewModel() {
private fun playWithVlc(act: Activity?, data: LinkLoadingResult, id: Int) = ioSafe {
if (act == null) return@ioSafe
if (data.links.isEmpty()) {
showToast(act, R.string.no_links_found_toast, Toast.LENGTH_SHORT)
return@ioSafe
}
try {
if (!act.checkWrite()) {
act.requestRW()
@ -955,6 +961,31 @@ class ResultViewModel2 : ViewModel() {
private suspend fun handleEpisodeClickEvent(activity: Activity?, click: EpisodeClickEvent) {
when (click.action) {
ACTION_SHOW_OPTIONS -> {
val options = mutableListOf<Pair<UiText, Int>>()
if (activity?.isConnectedToChromecast() == true) {
options.addAll(
listOf(
txt(R.string.episode_action_chromecast_episode) to ACTION_CHROME_CAST_EPISODE,
txt(R.string.episode_action_chromecast_mirror) to ACTION_CHROME_CAST_MIRROR,
)
)
}
options.add(txt(R.string.episode_action_play_in_app) to ACTION_PLAY_EPISODE_IN_PLAYER)
if (activity?.isAppInstalled(VLC_PACKAGE) == true) {
options.add(txt(R.string.episode_action_play_in_vlc) to ACTION_PLAY_EPISODE_IN_VLC_PLAYER)
}
options.addAll(
listOf(
txt(R.string.episode_action_play_in_browser) to ACTION_PLAY_EPISODE_IN_BROWSER,
txt(R.string.episode_action_copy_link) to ACTION_COPY_LINK,
txt(R.string.episode_action_auto_download) to ACTION_DOWNLOAD_EPISODE,
txt(R.string.episode_action_download_mirror) to ACTION_DOWNLOAD_MIRROR,
txt(R.string.episode_action_download_subtitle) to ACTION_DOWNLOAD_EPISODE_SUBTITLE_MIRROR,
txt(R.string.episode_action_reload_links) to ACTION_RELOAD_EPISODE,
)
)
postPopup(
txt(
activity?.getNameFull(
@ -963,8 +994,7 @@ class ResultViewModel2 : ViewModel() {
click.data.season
) ?: ""
), // TODO FIX
R.array.episode_long_click_options,
R.array.episode_long_click_options_values
options
) { result ->
handleEpisodeClickEvent(
activity,
@ -987,7 +1017,13 @@ class ResultViewModel2 : ViewModel() {
}
}
}
/* not implemented, not used
ACTION_DOWNLOAD_EPISODE_SUBTITLE -> {
loadLinks(click.data, isVisible = false, isCasting = false) { links ->
downloadSubtitle(activity,links.subs,)
}
}*/
ACTION_DOWNLOAD_EPISODE_SUBTITLE_MIRROR -> {
val response = currentResponse ?: return
acquireSingleSubtitle(
@ -1071,7 +1107,7 @@ class ResultViewModel2 : ViewModel() {
ACTION_CHROME_CAST_MIRROR -> {
acquireSingleLink(
click.data,
false,
isCasting = true,
txt(R.string.episode_action_chromecast_mirror)
) { (result, index) ->
startChromecast(activity, click.data, result.links, result.subs, index)
@ -1079,7 +1115,7 @@ class ResultViewModel2 : ViewModel() {
}
ACTION_PLAY_EPISODE_IN_BROWSER -> acquireSingleLink(
click.data,
false,
isCasting = true,
txt(R.string.episode_action_play_in_browser)
) { (result, index) ->
try {
@ -1093,7 +1129,7 @@ class ResultViewModel2 : ViewModel() {
ACTION_COPY_LINK -> {
acquireSingleLink(
click.data,
false,
isCasting = true,
txt(R.string.episode_action_copy_link)
) { (result, index) ->
val act = activity ?: return@acquireSingleLink
@ -1216,9 +1252,14 @@ class ResultViewModel2 : ViewModel() {
return out to updateEpisodes
}
fun setMeta(meta: SyncAPI.SyncResult, syncs: Map<String, String>?) =
fun setMeta(meta: SyncAPI.SyncResult, syncs: Map<String, String>?) {
// I dont want to update everything if the metadata is not relevant
if (currentMeta == meta && currentSync == syncs) {
Log.i(TAG, "setMeta same")
return
}
Log.i(TAG, "setMeta")
viewModelScope.launch {
Log.i(TAG, "setMeta")
currentMeta = meta
currentSync = syncs
val (value, updateEpisodes) = Coroutines.ioWork {
@ -1235,6 +1276,7 @@ class ResultViewModel2 : ViewModel() {
false
)
}
}
private suspend fun updateFillers(name: String) {

View File

@ -16,7 +16,7 @@
android:textColor="?attr/textColor"
android:layout_width="match_parent"
android:layout_rowWeight="1"
android:text="@string/loading_chromecast"
android:text="@string/loading"
android:layout_height="wrap_content" />
<androidx.core.widget.ContentLoadingProgressBar

View File

@ -12,7 +12,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loading_chromecast"
android:text="@string/loading"
android:layout_gravity="center"
android:textColor="@color/textColor"
android:textSize="20sp"

View File

@ -5,6 +5,7 @@
android:id="@+id/result_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/DarkFragment"
android:background="?attr/primaryBlackBackground"
android:clickable="true"
android:focusable="true">

View File

@ -2,6 +2,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
style="@style/AlertDialogCustom"
android:layout_width="match_parent"
android:layout_height="match_parent">

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/DarkFragment"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/quick_search_root"

View File

@ -29,7 +29,7 @@
<string name="result_share">شارك</string>
<string name="result_open_in_browser">فتح في الويب </string>
<string name="skip_loading">تخطي التحميل</string>
<string name="loading_chromecast">…تحميل</string>
<string name="loading">…تحميل</string>
<string name="type_watching">مشاهدة</string>
<string name="type_on_hold">في الانتظار</string>

View File

@ -108,7 +108,7 @@
<string name="result_share">Compartilhar</string>
<string name="result_open_in_browser">Abrir no Navegador</string>
<string name="skip_loading">Pular Carregamento</string>
<string name="loading_chromecast">Carregando…</string>
<string name="loading">Carregando…</string>
<string name="type_watching">Assistindo</string>
<string name="type_on_hold">Em espera</string>

View File

@ -101,7 +101,7 @@
<string name="result_share">Sdílet</string>
<string name="result_open_in_browser">Otevřít v prohlížeči</string>
<string name="skip_loading">Přeskočit načítání</string>
<string name="loading_chromecast">Načítání…</string>
<string name="loading">Načítání…</string>
<string name="type_watching">Sledování</string>
<string name="type_on_hold">Pozastaveno</string>

View File

@ -24,7 +24,7 @@
<string name="result_share">Teilen</string>
<string name="result_open_in_browser">Im Browser öffnen</string>
<string name="skip_loading">Buffern überspringen</string>
<string name="loading_chromecast">Lädt…</string>
<string name="loading">Lädt…</string>
<string name="type_watching">Am schauen</string>
<string name="type_on_hold">Pausiert</string>
<string name="type_completed">Abgeschlossen</string>

View File

@ -17,7 +17,7 @@
<string name="result_share">Μοίρασε</string>
<string name="result_open_in_browser">Άνοιγμα στον περιηγητή</string>
<string name="skip_loading">Προσπέραση φορτώματος</string>
<string name="loading_chromecast">Φόρτωση…</string>
<string name="loading">Φόρτωση…</string>
<string name="type_watching">Watching</string>
<string name="type_on_hold">On-Hold</string>

View File

@ -56,7 +56,7 @@
<string name="result_share">Compartir</string>
<string name="result_open_in_browser">Abrir en el navegador</string>
<string name="skip_loading">Omitir carga</string>
<string name="loading_chromecast">Cargando…</string>
<string name="loading">Cargando…</string>
<string name="type_watching">Viendo</string>
<string name="type_on_hold">En espera</string>

View File

@ -16,7 +16,7 @@
<string name="result_share">Partager</string>
<string name="result_open_in_browser">Ouvrir dans le naviguateur</string>
<string name="skip_loading">Passer le chargement</string>
<string name="loading_chromecast">Chargement…</string>
<string name="loading">Chargement…</string>
<string name="type_watching">En visionnage</string>
<string name="type_on_hold">En pose</string>
<string name="type_completed">Terminé</string>

View File

@ -52,7 +52,7 @@
<string name="result_share">Bagikan</string>
<string name="result_open_in_browser">Buka Di Browser</string>
<string name="skip_loading">Skip Loading</string>
<string name="loading_chromecast">Loading…</string>
<string name="loading">Loading…</string>
<string name="type_watching">Sedang Menonton</string>
<string name="type_on_hold">Tertahan</string>

View File

@ -52,7 +52,7 @@
<string name="result_share">Condividi</string>
<string name="result_open_in_browser">Apri nel browser</string>
<string name="skip_loading">Salta caricamento</string>
<string name="loading_chromecast">Caricamento…</string>
<string name="loading">Caricamento…</string>
<string name="type_watching">Guardando</string>
<string name="type_on_hold">In attesa</string>

View File

@ -20,7 +20,7 @@
<string name="result_share">Сподели</string>
<string name="result_open_in_browser">Отвори во прелистувач</string>
<string name="skip_loading">Прескокни вчитување</string>
<string name="loading_chromecast">Вчитување…</string>
<string name="loading">Вчитување…</string>
<string name="type_watching">Моментални гледања</string>
<string name="type_on_hold">Ставено на чекање</string>

View File

@ -17,7 +17,7 @@
<string name="result_share">aauuh</string>
<string name="result_open_in_browser">oooohh oooohhhaaaoouuh</string>
<string name="skip_loading">oooohhooooo</string>
<string name="loading_chromecast">ooh aaahhu</string>
<string name="loading">ooh aaahhu</string>
<string name="type_watching">aaaghh ooo-ahah</string>
<string name="type_on_hold">aaahhu</string>
<string name="type_completed">ahhahooo</string>

View File

@ -17,7 +17,7 @@
<string name="result_share">Deel</string>
<string name="result_open_in_browser">Openen in Browser</string>
<string name="skip_loading">Laden overslaan</string>
<string name="loading_chromecast">Laden…</string>
<string name="loading">Laden…</string>
<string name="type_watching">Aan het kijken</string>
<string name="type_on_hold">In de wacht</string>

View File

@ -28,7 +28,7 @@
<string name="result_share">Dele</string>
<string name="result_open_in_browser">Åpne i nettleseren</string>
<string name="skip_loading">Hopp over</string>
<string name="loading_chromecast">Laster inn…</string>
<string name="loading">Laster inn…</string>
<string name="type_watching">Ser på</string>
<string name="type_on_hold">På vent</string>

View File

@ -31,7 +31,7 @@
<string name="result_share">Udostępnij</string>
<string name="result_open_in_browser">Otwórz w przeglądarce</string>
<string name="skip_loading">Pomiń ładowanie</string>
<string name="loading_chromecast">Ładowanie…</string>
<string name="loading">Ładowanie…</string>
<string name="type_watching">W trakcie</string>
<string name="type_on_hold">Zawieszone</string>

View File

@ -31,7 +31,7 @@
<string name="result_share">Compartir</string>
<string name="result_open_in_browser">Abrir no Navegador</string>
<string name="skip_loading">Saltar Carga</string>
<string name="loading_chromecast">Cargando…</string>
<string name="loading">Cargando…</string>
<string name="type_watching">Assistindo</string>
<string name="type_on_hold">Em espera</string>

View File

@ -52,7 +52,7 @@
<string name="result_share">Distribuie</string>
<string name="result_open_in_browser">Deschide în browser</string>
<string name="skip_loading">Săriți încărcarea</string>
<string name="loading_chromecast">Se încarcă...</string>
<string name="loading">Se încarcă...</string>
<string name="type_watching">În curs de vizualizare</string>
<string name="type_on_hold">În așteptare</string>

View File

@ -20,7 +20,7 @@
<string name="result_share">Dela</string>
<string name="result_open_in_browser">Öppna i webbläsaren</string>
<string name="skip_loading">Hoppa över</string>
<string name="loading_chromecast">Laddar…</string>
<string name="loading">Laddar…</string>
<string name="type_watching">Tittar på</string>
<string name="type_on_hold">Pausad</string>

View File

@ -35,7 +35,7 @@
<string name="result_share">I-share</string>
<string name="result_open_in_browser">Buksan sa browser</string>
<string name="skip_loading">Skip Loading…</string>
<string name="loading_chromecast">Loading…</string>
<string name="loading">Loading…</string>
<string name="type_watching">Pinapanood</string>
<string name="type_on_hold">Inihinto</string>

View File

@ -56,7 +56,7 @@
<string name="result_share">Paylaş</string>
<string name="result_open_in_browser">Tarayıcıda aç</string>
<string name="skip_loading">Yüklemeyi atla</string>
<string name="loading_chromecast">Yükleniyor…</string>
<string name="loading">Yükleniyor…</string>
<string name="type_watching">İzleniyor</string>
<string name="type_on_hold">Beklemede</string>

View File

@ -108,7 +108,7 @@
<string name="result_share">Chia sẻ</string>
<string name="result_open_in_browser">Mở bằng trình duyệt</string>
<string name="skip_loading">Bỏ qua</string>
<string name="loading_chromecast">Đang tải…</string>
<string name="loading">Đang tải…</string>
<string name="type_watching">Đang xem</string>
<string name="type_on_hold">Đang chờ</string>

View File

@ -38,7 +38,7 @@
<string name="result_share">分享</string>
<string name="result_open_in_browser">在浏览器中打开</string>
<string name="skip_loading">跳过加载</string>
<string name="loading_chromecast">正在加载…</string>
<string name="loading">正在加载…</string>
<string name="type_watching">正在观看</string>
<string name="type_on_hold">暂时搁置</string>

View File

@ -110,7 +110,7 @@
<string name="result_share">Share</string>
<string name="result_open_in_browser">Open In Browser</string>
<string name="skip_loading">Skip Loading</string>
<string name="loading_chromecast">Loading…</string>
<string name="loading">Loading…</string>
<string name="type_watching">Watching</string>
<string name="type_on_hold">On-Hold</string>

View File

@ -266,6 +266,7 @@
</style>
<style name="AppBottomSheetDialogTheme">
<item name="android:navigationBarColor">?attr/boxItemBackground</item>
<item name="android:windowCloseOnTouchOutside">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowAnimationStyle">@style/Animation.Design.BottomSheetDialog</item>
@ -278,7 +279,7 @@
<item name="behavior_skipCollapsed">true</item>
<item name="shapeAppearance">@null</item>
<item name="shapeAppearanceOverlay">@null</item>
<item name="backgroundTint">?android:attr/colorBackground</item>
<item name="backgroundTint">@color/transparent</item>
<item name="android:background">@drawable/rounded_dialog</item>
<item name="behavior_peekHeight">512dp</item>
</style>
@ -334,6 +335,9 @@
<item name="tabMode">scrollable</item>-->
</style>
<style name="DarkFragment" parent="AppTheme">
<item name="android:navigationBarColor">?attr/colorPrimary</item>
</style>
<style name="AlertDialogCustom" parent="Theme.AppCompat.Dialog.Alert">
<item name="android:windowFullscreen">true</item>
<item name="android:textColor">?attr/textColor</item>