diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt index 4f71089649..e1c7731259 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt @@ -8,7 +8,6 @@ import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.ImageButton import android.widget.LinearLayout -import androidx.appcompat.app.AlertDialog import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat.startActivity import androidx.core.view.isGone @@ -19,7 +18,7 @@ import ani.dantotsu.FileUrl import ani.dantotsu.R import ani.dantotsu.currActivity import ani.dantotsu.databinding.DialogLayoutBinding -import ani.dantotsu.databinding.ItemAnimeWatchBinding +import ani.dantotsu.databinding.ItemMediaSourceBinding import ani.dantotsu.databinding.ItemChipBinding import ani.dantotsu.displayTimer import ani.dantotsu.isOnline @@ -33,6 +32,7 @@ import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.webview.CookieCatcher import ani.dantotsu.parsers.AnimeSources import ani.dantotsu.parsers.DynamicAnimeParser +import ani.dantotsu.parsers.OfflineAnimeParser import ani.dantotsu.parsers.WatchSources import ani.dantotsu.px import ani.dantotsu.settings.FAQActivity @@ -55,10 +55,10 @@ class AnimeWatchAdapter( ) : RecyclerView.Adapter() { private var autoSelect = true var subscribe: MediaDetailsActivity.PopImageButton? = null - private var _binding: ItemAnimeWatchBinding? = null + private var _binding: ItemMediaSourceBinding? = null override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val bind = ItemAnimeWatchBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val bind = ItemMediaSourceBinding.inflate(LayoutInflater.from(parent.context), parent, false) return ViewHolder(bind) } @@ -73,7 +73,7 @@ class AnimeWatchAdapter( null ) } - //Youtube + // Youtube if (media.anime?.youtube != null && PrefManager.getVal(PrefName.ShowYtButton)) { binding.animeSourceYT.visibility = View.VISIBLE binding.animeSourceYT.setOnClickListener { @@ -87,7 +87,7 @@ class AnimeWatchAdapter( R.string.subbed ) - //PreferDub + // PreferDub var changing = false binding.animeSourceDubbed.setOnCheckedChangeListener { _, isChecked -> binding.animeSourceDubbedText.text = @@ -97,8 +97,8 @@ class AnimeWatchAdapter( if (!changing) fragment.onDubClicked(isChecked) } - //Wrong Title - binding.animeSourceSearch.setOnClickListener { + // Wrong Title + binding.mediaSourceSearch.setOnClickListener { SourceSearchDialogFragment().show( fragment.requireActivity().supportFragmentManager, null @@ -106,37 +106,37 @@ class AnimeWatchAdapter( } val offline = !isOnline(binding.root.context) || PrefManager.getVal(PrefName.OfflineMode) - binding.animeSourceNameContainer.isGone = offline - binding.animeSourceSettings.isGone = offline - binding.animeSourceSearch.isGone = offline - binding.animeSourceTitle.isGone = offline + binding.mediaSourceNameContainer.isGone = offline + binding.mediaSourceSettings.isGone = offline + binding.mediaSourceSearch.isGone = offline + binding.mediaSourceTitle.isGone = offline - //Source Selection + // Source Selection var source = media.selected!!.sourceIndex.let { if (it >= watchSources.names.size) 0 else it } setLanguageList(media.selected!!.langIndex, source) if (watchSources.names.isNotEmpty() && source in 0 until watchSources.names.size) { - binding.animeSource.setText(watchSources.names[source]) + binding.mediaSource.setText(watchSources.names[source]) watchSources[source].apply { this.selectDub = media.selected!!.preferDub - binding.animeSourceTitle.text = showUserText - showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } } + binding.mediaSourceTitle.text = showUserText + showUserTextListener = { MainScope().launch { binding.mediaSourceTitle.text = it } } binding.animeSourceDubbedCont.isVisible = isDubAvailableSeparately() } } - binding.animeSource.setAdapter( + binding.mediaSource.setAdapter( ArrayAdapter( fragment.requireContext(), R.layout.item_dropdown, watchSources.names ) ) - binding.animeSourceTitle.isSelected = true - binding.animeSource.setOnItemClickListener { _, _, i, _ -> + binding.mediaSourceTitle.isSelected = true + binding.mediaSource.setOnItemClickListener { _, _, i, _ -> fragment.onSourceChange(i).apply { - binding.animeSourceTitle.text = showUserText - showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } } + binding.mediaSourceTitle.text = showUserText + showUserTextListener = { MainScope().launch { binding.mediaSourceTitle.text = it } } changing = true binding.animeSourceDubbed.isChecked = selectDub changing = false @@ -148,15 +148,15 @@ class AnimeWatchAdapter( fragment.loadEpisodes(i, false) } - binding.animeSourceLanguage.setOnItemClickListener { _, _, i, _ -> + binding.mediaSourceLanguage.setOnItemClickListener { _, _, i, _ -> // Check if 'extension' and 'selected' properties exist and are accessible (watchSources[source] as? DynamicAnimeParser)?.let { ext -> ext.sourceLanguage = i fragment.onLangChange(i) fragment.onSourceChange(media.selected!!.sourceIndex).apply { - binding.animeSourceTitle.text = showUserText + binding.mediaSourceTitle.text = showUserText showUserTextListener = - { MainScope().launch { binding.animeSourceTitle.text = it } } + { MainScope().launch { binding.mediaSourceTitle.text = it } } changing = true binding.animeSourceDubbed.isChecked = selectDub changing = false @@ -168,19 +168,19 @@ class AnimeWatchAdapter( } ?: run { } } - //settings - binding.animeSourceSettings.setOnClickListener { + // Settings + binding.mediaSourceSettings.setOnClickListener { (watchSources[source] as? DynamicAnimeParser)?.let { ext -> fragment.openSettings(ext.extension) } } - //Icons + // Icons - //subscribe + // Subscribe subscribe = MediaDetailsActivity.PopImageButton( fragment.lifecycleScope, - binding.animeSourceSubscribe, + binding.mediaSourceSubscribe, R.drawable.ic_round_notifications_active_24, R.drawable.ic_round_notifications_none_24, R.color.bg_opp, @@ -188,17 +188,17 @@ class AnimeWatchAdapter( fragment.subscribed, true ) { - fragment.onNotificationPressed(it, binding.animeSource.text.toString()) + fragment.onNotificationPressed(it, binding.mediaSource.text.toString()) } subscribeButton(false) - binding.animeSourceSubscribe.setOnLongClickListener { + binding.mediaSourceSubscribe.setOnLongClickListener { openSettings(fragment.requireContext(), CHANNEL_SUBSCRIPTION_CHECK) } - //Nested Button - binding.animeNestedButton.setOnClickListener { + // Nested Button + binding.mediaNestedButton.setOnClickListener { val dialogBinding = DialogLayoutBinding.inflate(fragment.layoutInflater) dialogBinding.apply { var refresh = false @@ -207,26 +207,26 @@ class AnimeWatchAdapter( var style = media.selected!!.recyclerStyle ?: PrefManager.getVal(PrefName.AnimeDefaultView) - animeSourceTop.rotation = if (reversed) -90f else 90f + mediaSourceTop.rotation = if (reversed) -90f else 90f sortText.text = if (reversed) "Down to Up" else "Up to Down" - animeSourceTop.setOnClickListener { + mediaSourceTop.setOnClickListener { reversed = !reversed - animeSourceTop.rotation = if (reversed) -90f else 90f + mediaSourceTop.rotation = if (reversed) -90f else 90f sortText.text = if (reversed) "Down to Up" else "Up to Down" run = true } - //Grids + // Grids var selected = when (style) { - 0 -> animeSourceList - 1 -> animeSourceGrid - 2 -> animeSourceCompact - else -> animeSourceList + 0 -> mediaSourceList + 1 -> mediaSourceGrid + 2 -> mediaSourceCompact + else -> mediaSourceList } when (style) { 0 -> layoutText.setText(R.string.list) 1 -> layoutText.setText(R.string.grid) 2 -> layoutText.setText(R.string.compact) - else -> animeSourceList + else -> mediaSourceList } selected.alpha = 1f fun selected(it: ImageButton) { @@ -234,29 +234,29 @@ class AnimeWatchAdapter( selected = it selected.alpha = 1f } - animeSourceList.setOnClickListener { + mediaSourceList.setOnClickListener { selected(it as ImageButton) style = 0 layoutText.setText(R.string.list) run = true } - animeSourceGrid.setOnClickListener { + mediaSourceGrid.setOnClickListener { selected(it as ImageButton) style = 1 layoutText.setText(R.string.grid) run = true } - animeSourceCompact.setOnClickListener { + mediaSourceCompact.setOnClickListener { selected(it as ImageButton) style = 2 layoutText.setText(R.string.compact) run = true } - animeWebviewContainer.setOnClickListener { + mediaWebviewContainer.setOnClickListener { if (!WebViewUtil.supportsWebView(fragment.requireContext())) { toast(R.string.webview_not_installed) } - //start CookieCatcher activity + // Start CookieCatcher activity if (watchSources.names.isNotEmpty() && source in 0 until watchSources.names.size) { val sourceAHH = watchSources[source] as? DynamicAnimeParser val sourceHttp = @@ -279,8 +279,8 @@ class AnimeWatchAdapter( } } - //hidden - animeScanlatorContainer.visibility = View.GONE + // Hidden + mangaScanlatorContainer.visibility = View.GONE animeDownloadContainer.visibility = View.GONE fragment.requireContext().customAlertDialog().apply { setTitle("Options") @@ -296,7 +296,7 @@ class AnimeWatchAdapter( } } } - //Episode Handling + // Episode Handling handleEpisodes() } @@ -304,7 +304,7 @@ class AnimeWatchAdapter( subscribe?.enabled(enabled) } - //Chips + // Chips fun updateChips(limit: Int, names: Array, arr: Array, selected: Int = 0) { val binding = _binding if (binding != null) { @@ -315,13 +315,13 @@ class AnimeWatchAdapter( val chip = ItemChipBinding.inflate( LayoutInflater.from(fragment.context), - binding.animeSourceChipGroup, + binding.mediaSourceChipGroup, false ).root chip.isCheckable = true fun selected() { chip.isChecked = true - binding.animeWatchChipScroll.smoothScrollTo( + binding.mediaWatchChipScroll.smoothScrollTo( (chip.left - screenWidth / 2) + (chip.width / 2), 0 ) @@ -340,14 +340,14 @@ class AnimeWatchAdapter( selected() fragment.onChipClicked(position, limit * (position), last - 1) } - binding.animeSourceChipGroup.addView(chip) + binding.mediaSourceChipGroup.addView(chip) if (selected == position) { selected() select = chip } } if (select != null) - binding.animeWatchChipScroll.apply { + binding.mediaWatchChipScroll.apply { post { scrollTo( (select.left - screenWidth / 2) + (select.width / 2), @@ -359,7 +359,7 @@ class AnimeWatchAdapter( } fun clearChips() { - _binding?.animeSourceChipGroup?.removeAllViews() + _binding?.mediaSourceChipGroup?.removeAllViews() } fun handleEpisodes() { @@ -375,15 +375,15 @@ class AnimeWatchAdapter( var continueEp = (if (anilistEp > appEp) anilistEp else appEp).toString() if (episodes.contains(continueEp)) { - binding.animeSourceContinue.visibility = View.VISIBLE + binding.sourceContinue.visibility = View.VISIBLE handleProgress( - binding.itemEpisodeProgressCont, - binding.itemEpisodeProgress, - binding.itemEpisodeProgressEmpty, + binding.itemMediaProgressCont, + binding.itemMediaProgress, + binding.itemMediaProgressEmpty, media.id, continueEp ) - if ((binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams).weight > PrefManager.getVal( + if ((binding.itemMediaProgress.layoutParams as LinearLayout.LayoutParams).weight > PrefManager.getVal( PrefName.WatchPercentage ) ) { @@ -391,9 +391,9 @@ class AnimeWatchAdapter( if (e != -1 && e + 1 < episodes.size) { continueEp = episodes[e + 1] handleProgress( - binding.itemEpisodeProgressCont, - binding.itemEpisodeProgress, - binding.itemEpisodeProgressEmpty, + binding.itemMediaProgressCont, + binding.itemMediaProgress, + binding.itemMediaProgressEmpty, media.id, continueEp ) @@ -403,51 +403,63 @@ class AnimeWatchAdapter( val cleanedTitle = ep.title?.let { MediaNameAdapter.removeEpisodeNumber(it) } - binding.itemEpisodeImage.loadImage( + binding.itemMediaImage.loadImage( ep.thumb ?: FileUrl[media.banner ?: media.cover], 0 ) if (ep.filler) binding.itemEpisodeFillerView.visibility = View.VISIBLE - binding.animeSourceContinueText.text = + binding.mediaSourceContinueText.text = currActivity()!!.getString( R.string.continue_episode, ep.number, if (ep.filler) currActivity()!!.getString(R.string.filler_tag) else "", cleanedTitle ) - binding.animeSourceContinue.setOnClickListener { + binding.sourceContinue.setOnClickListener { fragment.onEpisodeClick(continueEp) } if (fragment.continueEp) { if ( - (binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams) + (binding.itemMediaProgress.layoutParams as LinearLayout.LayoutParams) .weight < PrefManager.getVal(PrefName.WatchPercentage) ) { - binding.animeSourceContinue.performClick() + binding.sourceContinue.performClick() fragment.continueEp = false } } } else { - binding.animeSourceContinue.visibility = View.GONE + binding.sourceContinue.visibility = View.GONE } - binding.animeSourceProgressBar.visibility = View.GONE + binding.sourceProgressBar.visibility = View.GONE val sourceFound = media.anime.episodes!!.isNotEmpty() - binding.animeSourceNotFound.isGone = sourceFound + val isDownloadedSource = watchSources[media.selected!!.sourceIndex] is OfflineAnimeParser + + if (isDownloadedSource) { + binding.sourceNotFound.text = if (sourceFound) { + currActivity()!!.getString(R.string.source_not_found) + } else { + currActivity()!!.getString(R.string.download_not_found) + } + } else { + binding.sourceNotFound.text = currActivity()!!.getString(R.string.source_not_found) + } + + binding.sourceNotFound.isGone = sourceFound binding.faqbutton.isGone = sourceFound if (!sourceFound && PrefManager.getVal(PrefName.SearchSources) && autoSelect) { - if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) { + if (binding.mediaSource.adapter.count > media.selected!!.sourceIndex + 1) { val nextIndex = media.selected!!.sourceIndex + 1 - binding.animeSource.setText( - binding.animeSource.adapter + binding.mediaSource.setText( + binding.mediaSource.adapter .getItem(nextIndex).toString(), false ) fragment.onSourceChange(nextIndex).apply { - binding.animeSourceTitle.text = showUserText + binding.mediaSourceTitle.text = showUserText showUserTextListener = - { MainScope().launch { binding.animeSourceTitle.text = it } } + { MainScope().launch { binding.mediaSourceTitle.text = it } } binding.animeSourceDubbed.isChecked = selectDub binding.animeSourceDubbedCont.isVisible = isDubAvailableSeparately() setLanguageList(0, nextIndex) @@ -456,13 +468,13 @@ class AnimeWatchAdapter( fragment.loadEpisodes(nextIndex, false) } } - binding.animeSource.setOnClickListener { autoSelect = false } + binding.mediaSource.setOnClickListener { autoSelect = false } } else { - binding.animeSourceContinue.visibility = View.GONE - binding.animeSourceNotFound.visibility = View.GONE + binding.sourceContinue.visibility = View.GONE + binding.sourceNotFound.visibility = View.GONE binding.faqbutton.visibility = View.GONE clearChips() - binding.animeSourceProgressBar.visibility = View.VISIBLE + binding.sourceProgressBar.visibility = View.VISIBLE } } } @@ -476,9 +488,9 @@ class AnimeWatchAdapter( ext.sourceLanguage = lang } try { - binding?.animeSourceLanguage?.setText(parser.extension.sources[lang].lang) + binding?.mediaSourceLanguage?.setText(parser.extension.sources[lang].lang) } catch (e: IndexOutOfBoundsException) { - binding?.animeSourceLanguage?.setText( + binding?.mediaSourceLanguage?.setText( parser.extension.sources.firstOrNull()?.lang ?: "Unknown" ) } @@ -489,9 +501,9 @@ class AnimeWatchAdapter( ) val items = adapter.count - binding?.animeSourceLanguageContainer?.visibility = + binding?.mediaSourceLanguageContainer?.visibility = if (items > 1) View.VISIBLE else View.GONE - binding?.animeSourceLanguage?.setAdapter(adapter) + binding?.mediaSourceLanguage?.setAdapter(adapter) } } @@ -499,7 +511,7 @@ class AnimeWatchAdapter( override fun getItemCount(): Int = 1 - inner class ViewHolder(val binding: ItemAnimeWatchBinding) : + inner class ViewHolder(val binding: ItemMediaSourceBinding) : RecyclerView.ViewHolder(binding.root) { init { displayTimer(media, binding.animeSourceContainer) diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt index a9dc9b7e8e..847d87554a 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt @@ -32,7 +32,7 @@ import ani.dantotsu.FileUrl import ani.dantotsu.R import ani.dantotsu.addons.download.DownloadAddonManager import ani.dantotsu.connections.anilist.api.MediaStreamingEpisode -import ani.dantotsu.databinding.FragmentAnimeWatchBinding +import ani.dantotsu.databinding.FragmentMediaSourceBinding import ani.dantotsu.download.DownloadedType import ani.dantotsu.download.DownloadsManager import ani.dantotsu.download.DownloadsManager.Companion.compareName @@ -81,7 +81,7 @@ import kotlin.math.max import kotlin.math.roundToInt class AnimeWatchFragment : Fragment() { - private var _binding: FragmentAnimeWatchBinding? = null + private var _binding: FragmentMediaSourceBinding? = null private val binding get() = _binding!! private val model: MediaDetailsViewModel by activityViewModels() @@ -108,7 +108,7 @@ class AnimeWatchFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - _binding = FragmentAnimeWatchBinding.inflate(inflater, container, false) + _binding = FragmentMediaSourceBinding.inflate(inflater, container, false) return _binding?.root } @@ -129,7 +129,7 @@ class AnimeWatchFragment : Fragment() { ) - binding.animeSourceRecycler.updatePadding(bottom = binding.animeSourceRecycler.paddingBottom + navBarHeight) + binding.mediaSourceRecycler.updatePadding(bottom = binding.mediaSourceRecycler.paddingBottom + navBarHeight) screenWidth = resources.displayMetrics.widthPixels.dp var maxGridSize = (screenWidth / 100f).roundToInt() @@ -153,13 +153,13 @@ class AnimeWatchFragment : Fragment() { } } - binding.animeSourceRecycler.layoutManager = gridLayoutManager + binding.mediaSourceRecycler.layoutManager = gridLayoutManager binding.ScrollTop.setOnClickListener { - binding.animeSourceRecycler.scrollToPosition(10) - binding.animeSourceRecycler.smoothScrollToPosition(0) + binding.mediaSourceRecycler.scrollToPosition(10) + binding.mediaSourceRecycler.smoothScrollToPosition(0) } - binding.animeSourceRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { + binding.mediaSourceRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) @@ -173,7 +173,7 @@ class AnimeWatchFragment : Fragment() { } }) model.scrolledToTop.observe(viewLifecycleOwner) { - if (it) binding.animeSourceRecycler.scrollToPosition(0) + if (it) binding.mediaSourceRecycler.scrollToPosition(0) } continueEp = model.continueMedia ?: false @@ -206,7 +206,7 @@ class AnimeWatchFragment : Fragment() { offlineMode = offlineMode ) - binding.animeSourceRecycler.adapter = + binding.mediaSourceRecycler.adapter = ConcatAdapter(headerAdapter, episodeAdapter) lifecycleScope.launch(Dispatchers.IO) { @@ -267,7 +267,7 @@ class AnimeWatchFragment : Fragment() { } media.anime?.episodes = episodes - //CHIP GROUP + // CHIP GROUP val total = episodes.size val divisions = total.toDouble() / 10 start = 0 @@ -635,7 +635,7 @@ class AnimeWatchFragment : Fragment() { private fun reload() { val selected = model.loadSelected(media) - //Find latest episode for subscription + // Find latest episode for subscription selected.latest = media.anime?.episodes?.values?.maxOfOrNull { it.number.toFloatOrNull() ?: 0f } ?: 0f selected.latest = @@ -679,14 +679,14 @@ class AnimeWatchFragment : Fragment() { override fun onResume() { super.onResume() binding.mediaInfoProgressBar.visibility = progress - binding.animeSourceRecycler.layoutManager?.onRestoreInstanceState(state) + binding.mediaSourceRecycler.layoutManager?.onRestoreInstanceState(state) requireActivity().setNavigationTheme() } override fun onPause() { super.onPause() - state = binding.animeSourceRecycler.layoutManager?.onSaveInstanceState() + state = binding.mediaSourceRecycler.layoutManager?.onSaveInstanceState() } companion object { diff --git a/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt b/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt index 1ee5c88127..c0ac435240 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt @@ -107,8 +107,8 @@ class EpisodeAdapter( val thumb = ep.thumb?.let { if (it.url.isNotEmpty()) GlideUrl(it.url) { it.headers } else null } - Glide.with(binding.itemEpisodeImage).load(thumb ?: media.cover).override(400, 0) - .into(binding.itemEpisodeImage) + Glide.with(binding.itemMediaImage).load(thumb ?: media.cover).override(400, 0) + .into(binding.itemMediaImage) binding.itemEpisodeNumber.text = ep.number binding.itemEpisodeTitle.text = if (ep.number == title) "Episode $title" else title @@ -141,9 +141,9 @@ class EpisodeAdapter( } handleProgress( - binding.itemEpisodeProgressCont, - binding.itemEpisodeProgress, - binding.itemEpisodeProgressEmpty, + binding.itemMediaProgressCont, + binding.itemMediaProgress, + binding.itemMediaProgressEmpty, media.id, ep.number ) @@ -155,8 +155,8 @@ class EpisodeAdapter( val thumb = ep.thumb?.let { if (it.url.isNotEmpty()) GlideUrl(it.url) { it.headers } else null } - Glide.with(binding.itemEpisodeImage).load(thumb ?: media.cover).override(400, 0) - .into(binding.itemEpisodeImage) + Glide.with(binding.itemMediaImage).load(thumb ?: media.cover).override(400, 0) + .into(binding.itemMediaImage) binding.itemEpisodeNumber.text = ep.number binding.itemEpisodeTitle.text = title @@ -184,9 +184,9 @@ class EpisodeAdapter( binding.itemEpisodeViewed.visibility = View.GONE } handleProgress( - binding.itemEpisodeProgressCont, - binding.itemEpisodeProgress, - binding.itemEpisodeProgressEmpty, + binding.itemMediaProgressCont, + binding.itemMediaProgress, + binding.itemMediaProgressEmpty, media.id, ep.number ) @@ -209,9 +209,9 @@ class EpisodeAdapter( } } handleProgress( - binding.itemEpisodeProgressCont, - binding.itemEpisodeProgress, - binding.itemEpisodeProgressEmpty, + binding.itemMediaProgressCont, + binding.itemMediaProgress, + binding.itemMediaProgressEmpty, media.id, ep.number ) diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt index 4cd856a1c7..a98f0570ac 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt @@ -1,6 +1,5 @@ package ani.dantotsu.media.manga -import android.app.AlertDialog import android.content.Intent import android.view.LayoutInflater import android.view.View @@ -21,7 +20,7 @@ import ani.dantotsu.currActivity import ani.dantotsu.currContext import ani.dantotsu.databinding.CustomDialogLayoutBinding import ani.dantotsu.databinding.DialogLayoutBinding -import ani.dantotsu.databinding.ItemAnimeWatchBinding +import ani.dantotsu.databinding.ItemMediaSourceBinding import ani.dantotsu.databinding.ItemChipBinding import ani.dantotsu.isOnline import ani.dantotsu.loadImage @@ -36,6 +35,7 @@ import ani.dantotsu.others.webview.CookieCatcher import ani.dantotsu.parsers.DynamicMangaParser import ani.dantotsu.parsers.MangaReadSources import ani.dantotsu.parsers.MangaSources +import ani.dantotsu.parsers.OfflineMangaParser import ani.dantotsu.px import ani.dantotsu.settings.FAQActivity import ani.dantotsu.settings.saving.PrefManager @@ -57,13 +57,13 @@ class MangaReadAdapter( ) : RecyclerView.Adapter() { var subscribe: MediaDetailsActivity.PopImageButton? = null - private var _binding: ItemAnimeWatchBinding? = null + private var _binding: ItemMediaSourceBinding? = null val hiddenScanlators = mutableListOf() var scanlatorSelectionListener: ScanlatorSelectionListener? = null var options = listOf() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val bind = ItemAnimeWatchBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val bind = ItemMediaSourceBinding.inflate(LayoutInflater.from(parent.context), parent, false) return ViewHolder(bind) } @@ -72,14 +72,14 @@ class MangaReadAdapter( _binding = binding binding.sourceTitle.setText(R.string.chaps) - //Fuck u launch + // Fuck u launch binding.faqbutton.setOnClickListener { val intent = Intent(fragment.requireContext(), FAQActivity::class.java) startActivity(fragment.requireContext(), intent, null) } - //Wrong Title - binding.animeSourceSearch.setOnClickListener { + // Wrong Title + binding.mediaSourceSearch.setOnClickListener { SourceSearchDialogFragment().show( fragment.requireActivity().supportFragmentManager, null @@ -87,54 +87,54 @@ class MangaReadAdapter( } val offline = !isOnline(binding.root.context) || PrefManager.getVal(PrefName.OfflineMode) - binding.animeSourceNameContainer.isGone = offline - binding.animeSourceSettings.isGone = offline - binding.animeSourceSearch.isGone = offline - binding.animeSourceTitle.isGone = offline - //Source Selection + binding.mediaSourceNameContainer.isGone = offline + binding.mediaSourceSettings.isGone = offline + binding.mediaSourceSearch.isGone = offline + binding.mediaSourceTitle.isGone = offline + // Source Selection var source = media.selected!!.sourceIndex.let { if (it >= mangaReadSources.names.size) 0 else it } setLanguageList(media.selected!!.langIndex, source) if (mangaReadSources.names.isNotEmpty() && source in 0 until mangaReadSources.names.size) { - binding.animeSource.setText(mangaReadSources.names[source]) + binding.mediaSource.setText(mangaReadSources.names[source]) mangaReadSources[source].apply { - binding.animeSourceTitle.text = showUserText - showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } } + binding.mediaSourceTitle.text = showUserText + showUserTextListener = { MainScope().launch { binding.mediaSourceTitle.text = it } } } } media.selected?.scanlators?.let { hiddenScanlators.addAll(it) } - binding.animeSource.setAdapter( + binding.mediaSource.setAdapter( ArrayAdapter( fragment.requireContext(), R.layout.item_dropdown, mangaReadSources.names ) ) - binding.animeSourceTitle.isSelected = true - binding.animeSource.setOnItemClickListener { _, _, i, _ -> + binding.mediaSourceTitle.isSelected = true + binding.mediaSource.setOnItemClickListener { _, _, i, _ -> fragment.onSourceChange(i).apply { - binding.animeSourceTitle.text = showUserText - showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } } + binding.mediaSourceTitle.text = showUserText + showUserTextListener = { MainScope().launch { binding.mediaSourceTitle.text = it } } source = i setLanguageList(0, i) } subscribeButton(false) - //invalidate if it's the last source + // Invalidate if it's the last source val invalidate = i == mangaReadSources.names.size - 1 fragment.loadChapters(i, invalidate) } - binding.animeSourceLanguage.setOnItemClickListener { _, _, i, _ -> + binding.mediaSourceLanguage.setOnItemClickListener { _, _, i, _ -> // Check if 'extension' and 'selected' properties exist and are accessible (mangaReadSources[source] as? DynamicMangaParser)?.let { ext -> ext.sourceLanguage = i fragment.onLangChange(i, ext.saveName) fragment.onSourceChange(media.selected!!.sourceIndex).apply { - binding.animeSourceTitle.text = showUserText + binding.mediaSourceTitle.text = showUserText showUserTextListener = - { MainScope().launch { binding.animeSourceTitle.text = it } } + { MainScope().launch { binding.mediaSourceTitle.text = it } } setLanguageList(i, source) } subscribeButton(false) @@ -143,17 +143,17 @@ class MangaReadAdapter( } } - //settings - binding.animeSourceSettings.setOnClickListener { + // Settings + binding.mediaSourceSettings.setOnClickListener { (mangaReadSources[source] as? DynamicMangaParser)?.let { ext -> fragment.openSettings(ext.extension) } } - //Grids + // Grids subscribe = MediaDetailsActivity.PopImageButton( fragment.lifecycleScope, - binding.animeSourceSubscribe, + binding.mediaSourceSubscribe, R.drawable.ic_round_notifications_active_24, R.drawable.ic_round_notifications_none_24, R.color.bg_opp, @@ -161,16 +161,16 @@ class MangaReadAdapter( fragment.subscribed, true ) { - fragment.onNotificationPressed(it, binding.animeSource.text.toString()) + fragment.onNotificationPressed(it, binding.mediaSource.text.toString()) } subscribeButton(false) - binding.animeSourceSubscribe.setOnLongClickListener { + binding.mediaSourceSubscribe.setOnLongClickListener { openSettings(fragment.requireContext(), CHANNEL_SUBSCRIPTION_CHECK) } - binding.animeNestedButton.setOnClickListener { + binding.mediaNestedButton.setOnClickListener { val dialogBinding = DialogLayoutBinding.inflate(fragment.layoutInflater) var refresh = false var run = false @@ -178,26 +178,26 @@ class MangaReadAdapter( var style = media.selected!!.recyclerStyle ?: PrefManager.getVal(PrefName.MangaDefaultView) dialogBinding.apply { - animeSourceTop.rotation = if (reversed) -90f else 90f + mediaSourceTop.rotation = if (reversed) -90f else 90f sortText.text = if (reversed) "Down to Up" else "Up to Down" - animeSourceTop.setOnClickListener { + mediaSourceTop.setOnClickListener { reversed = !reversed - animeSourceTop.rotation = if (reversed) -90f else 90f + mediaSourceTop.rotation = if (reversed) -90f else 90f sortText.text = if (reversed) "Down to Up" else "Up to Down" run = true } - //Grids - animeSourceGrid.visibility = View.GONE + // Grids + mediaSourceGrid.visibility = View.GONE var selected = when (style) { - 0 -> animeSourceList - 1 -> animeSourceCompact - else -> animeSourceList + 0 -> mediaSourceList + 1 -> mediaSourceCompact + else -> mediaSourceList } when (style) { 0 -> layoutText.setText(R.string.list) 1 -> layoutText.setText(R.string.compact) - else -> animeSourceList + else -> mediaSourceList } selected.alpha = 1f fun selected(it: ImageButton) { @@ -205,23 +205,23 @@ class MangaReadAdapter( selected = it selected.alpha = 1f } - animeSourceList.setOnClickListener { + mediaSourceList.setOnClickListener { selected(it as ImageButton) style = 0 layoutText.setText(R.string.list) run = true } - animeSourceCompact.setOnClickListener { + mediaSourceCompact.setOnClickListener { selected(it as ImageButton) style = 1 layoutText.setText(R.string.compact) run = true } - animeWebviewContainer.setOnClickListener { + mediaWebviewContainer.setOnClickListener { if (!WebViewUtil.supportsWebView(fragment.requireContext())) { toast(R.string.webview_not_installed) } - //start CookieCatcher activity + // Start CookieCatcher activity if (mangaReadSources.names.isNotEmpty() && source in 0 until mangaReadSources.names.size) { val sourceAHH = mangaReadSources[source] as? DynamicMangaParser val sourceHttp = sourceAHH?.extension?.sources?.firstOrNull() as? HttpSource @@ -236,10 +236,10 @@ class MangaReadAdapter( } } - //Multi download + // Multi download downloadNo.text = "0" - animeDownloadTop.setOnClickListener { - //Alert dialog asking for the number of chapters to download + mediaDownloadTop.setOnClickListener { + // Alert dialog asking for the number of chapters to download fragment.requireContext().customAlertDialog().apply { setTitle("Multi Chapter Downloader") setMessage("Enter the number of chapters to download") @@ -256,10 +256,10 @@ class MangaReadAdapter( } } - //Scanlator - animeScanlatorContainer.isVisible = options.count() > 1 + // Scanlator + mangaScanlatorContainer.isVisible = options.count() > 1 scanlatorNo.text = "${options.count()}" - animeScanlatorTop.setOnClickListener { + mangaScanlatorTop.setOnClickListener { CustomDialogLayoutBinding.inflate(fragment.layoutInflater) val dialogView = CustomDialogLayoutBinding.inflate(fragment.layoutInflater) val checkboxContainer = dialogView.checkboxContainer @@ -345,7 +345,7 @@ class MangaReadAdapter( } } } - //Chapter Handling + // Chapter Handling handleChapters() } @@ -353,7 +353,7 @@ class MangaReadAdapter( subscribe?.enabled(enabled) } - //Chips + // Chips fun updateChips(limit: Int, names: Array, arr: Array, selected: Int = 0) { val binding = _binding if (binding != null) { @@ -364,13 +364,13 @@ class MangaReadAdapter( val chip = ItemChipBinding.inflate( LayoutInflater.from(fragment.context), - binding.animeSourceChipGroup, + binding.mediaSourceChipGroup, false ).root chip.isCheckable = true fun selected() { chip.isChecked = true - binding.animeWatchChipScroll.smoothScrollTo( + binding.mediaWatchChipScroll.smoothScrollTo( (chip.left - screenWidth / 2) + (chip.width / 2), 0 ) @@ -388,7 +388,7 @@ class MangaReadAdapter( } else { names[last - 1] } - //chip.text = "${names[limit * (position)]} - ${names[last - 1]}" + // chip.text = "${names[limit * (position)]} - ${names[last - 1]}" val chipText = "$startChapterString - $endChapterString" chip.text = chipText chip.setTextColor( @@ -402,14 +402,14 @@ class MangaReadAdapter( selected() fragment.onChipClicked(position, limit * (position), last - 1) } - binding.animeSourceChipGroup.addView(chip) + binding.mediaSourceChipGroup.addView(chip) if (selected == position) { selected() select = chip } } if (select != null) - binding.animeWatchChipScroll.apply { + binding.mediaWatchChipScroll.apply { post { scrollTo( (select.left - screenWidth / 2) + (select.width / 2), @@ -421,7 +421,7 @@ class MangaReadAdapter( } fun clearChips() { - _binding?.animeSourceChipGroup?.removeAllViews() + _binding?.mediaSourceChipGroup?.removeAllViews() } fun handleChapters() { @@ -447,70 +447,86 @@ class MangaReadAdapter( } if (formattedChapters.contains(continueEp)) { continueEp = chapters[formattedChapters.indexOf(continueEp)] - binding.animeSourceContinue.visibility = View.VISIBLE + binding.sourceContinue.visibility = View.VISIBLE handleProgress( - binding.itemEpisodeProgressCont, - binding.itemEpisodeProgress, - binding.itemEpisodeProgressEmpty, + binding.itemMediaProgressCont, + binding.itemMediaProgress, + binding.itemMediaProgressEmpty, media.id, continueEp ) - if ((binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams).weight > 0.8f) { + if ((binding.itemMediaProgress.layoutParams as LinearLayout.LayoutParams).weight > 0.8f) { val e = chapters.indexOf(continueEp) if (e != -1 && e + 1 < chapters.size) { continueEp = chapters[e + 1] } } val ep = media.manga.chapters!![continueEp]!! - binding.itemEpisodeImage.loadImage(media.banner ?: media.cover) - binding.animeSourceContinueText.text = + binding.itemMediaImage.loadImage(media.banner ?: media.cover) + binding.mediaSourceContinueText.text = currActivity()!!.getString( R.string.continue_chapter, ep.number, if (!ep.title.isNullOrEmpty()) ep.title else "" ) - binding.animeSourceContinue.setOnClickListener { + binding.sourceContinue.setOnClickListener { fragment.onMangaChapterClick(continueEp) } if (fragment.continueEp) { - if ((binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams).weight < 0.8f) { - binding.animeSourceContinue.performClick() + if ((binding.itemMediaProgress.layoutParams as LinearLayout.LayoutParams).weight < 0.8f) { + binding.sourceContinue.performClick() fragment.continueEp = false } } } else { - binding.animeSourceContinue.visibility = View.GONE + binding.sourceContinue.visibility = View.GONE } - binding.animeSourceProgressBar.visibility = View.GONE - val sourceFound = media.manga.chapters!!.isNotEmpty() - binding.animeSourceNotFound.isGone = sourceFound + + binding.sourceProgressBar.visibility = View.GONE + + val sourceFound = filteredChapters.isNotEmpty() + val isDownloadedSource = mangaReadSources[media.selected!!.sourceIndex] is OfflineMangaParser + + if (isDownloadedSource) { + binding.sourceNotFound.text = if (sourceFound) { + currActivity()!!.getString(R.string.source_not_found) + } else { + currActivity()!!.getString(R.string.download_not_found) + } + } else { + binding.sourceNotFound.text = currActivity()!!.getString(R.string.source_not_found) + } + + binding.sourceNotFound.isGone = sourceFound binding.faqbutton.isGone = sourceFound + + if (!sourceFound && PrefManager.getVal(PrefName.SearchSources)) { - if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) { + if (binding.mediaSource.adapter.count > media.selected!!.sourceIndex + 1) { val nextIndex = media.selected!!.sourceIndex + 1 - binding.animeSource.setText( - binding.animeSource.adapter + binding.mediaSource.setText( + binding.mediaSource.adapter .getItem(nextIndex).toString(), false ) fragment.onSourceChange(nextIndex).apply { - binding.animeSourceTitle.text = showUserText + binding.mediaSourceTitle.text = showUserText showUserTextListener = - { MainScope().launch { binding.animeSourceTitle.text = it } } + { MainScope().launch { binding.mediaSourceTitle.text = it } } setLanguageList(0, nextIndex) } subscribeButton(false) - // invalidate if it's the last source + // Invalidate if it's the last source val invalidate = nextIndex == mangaReadSources.names.size - 1 fragment.loadChapters(nextIndex, invalidate) } } } else { - binding.animeSourceContinue.visibility = View.GONE - binding.animeSourceNotFound.visibility = View.GONE + binding.sourceContinue.visibility = View.GONE + binding.sourceNotFound.visibility = View.GONE binding.faqbutton.visibility = View.GONE clearChips() - binding.animeSourceProgressBar.visibility = View.VISIBLE + binding.sourceProgressBar.visibility = View.VISIBLE } } } @@ -524,9 +540,9 @@ class MangaReadAdapter( ext.sourceLanguage = lang } try { - binding?.animeSourceLanguage?.setText(parser.extension.sources[lang].lang) + binding?.mediaSourceLanguage?.setText(parser.extension.sources[lang].lang) } catch (e: IndexOutOfBoundsException) { - binding?.animeSourceLanguage?.setText( + binding?.mediaSourceLanguage?.setText( parser.extension.sources.firstOrNull()?.lang ?: "Unknown" ) } @@ -536,9 +552,9 @@ class MangaReadAdapter( parser.extension.sources.map { LanguageMapper.getLanguageName(it.lang) } ) val items = adapter.count - binding?.animeSourceLanguageContainer?.isVisible = items > 1 + binding?.mediaSourceLanguageContainer?.isVisible = items > 1 - binding?.animeSourceLanguage?.setAdapter(adapter) + binding?.mediaSourceLanguage?.setAdapter(adapter) } } @@ -546,7 +562,7 @@ class MangaReadAdapter( override fun getItemCount(): Int = 1 - inner class ViewHolder(val binding: ItemAnimeWatchBinding) : + inner class ViewHolder(val binding: ItemMediaSourceBinding) : RecyclerView.ViewHolder(binding.root) } diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt index 7430bafa51..be836ad59b 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt @@ -2,7 +2,6 @@ package ani.dantotsu.media.manga import android.Manifest import android.annotation.SuppressLint -import android.app.AlertDialog import android.content.BroadcastReceiver import android.content.Context import android.content.Intent @@ -31,7 +30,7 @@ import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import ani.dantotsu.R -import ani.dantotsu.databinding.FragmentAnimeWatchBinding +import ani.dantotsu.databinding.FragmentMediaSourceBinding import ani.dantotsu.download.DownloadedType import ani.dantotsu.download.DownloadsManager import ani.dantotsu.download.DownloadsManager.Companion.compareName @@ -75,7 +74,7 @@ import kotlin.math.max import kotlin.math.roundToInt open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { - private var _binding: FragmentAnimeWatchBinding? = null + private var _binding: FragmentMediaSourceBinding? = null private val binding get() = _binding!! private val model: MediaDetailsViewModel by activityViewModels() @@ -102,7 +101,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - _binding = FragmentAnimeWatchBinding.inflate(inflater, container, false) + _binding = FragmentMediaSourceBinding.inflate(inflater, container, false) return _binding?.root } @@ -122,7 +121,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { ContextCompat.RECEIVER_EXPORTED ) - binding.animeSourceRecycler.updatePadding(bottom = binding.animeSourceRecycler.paddingBottom + navBarHeight) + binding.mediaSourceRecycler.updatePadding(bottom = binding.mediaSourceRecycler.paddingBottom + navBarHeight) screenWidth = resources.displayMetrics.widthPixels.dp var maxGridSize = (screenWidth / 100f).roundToInt() @@ -145,13 +144,13 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { } } - binding.animeSourceRecycler.layoutManager = gridLayoutManager + binding.mediaSourceRecycler.layoutManager = gridLayoutManager binding.ScrollTop.setOnClickListener { - binding.animeSourceRecycler.scrollToPosition(10) - binding.animeSourceRecycler.smoothScrollToPosition(0) + binding.mediaSourceRecycler.scrollToPosition(10) + binding.mediaSourceRecycler.smoothScrollToPosition(0) } - binding.animeSourceRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { + binding.mediaSourceRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) @@ -165,7 +164,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { } }) model.scrolledToTop.observe(viewLifecycleOwner) { - if (it) binding.animeSourceRecycler.scrollToPosition(0) + if (it) binding.mediaSourceRecycler.scrollToPosition(0) } continueEp = model.continueMedia ?: false @@ -200,7 +199,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { } } - binding.animeSourceRecycler.adapter = + binding.mediaSourceRecycler.adapter = ConcatAdapter(headerAdapter, chapterAdapter) lifecycleScope.launch(Dispatchers.IO) { @@ -215,8 +214,8 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { reload() } } else { - binding.animeNotSupported.visibility = View.VISIBLE - binding.animeNotSupported.text = + binding.mediaNotSupported.visibility = View.VISIBLE + binding.mediaNotSupported.text = getString(R.string.not_supported, media.format ?: "") } } @@ -232,10 +231,10 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { } fun multiDownload(n: Int) { - //get last viewed chapter + // Get last viewed chapter val selected = media.userProgress val chapters = media.manga?.chapters?.values?.toList() - //filter by selected language + // Filter by selected language val progressChapterIndex = (chapters?.indexOfFirst { MediaNameAdapter.findChapterNumber(it.number)?.toInt() == selected } ?: 0) + 1 @@ -245,7 +244,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { // Calculate the end index val endIndex = minOf(progressChapterIndex + n, chapters.size) - //make sure there are enough chapters + // Make sure there are enough chapters val chaptersToDownload = chapters.subList(progressChapterIndex, endIndex) @@ -583,7 +582,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { private fun reload() { val selected = model.loadSelected(media) - //Find latest chapter for subscription + // Find latest chapter for subscription selected.latest = media.manga?.chapters?.values?.maxOfOrNull { it.number.toFloatOrNull() ?: 0f } ?: 0f selected.latest = @@ -617,14 +616,14 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { override fun onResume() { super.onResume() binding.mediaInfoProgressBar.visibility = progress - binding.animeSourceRecycler.layoutManager?.onRestoreInstanceState(state) + binding.mediaSourceRecycler.layoutManager?.onRestoreInstanceState(state) requireActivity().setNavigationTheme() } override fun onPause() { super.onPause() - state = binding.animeSourceRecycler.layoutManager?.onSaveInstanceState() + state = binding.mediaSourceRecycler.layoutManager?.onSaveInstanceState() } companion object { diff --git a/app/src/main/java/ani/dantotsu/media/novel/NovelReadAdapter.kt b/app/src/main/java/ani/dantotsu/media/novel/NovelReadAdapter.kt index 7f9d34f418..cfaf298feb 100644 --- a/app/src/main/java/ani/dantotsu/media/novel/NovelReadAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/novel/NovelReadAdapter.kt @@ -50,16 +50,16 @@ class NovelReadAdapter( val source = media.selected!!.sourceIndex.let { if (it >= novelReadSources.names.size) 0 else it } if (novelReadSources.names.isNotEmpty() && source in 0 until novelReadSources.names.size) { - binding.animeSource.setText(novelReadSources.names[source], false) + binding.mediaSource.setText(novelReadSources.names[source], false) } - binding.animeSource.setAdapter( + binding.mediaSource.setAdapter( ArrayAdapter( fragment.requireContext(), R.layout.item_dropdown, novelReadSources.names ) ) - binding.animeSource.setOnItemClickListener { _, _, i, _ -> + binding.mediaSource.setOnItemClickListener { _, _, i, _ -> fragment.onSourceChange(i) search() } diff --git a/app/src/main/java/ani/dantotsu/media/novel/NovelReadFragment.kt b/app/src/main/java/ani/dantotsu/media/novel/NovelReadFragment.kt index c95328f6fb..5cd1f8add0 100644 --- a/app/src/main/java/ani/dantotsu/media/novel/NovelReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/novel/NovelReadFragment.kt @@ -20,7 +20,7 @@ import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.LinearLayoutManager import ani.dantotsu.R import ani.dantotsu.currContext -import ani.dantotsu.databinding.FragmentAnimeWatchBinding +import ani.dantotsu.databinding.FragmentMediaSourceBinding import ani.dantotsu.download.DownloadedType import ani.dantotsu.download.DownloadsManager import ani.dantotsu.download.novel.NovelDownloaderService @@ -47,7 +47,7 @@ class NovelReadFragment : Fragment(), DownloadTriggerCallback, DownloadedCheckCallback { - private var _binding: FragmentAnimeWatchBinding? = null + private var _binding: FragmentMediaSourceBinding? = null private val binding get() = _binding!! private val model: MediaDetailsViewModel by activityViewModels() @@ -214,11 +214,11 @@ class NovelReadFragment : Fragment(), ContextCompat.RECEIVER_EXPORTED ) - binding.animeSourceRecycler.updatePadding(bottom = binding.animeSourceRecycler.paddingBottom + navBarHeight) + binding.mediaSourceRecycler.updatePadding(bottom = binding.mediaSourceRecycler.paddingBottom + navBarHeight) - binding.animeSourceRecycler.layoutManager = LinearLayoutManager(requireContext()) + binding.mediaSourceRecycler.layoutManager = LinearLayoutManager(requireContext()) model.scrolledToTop.observe(viewLifecycleOwner) { - if (it) binding.animeSourceRecycler.scrollToPosition(0) + if (it) binding.mediaSourceRecycler.scrollToPosition(0) } continueEp = model.continueMedia ?: false @@ -237,7 +237,7 @@ class NovelReadFragment : Fragment(), this, this ) // probably a better way to do this but it works - binding.animeSourceRecycler.adapter = + binding.mediaSourceRecycler.adapter = ConcatAdapter(headerAdapter, novelResponseAdapter) loaded = true Handler(Looper.getMainLooper()).postDelayed({ @@ -290,7 +290,7 @@ class NovelReadFragment : Fragment(), container: ViewGroup?, savedInstanceState: Bundle? ): View? { - _binding = FragmentAnimeWatchBinding.inflate(inflater, container, false) + _binding = FragmentMediaSourceBinding.inflate(inflater, container, false) return _binding?.root } @@ -304,12 +304,12 @@ class NovelReadFragment : Fragment(), override fun onResume() { super.onResume() binding.mediaInfoProgressBar.visibility = progress - binding.animeSourceRecycler.layoutManager?.onRestoreInstanceState(state) + binding.mediaSourceRecycler.layoutManager?.onRestoreInstanceState(state) } override fun onPause() { super.onPause() - state = binding.animeSourceRecycler.layoutManager?.onSaveInstanceState() + state = binding.mediaSourceRecycler.layoutManager?.onSaveInstanceState() } companion object { diff --git a/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt b/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt index cade2abd8e..7bc304cdbd 100644 --- a/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt @@ -39,7 +39,7 @@ class NovelResponseAdapter( val binding = holder.binding val novel = list[position] setAnimation(fragment.requireContext(), holder.binding.root) - binding.itemEpisodeImage.loadImage(novel.coverUrl, 400, 0) + binding.itemMediaImage.loadImage(novel.coverUrl, 400, 0) val color =fragment.requireContext().getThemeColor(com.google.android.material.R.attr.colorOnBackground) binding.itemEpisodeTitle.text = novel.name diff --git a/app/src/main/java/ani/dantotsu/parsers/AnimeSources.kt b/app/src/main/java/ani/dantotsu/parsers/AnimeSources.kt index 119f4d2f84..f343d70b5b 100644 --- a/app/src/main/java/ani/dantotsu/parsers/AnimeSources.kt +++ b/app/src/main/java/ani/dantotsu/parsers/AnimeSources.kt @@ -39,7 +39,7 @@ object AnimeSources : WatchSources() { } fun performReorderAnimeSources() { - //remove the downloaded source from the list to avoid duplicates + // Remove the downloaded source from the list to avoid duplicates list = list.filter { it.name != "Downloaded" } list = sortPinnedAnimeSources(list, pinnedAnimeSources) + Lazier( { OfflineAnimeParser() }, diff --git a/app/src/main/res/layout/dialog_layout.xml b/app/src/main/res/layout/dialog_layout.xml index 4eae05d3b7..eab3f4792f 100644 --- a/app/src/main/res/layout/dialog_layout.xml +++ b/app/src/main/res/layout/dialog_layout.xml @@ -54,7 +54,7 @@ app:cardElevation="0dp"> @@ -235,7 +235,7 @@ app:cardElevation="0dp"> + tools:listitem="@layout/item_media_source" /> diff --git a/app/src/main/res/layout/item_episode_grid.xml b/app/src/main/res/layout/item_episode_grid.xml index d793687dd8..12dd8636a1 100644 --- a/app/src/main/res/layout/item_episode_grid.xml +++ b/app/src/main/res/layout/item_episode_grid.xml @@ -13,7 +13,7 @@ app:cardElevation="4dp"> diff --git a/app/src/main/res/layout/item_episode_list.xml b/app/src/main/res/layout/item_episode_list.xml index 3e33c88213..a42145378a 100644 --- a/app/src/main/res/layout/item_episode_list.xml +++ b/app/src/main/res/layout/item_episode_list.xml @@ -47,7 +47,7 @@ android:indeterminate="true" /> @@ -318,7 +318,7 @@ Chapter Wrong Title? - Couldn\'t find anything X( \n - Try another source. + Hmm, nothing came up from this source.\n + Let\'s look elsewhere :) + + + Your downloads are feeling a bit lonely…\n + Nothing here yet :( %1$s is not supported! Select Server