feat: automatically check sources

This commit is contained in:
TwistedUmbrellaX 2024-03-19 19:59:50 -04:00
parent ab7bc15573
commit 26d97da066
7 changed files with 75 additions and 2 deletions

View file

@ -159,8 +159,7 @@ class AnimeWatchAdapter(
} }
subscribeButton(false) subscribeButton(false)
fragment.loadEpisodes(media.selected!!.sourceIndex, true) fragment.loadEpisodes(media.selected!!.sourceIndex, true)
} ?: run { } ?: run { }
}
} }
//settings //settings
@ -430,6 +429,22 @@ class AnimeWatchAdapter(
val sourceFound = media.anime.episodes!!.isNotEmpty() val sourceFound = media.anime.episodes!!.isNotEmpty()
binding.animeSourceNotFound.isGone = sourceFound binding.animeSourceNotFound.isGone = sourceFound
binding.faqbutton.isGone = sourceFound binding.faqbutton.isGone = sourceFound
if (!sourceFound && PrefManager.getVal(PrefName.SearchSources)) {
if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) {
val nextIndex = media.selected!!.sourceIndex + 1
binding.animeSource.setText(binding.animeSource.adapter
.getItem(nextIndex).toString(), false)
fragment.onSourceChange(nextIndex).apply {
binding.animeSourceTitle.text = showUserText
showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } }
binding.animeSourceDubbed.isChecked = selectDub
binding.animeSourceDubbedCont.isVisible = isDubAvailableSeparately()
setLanguageList(0, nextIndex)
}
subscribeButton(false)
fragment.loadEpisodes(nextIndex, false)
}
}
} else { } else {
binding.animeSourceContinue.visibility = View.GONE binding.animeSourceContinue.visibility = View.GONE
binding.animeSourceNotFound.visibility = View.GONE binding.animeSourceNotFound.visibility = View.GONE

View file

@ -481,6 +481,22 @@ class MangaReadAdapter(
val sourceFound = media.manga.chapters!!.isNotEmpty() val sourceFound = media.manga.chapters!!.isNotEmpty()
binding.animeSourceNotFound.isGone = sourceFound binding.animeSourceNotFound.isGone = sourceFound
binding.faqbutton.isGone = sourceFound binding.faqbutton.isGone = sourceFound
if (!sourceFound && PrefManager.getVal(PrefName.SearchSources)) {
if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) {
val nextIndex = media.selected!!.sourceIndex + 1
binding.animeSource.setText(binding.animeSource.adapter
.getItem(nextIndex).toString(), false)
fragment.onSourceChange(nextIndex).apply {
binding.animeSourceTitle.text = showUserText
showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } }
setLanguageList(0, nextIndex)
}
subscribeButton(false)
// invalidate if it's the last source
val invalidate = nextIndex == mangaReadSources.names.size - 1
fragment.loadChapters(nextIndex, invalidate)
}
}
} else { } else {
binding.animeSourceContinue.visibility = View.GONE binding.animeSourceContinue.visibility = View.GONE
binding.animeSourceNotFound.visibility = View.GONE binding.animeSourceNotFound.visibility = View.GONE

View file

@ -710,6 +710,11 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
PrefManager.setVal(PrefName.ContinueMedia, isChecked) PrefManager.setVal(PrefName.ContinueMedia, isChecked)
} }
settingsSearchSources.isChecked = PrefManager.getVal(PrefName.SearchSources)
settingsSearchSources.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.SearchSources, isChecked)
}
settingsRecentlyListOnly.isChecked = PrefManager.getVal(PrefName.RecentlyListOnly) settingsRecentlyListOnly.isChecked = PrefManager.getVal(PrefName.RecentlyListOnly)
settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked -> settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.RecentlyListOnly, isChecked) PrefManager.setVal(PrefName.RecentlyListOnly, isChecked)

View file

@ -15,6 +15,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
NSFWExtension(Pref(Location.General, Boolean::class, true)), NSFWExtension(Pref(Location.General, Boolean::class, true)),
SdDl(Pref(Location.General, Boolean::class, false)), SdDl(Pref(Location.General, Boolean::class, false)),
ContinueMedia(Pref(Location.General, Boolean::class, true)), ContinueMedia(Pref(Location.General, Boolean::class, true)),
SearchSources(Pref(Location.General, Boolean::class, true)),
RecentlyListOnly(Pref(Location.General, Boolean::class, false)), RecentlyListOnly(Pref(Location.General, Boolean::class, false)),
SettingsPreferDub(Pref(Location.General, Boolean::class, false)), SettingsPreferDub(Pref(Location.General, Boolean::class, false)),
SubscriptionCheckingNotifications(Pref(Location.General, Boolean::class, true)), SubscriptionCheckingNotifications(Pref(Location.General, Boolean::class, true)),

View file

@ -0,0 +1,17 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:tint="#000000"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp">
<path
android:fillColor="@android:color/white"
android:pathData="M11.5,3.5m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
<path
android:fillColor="@android:color/white"
android:pathData="M12.13,7.12c-0.17,-0.35 -0.44,-0.65 -0.8,-0.85C10.72,5.91 9.99,5.93 9.4,6.24l0,-0.01L4,9.3V14h2v-3.54l1.5,-0.85C7.18,10.71 7,11.85 7,13v5.33L4.4,21.8L6,23l3,-4l0.22,-3.54L11,18v5h2v-6.5l-1.97,-2.81c-0.04,-0.52 -0.14,-1.76 0.45,-3.4c0.75,1.14 1.88,1.98 3.2,2.41L20.63,23l0.87,-0.5L16.02,13H17v-2c-0.49,0 -2.88,0.17 -4.08,-2.21"/>
</vector>

View file

@ -263,6 +263,24 @@
app:showText="false" app:showText="false"
app:thumbTint="@color/button_switch_track" /> app:thumbTint="@color/button_switch_track" />
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/settingsSearchSources"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:drawableStart="@drawable/ic_round_search_sources_24"
android:drawablePadding="16dp"
android:elegantTextHeight="true"
android:fontFamily="@font/poppins_bold"
android:minHeight="64dp"
android:text="@string/search_source_list"
android:textAlignment="viewStart"
android:textColor="?attr/colorOnBackground"
app:cornerRadius="0dp"
app:drawableTint="?attr/colorPrimary"
app:showText="false"
app:thumbTint="@color/button_switch_track" />
<com.google.android.material.materialswitch.MaterialSwitch <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/settingsRecentlyListOnly" android:id="@+id/settingsRecentlyListOnly"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -370,6 +370,7 @@
<string name="planned_manga">Planned Manga</string> <string name="planned_manga">Planned Manga</string>
<string name="image_long_clicking">Open image by Long Clicking</string> <string name="image_long_clicking">Open image by Long Clicking</string>
<string name="always_continue_shows">Always continue Shows</string> <string name="always_continue_shows">Always continue Shows</string>
<string name="search_source_list">Search available sources</string>
<string name="timestamp_proxy_desc">Useful if you are getting Handshake Fails</string> <string name="timestamp_proxy_desc">Useful if you are getting Handshake Fails</string>
<string name="timestamp_proxy">Use Proxy for Timestamps</string> <string name="timestamp_proxy">Use Proxy for Timestamps</string>
<string name="check_app_updates">Always check for App Updates</string> <string name="check_app_updates">Always check for App Updates</string>