This commit is contained in:
rebelonion 2024-02-01 14:54:27 -06:00
commit b559a13bab
39 changed files with 859 additions and 864 deletions

View file

@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
//get FRAGMENT_CLASS_NAME from intent //get FRAGMENT_CLASS_NAME from intent
val FRAGMENT_CLASS_NAME = intent.getStringExtra("FRAGMENT_CLASS_NAME") val fragment = intent.getStringExtra("FRAGMENT_CLASS_NAME")
binding = ActivityMainBinding.inflate(layoutInflater) binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
@ -209,8 +209,8 @@ class MainActivity : AppCompatActivity() {
binding.root.doOnAttach { binding.root.doOnAttach {
initActivity(this) initActivity(this)
uiSettings = loadData("ui_settings") ?: uiSettings uiSettings = loadData("ui_settings") ?: uiSettings
selectedOption = if (FRAGMENT_CLASS_NAME != null) { selectedOption = if (fragment != null) {
when (FRAGMENT_CLASS_NAME) { when (fragment) {
AnimeFragment::class.java.name -> 0 AnimeFragment::class.java.name -> 0
HomeFragment::class.java.name -> 1 HomeFragment::class.java.name -> 1
MangaFragment::class.java.name -> 2 MangaFragment::class.java.name -> 2
@ -299,7 +299,7 @@ class MainActivity : AppCompatActivity() {
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (loadData<Boolean>("allow_opening_links", this) != true) { if (!PrefWrapper.getVal(PrefName.AllowOpeningLinks, false)) {
CustomBottomDialog.newInstance().apply { CustomBottomDialog.newInstance().apply {
title = "Allow Dantotsu to automatically open Anilist & MAL Links?" title = "Allow Dantotsu to automatically open Anilist & MAL Links?"
val md = "Open settings & click +Add Links & select Anilist & Mal urls" val md = "Open settings & click +Add Links & select Anilist & Mal urls"
@ -311,18 +311,19 @@ class MainActivity : AppCompatActivity() {
}) })
setNegativeButton(this@MainActivity.getString(R.string.no)) { setNegativeButton(this@MainActivity.getString(R.string.no)) {
saveData("allow_opening_links", true, this@MainActivity) PrefWrapper.setVal(PrefName.AllowOpeningLinks, true)
dismiss() dismiss()
} }
setPositiveButton(this@MainActivity.getString(R.string.yes)) { setPositiveButton(this@MainActivity.getString(R.string.yes)) {
saveData("allow_opening_links", true, this@MainActivity) PrefWrapper.setVal(PrefName.AllowOpeningLinks, true)
tryWith(true) { tryWith(true) {
startActivity( startActivity(
Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS) Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS)
.setData(Uri.parse("package:$packageName")) .setData(Uri.parse("package:$packageName"))
) )
} }
dismiss()
} }
}.show(supportFragmentManager, "dialog") }.show(supportFragmentManager, "dialog")
} }
@ -336,7 +337,7 @@ class MainActivity : AppCompatActivity() {
while (downloadCursor.moveToNext()) { while (downloadCursor.moveToNext()) {
val download = downloadCursor.download val download = downloadCursor.download
Log.e("Downloader", download.request.uri.toString()) Log.e("Downloader", download.request.uri.toString())
Log.e("Downloader", download.request.id.toString()) Log.e("Downloader", download.request.id)
Log.e("Downloader", download.request.mimeType.toString()) Log.e("Downloader", download.request.mimeType.toString())
Log.e("Downloader", download.request.data.size.toString()) Log.e("Downloader", download.request.data.size.toString())
Log.e("Downloader", download.bytesDownloaded.toString()) Log.e("Downloader", download.bytesDownloaded.toString())

View file

@ -719,7 +719,7 @@ Page(page:$page,perPage:50) {
if (smaller) { if (smaller) {
val response = execute()?.airingSchedules ?: return null val response = execute()?.airingSchedules ?: return null
val idArr = mutableListOf<Int>() val idArr = mutableListOf<Int>()
val listOnly = loadData("recently_list_only") ?: false val listOnly = PrefWrapper.getVal(PrefName.RecentlyListOnly, false)
return response.mapNotNull { i -> return response.mapNotNull { i ->
i.media?.let { i.media?.let {
if (!idArr.contains(it.id)) if (!idArr.contains(it.id))

View file

@ -101,7 +101,7 @@ class AnilistHomeViewModel : ViewModel() {
Anilist.getSavedToken(context) Anilist.getSavedToken(context)
MAL.getSavedToken(context) MAL.getSavedToken(context)
Discord.getSavedToken(context) Discord.getSavedToken(context)
if (loadData<Boolean>("check_update") != false) AppUpdater.check(context) if (PrefWrapper.getVal(PrefName.CheckUpdate, false)) AppUpdater.check(context)
genres.postValue(Anilist.query.getGenresAndTags(context)) genres.postValue(Anilist.query.getGenresAndTags(context))
} }

View file

@ -272,7 +272,7 @@ class AnimeFragment : Fragment() {
model.loadTrending(1) model.loadTrending(1)
model.loadUpdated() model.loadUpdated()
model.loadPopular("ANIME", sort = Anilist.sortBy[1], onList = PrefWrapper.getVal( model.loadPopular("ANIME", sort = Anilist.sortBy[1], onList = PrefWrapper.getVal(
PrefName.PopularAnimeList, false)) PrefName.PopularAnimeList, true))
} }
live.postValue(false) live.postValue(false)
_binding?.animeRefresh?.isRefreshing = false _binding?.animeRefresh?.isRefreshing = false

View file

@ -246,8 +246,7 @@ class MangaFragment : Fragment() {
model.loadTrending() model.loadTrending()
model.loadTrendingNovel() model.loadTrendingNovel()
model.loadPopular("MANGA", sort = Anilist.sortBy[1], onList = PrefWrapper.getVal( model.loadPopular("MANGA", sort = Anilist.sortBy[1], onList = PrefWrapper.getVal(
PrefName.PopularMangaList, false PrefName.PopularMangaList, true))
))
} }
live.postValue(false) live.postValue(false)
_binding?.mangaRefresh?.isRefreshing = false _binding?.mangaRefresh?.isRefreshing = false

View file

@ -123,7 +123,7 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
binding.mangaIncludeList.visibility = binding.mangaIncludeList.visibility =
if (Anilist.userid != null) View.VISIBLE else View.GONE if (Anilist.userid != null) View.VISIBLE else View.GONE
binding.mangaIncludeList.isChecked = PrefWrapper.getVal(PrefName.PopularMangaList, false) binding.mangaIncludeList.isChecked = PrefWrapper.getVal(PrefName.PopularMangaList, true)
binding.mangaIncludeList.setOnCheckedChangeListener { _, isChecked -> binding.mangaIncludeList.setOnCheckedChangeListener { _, isChecked ->
onIncludeListClick.invoke(isChecked) onIncludeListClick.invoke(isChecked)

View file

@ -33,7 +33,6 @@ import nl.joery.animatedbottombar.AnimatedBottomBar
class NoInternet : AppCompatActivity() { class NoInternet : AppCompatActivity() {
private lateinit var binding: ActivityNoInternetBinding private lateinit var binding: ActivityNoInternetBinding
lateinit var bottomBar: AnimatedBottomBar
private var uiSettings = UserInterfaceSettings() private var uiSettings = UserInterfaceSettings()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -43,16 +42,16 @@ class NoInternet : AppCompatActivity() {
binding = ActivityNoInternetBinding.inflate(layoutInflater) binding = ActivityNoInternetBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
val _bottomBar = findViewById<AnimatedBottomBar>(R.id.navbar) val bottomBar = findViewById<AnimatedBottomBar>(R.id.navbar)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val backgroundDrawable = _bottomBar.background as GradientDrawable val backgroundDrawable = bottomBar.background as GradientDrawable
val currentColor = backgroundDrawable.color?.defaultColor ?: 0 val currentColor = backgroundDrawable.color?.defaultColor ?: 0
val semiTransparentColor = (currentColor and 0x00FFFFFF) or 0xE8000000.toInt() val semiTransparentColor = (currentColor and 0x00FFFFFF) or 0xE8000000.toInt()
backgroundDrawable.setColor(semiTransparentColor) backgroundDrawable.setColor(semiTransparentColor)
_bottomBar.background = backgroundDrawable bottomBar.background = backgroundDrawable
} }
_bottomBar.background = ContextCompat.getDrawable(this, R.drawable.bottom_nav_gray) bottomBar.background = ContextCompat.getDrawable(this, R.drawable.bottom_nav_gray)
var doubleBackToExitPressedOnce = false var doubleBackToExitPressedOnce = false

View file

@ -355,7 +355,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
viewPager.setCurrentItem(selected, false) viewPager.setCurrentItem(selected, false)
if (model.continueMedia == null && media.cameFromContinue) { if (model.continueMedia == null && media.cameFromContinue) {
model.continueMedia = loadData("continue_media") ?: true model.continueMedia = PrefWrapper.getVal(PrefName.ContinueMedia, true)
selected = 1 selected = 1
} }

View file

@ -28,6 +28,8 @@ import ani.dantotsu.parsers.ShowResponse
import ani.dantotsu.parsers.VideoExtractor import ani.dantotsu.parsers.VideoExtractor
import ani.dantotsu.parsers.WatchSources import ani.dantotsu.parsers.WatchSources
import ani.dantotsu.saveData import ani.dantotsu.saveData
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.snackString import ani.dantotsu.snackString
import ani.dantotsu.tryWithSuspend import ani.dantotsu.tryWithSuspend
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
@ -48,7 +50,7 @@ class MediaDetailsViewModel : ViewModel() {
fun loadSelected(media: Media, isDownload: Boolean = false): Selected { fun loadSelected(media: Media, isDownload: Boolean = false): Selected {
val data = loadData<Selected>("${media.id}-select") ?: Selected().let { val data = loadData<Selected>("${media.id}-select") ?: Selected().let {
it.sourceIndex = 0 it.sourceIndex = 0
it.preferDub = loadData("settings_prefer_dub") ?: false it.preferDub = PrefWrapper.getVal(PrefName.SettingsPreferDub, false)
saveSelected(media.id, it) saveSelected(media.id, it)
it it
} }

View file

@ -16,6 +16,8 @@ import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.connections.anilist.AnilistSearch import ani.dantotsu.connections.anilist.AnilistSearch
import ani.dantotsu.connections.anilist.SearchResults import ani.dantotsu.connections.anilist.SearchResults
import ani.dantotsu.databinding.ActivitySearchBinding import ani.dantotsu.databinding.ActivitySearchBinding
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.themes.ThemeManager import ani.dantotsu.themes.ThemeManager
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -51,7 +53,7 @@ class SearchActivity : AppCompatActivity() {
bottom = navBarHeight + 80f.px bottom = navBarHeight + 80f.px
) )
style = loadData<Int>("searchStyle") ?: 0 style = PrefWrapper.getVal(PrefName.SearchStyle,0)
var listOnly: Boolean? = intent.getBooleanExtra("listOnly", false) var listOnly: Boolean? = intent.getBooleanExtra("listOnly", false)
if (!listOnly!!) listOnly = null if (!listOnly!!) listOnly = null

View file

@ -22,7 +22,6 @@ import ani.dantotsu.R
import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.databinding.ItemChipBinding import ani.dantotsu.databinding.ItemChipBinding
import ani.dantotsu.databinding.ItemSearchHeaderBinding import ani.dantotsu.databinding.ItemSearchHeaderBinding
import ani.dantotsu.saveData
import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper import ani.dantotsu.settings.saving.PrefWrapper
import com.google.android.material.checkbox.MaterialCheckBox.* import com.google.android.material.checkbox.MaterialCheckBox.*
@ -149,14 +148,14 @@ class SearchAdapter(private val activity: SearchActivity, private val type: Stri
it.alpha = 1f it.alpha = 1f
binding.searchResultList.alpha = 0.33f binding.searchResultList.alpha = 0.33f
activity.style = 0 activity.style = 0
saveData("searchStyle", 0) PrefWrapper.setVal(PrefName.SearchStyle, 0)
activity.recycler() activity.recycler()
} }
binding.searchResultList.setOnClickListener { binding.searchResultList.setOnClickListener {
it.alpha = 1f it.alpha = 1f
binding.searchResultGrid.alpha = 0.33f binding.searchResultGrid.alpha = 0.33f
activity.style = 1 activity.style = 1
saveData("searchStyle", 1) PrefWrapper.setVal(PrefName.SearchStyle, 1)
activity.recycler() activity.recycler()
} }

View file

@ -383,12 +383,10 @@ class AnimeWatchFragment : Fragment() {
if (allSettings.size > 1) { if (allSettings.size > 1) {
val names = val names =
allSettings.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray() allSettings.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray()
var selectedIndex = 0
val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup) val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup)
.setTitle("Select a Source") .setTitle("Select a Source")
.setSingleChoiceItems(names, selectedIndex) { dialog, which -> .setSingleChoiceItems(names, -1) { dialog, which ->
selectedIndex = which selectedSetting = allSettings[which]
selectedSetting = allSettings[selectedIndex]
itemSelected = true itemSelected = true
dialog.dismiss() dialog.dismiss()

View file

@ -543,7 +543,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
exoPlayer.seekTo(exoPlayer.currentPosition + settings.skipTime * 1000) exoPlayer.seekTo(exoPlayer.currentPosition + settings.skipTime * 1000)
} }
exoSkip.setOnLongClickListener { exoSkip.setOnLongClickListener {
val dialog = Dialog(this, R.style.DialogTheme) val dialog = Dialog(this, R.style.MyPopup)
dialog.setContentView(R.layout.item_seekbar_dialog) dialog.setContentView(R.layout.item_seekbar_dialog)
dialog.setCancelable(true) dialog.setCancelable(true)
dialog.setCanceledOnTouchOutside(true) dialog.setCanceledOnTouchOutside(true)
@ -1013,9 +1013,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
initPlayer() initPlayer()
preloading = false preloading = false
val context = this val context = this
val offline = PrefWrapper.getVal(PrefName.OfflineMode, false)
val incognito = PrefWrapper.getVal(PrefName.Incognito, false) val incognito = PrefWrapper.getVal(PrefName.Incognito, false)
if (isOnline(context) && Discord.token != null && !incognito) { if ((isOnline(context) && !offline) && Discord.token != null && !incognito) {
lifecycleScope.launch { lifecycleScope.launch {
val presence = RPC.createPresence(RPC.Companion.RPCData( val presence = RPC.createPresence(RPC.Companion.RPCData(
applicationId = Discord.application_Id, applicationId = Discord.application_Id,
@ -1144,7 +1144,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
playbackParameters = PlaybackParameters(speeds[curSpeed]) playbackParameters = PlaybackParameters(speeds[curSpeed])
var speed: Float var speed: Float
val speedDialog = val speedDialog =
AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.speed)) AlertDialog.Builder(this, R.style.MyPopup).setTitle(getString(R.string.speed))
exoSpeed.setOnClickListener { exoSpeed.setOnClickListener {
val dialog = speedDialog.setSingleChoiceItems(speedsName, curSpeed) { dialog, i -> val dialog = speedDialog.setSingleChoiceItems(speedsName, curSpeed) { dialog, i ->
if (isInitialized) { if (isInitialized) {
@ -1413,7 +1413,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
) )
) )
) )
val dialog = AlertDialog.Builder(this, R.style.DialogTheme) val dialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.continue_from, time)).apply { .setTitle(getString(R.string.continue_from, time)).apply {
setCancelable(false) setCancelable(false)
setPositiveButton(getString(R.string.yes)) { d, _ -> setPositiveButton(getString(R.string.yes)) { d, _ ->

View file

@ -27,6 +27,8 @@ import ani.dantotsu.others.Download.download
import ani.dantotsu.parsers.Subtitle import ani.dantotsu.parsers.Subtitle
import ani.dantotsu.parsers.VideoExtractor import ani.dantotsu.parsers.VideoExtractor
import ani.dantotsu.parsers.VideoType import ani.dantotsu.parsers.VideoType
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import com.google.firebase.crashlytics.FirebaseCrashlytics import com.google.firebase.crashlytics.FirebaseCrashlytics
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -299,7 +301,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
extractor.server.name extractor.server.name
media!!.anime!!.episodes!![media!!.anime!!.selectedEpisode!!]!!.selectedVideo = media!!.anime!!.episodes!![media!!.anime!!.selectedEpisode!!]!!.selectedVideo =
position position
if ((loadData<Int>("settings_download_manager") ?: 0) != 0) { if (PrefWrapper.getVal(PrefName.DownloadManager, 0) != 0) {
download( download(
requireActivity(), requireActivity(),
media!!.anime!!.episodes!![media!!.anime!!.selectedEpisode!!]!!, media!!.anime!!.episodes!![media!!.anime!!.selectedEpisode!!]!!,

View file

@ -386,12 +386,10 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
if (allSettings.size > 1) { if (allSettings.size > 1) {
val names = val names =
allSettings.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray() allSettings.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray()
var selectedIndex = 0
val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup) val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup)
.setTitle("Select a Source") .setTitle("Select a Source")
.setSingleChoiceItems(names, selectedIndex) { dialog, which -> .setSingleChoiceItems(names, -1) { dialog, which ->
selectedIndex = which selectedSetting = allSettings[which]
selectedSetting = allSettings[selectedIndex]
itemSelected = true itemSelected = true
dialog.dismiss() dialog.dismiss()

View file

@ -98,8 +98,6 @@ class MangaReaderActivity : AppCompatActivity() {
var sliding = false var sliding = false
var isAnimating = false var isAnimating = false
private var rpc: RPC? = null
override fun onAttachedToWindow() { override fun onAttachedToWindow() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && !settings.showSystemBars) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && !settings.showSystemBars) {
val displayCutout = window.decorView.rootWindowInsets.displayCutout val displayCutout = window.decorView.rootWindowInsets.displayCutout
@ -320,8 +318,9 @@ class MangaReaderActivity : AppCompatActivity() {
chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: "" chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: ""
applySettings() applySettings()
val context = this val context = this
val offline = PrefWrapper.getVal(PrefName.OfflineMode, false)
val incognito = PrefWrapper.getVal(PrefName.Incognito, false) val incognito = PrefWrapper.getVal(PrefName.Incognito, false)
if (isOnline(context) && Discord.token != null && !incognito) { if ((isOnline(context) && !offline) && Discord.token != null && !incognito) {
lifecycleScope.launch { lifecycleScope.launch {
val presence = RPC.createPresence( val presence = RPC.createPresence(
RPC.Companion.RPCData( RPC.Companion.RPCData(

View file

@ -104,7 +104,7 @@ class NovelResponseAdapter(
binding.root.setOnLongClickListener { binding.root.setOnLongClickListener {
val builder = androidx.appcompat.app.AlertDialog.Builder( val builder = androidx.appcompat.app.AlertDialog.Builder(
fragment.requireContext(), fragment.requireContext(),
R.style.DialogTheme R.style.MyPopup
) )
builder.setTitle("Delete ${novel.name}?") builder.setTitle("Delete ${novel.name}?")
builder.setMessage("Are you sure you want to delete ${novel.name}?") builder.setMessage("Are you sure you want to delete ${novel.name}?")

View file

@ -17,6 +17,8 @@ import ani.dantotsu.defaultHeaders
import ani.dantotsu.loadData import ani.dantotsu.loadData
import ani.dantotsu.media.anime.Episode import ani.dantotsu.media.anime.Episode
import ani.dantotsu.parsers.Book import ani.dantotsu.parsers.Book
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.toast import ani.dantotsu.toast
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -36,7 +38,7 @@ object Download {
private fun getDownloadDir(context: Context): File { private fun getDownloadDir(context: Context): File {
val direct: File val direct: File
if (loadData<Boolean>("sd_dl") == true) { if (PrefWrapper.getVal(PrefName.SdDl, false)) {
val arrayOfFiles = ContextCompat.getExternalFilesDirs(context, null) val arrayOfFiles = ContextCompat.getExternalFilesDirs(context, null)
val parentDirectory = arrayOfFiles[1].toString() val parentDirectory = arrayOfFiles[1].toString()
direct = File(parentDirectory) direct = File(parentDirectory)
@ -92,7 +94,7 @@ object Download {
if (!file.url.startsWith("http")) if (!file.url.startsWith("http"))
toast(context.getString(R.string.invalid_url)) toast(context.getString(R.string.invalid_url))
else else
when (loadData<Int>("settings_download_manager", context, false) ?: 0) { when (PrefWrapper.getVal(PrefName.DownloadManager, 0)) {
1 -> oneDM(context, file, notif ?: fileName) 1 -> oneDM(context, file, notif ?: fileName)
2 -> adm(context, file, fileName, folder) 2 -> adm(context, file, fileName, folder)
else -> defaultDownload(context, file, fileName, folder, notif ?: fileName) else -> defaultDownload(context, file, fileName, folder, notif ?: fileName)
@ -117,7 +119,7 @@ object Download {
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
val arrayOfFiles = ContextCompat.getExternalFilesDirs(context, null) val arrayOfFiles = ContextCompat.getExternalFilesDirs(context, null)
if (loadData<Boolean>("sd_dl") == true && arrayOfFiles.size > 1 && arrayOfFiles[0] != null && arrayOfFiles[1] != null) { if (PrefWrapper.getVal(PrefName.SdDl, false) && arrayOfFiles.size > 1 && arrayOfFiles[0] != null && arrayOfFiles[1] != null) {
val parentDirectory = arrayOfFiles[1].toString() + folder val parentDirectory = arrayOfFiles[1].toString() + folder
val direct = File(parentDirectory) val direct = File(parentDirectory)
if (!direct.exists()) direct.mkdirs() if (!direct.exists()) direct.mkdirs()

View file

@ -1,12 +1,12 @@
package ani.dantotsu.settings package ani.dantotsu.settings
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.AlertDialog
import android.os.Build.* import android.os.Build.*
import android.os.Build.VERSION.* import android.os.Build.VERSION.*
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AutoCompleteTextView import android.widget.AutoCompleteTextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -16,6 +16,9 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import ani.dantotsu.* import ani.dantotsu.*
import ani.dantotsu.databinding.ActivityExtensionsBinding import ani.dantotsu.databinding.ActivityExtensionsBinding
import ani.dantotsu.others.LanguageMapper
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.themes.ThemeManager import ani.dantotsu.themes.ThemeManager
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
@ -111,20 +114,20 @@ class ExtensionsActivity : AppCompatActivity() {
} }
}) })
initActivity(this) initActivity(this)
binding.languageselect.visibility = View.GONE
/* TODO
binding.languageselect.setOnClickListener { binding.languageselect.setOnClickListener {
val popup = PopupMenu(this, it) val languageOptions = LanguageMapper.Companion.Language.entries.map{ it.name }.toTypedArray()
popup.inflate(R.menu.launguage_selector_menu) val builder = AlertDialog.Builder(currContext(), R.style.MyPopup)
popup.setOnMenuItemClickListener { menuItem -> val listOrder = PrefWrapper.getVal(PrefName.LangSort,"all")
true val index = LanguageMapper.Companion.Language.entries.toTypedArray().indexOfFirst{it.code == listOrder}
builder.setTitle("Language")
builder.setSingleChoiceItems(languageOptions, index){ dialog, i ->
PrefWrapper.setVal(PrefName.LangSort, LanguageMapper.Companion.Language.entries[i].code)
dialog.dismiss()
} }
popup.setOnDismissListener { val dialog = builder.show()
dialog.window?.setDimAmount(0.8f)
} }
popup.show()
}*/
binding.settingsContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { binding.settingsContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = statusBarHeight topMargin = statusBarHeight
bottomMargin = navBarHeight bottomMargin = navBarHeight

View file

@ -26,6 +26,8 @@ import ani.dantotsu.databinding.FragmentAnimeExtensionsBinding
import ani.dantotsu.loadData import ani.dantotsu.loadData
import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.LanguageMapper
import ani.dantotsu.settings.extensionprefs.AnimeSourcePreferencesFragment import ani.dantotsu.settings.extensionprefs.AnimeSourcePreferencesFragment
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.snackString import ani.dantotsu.snackString
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
@ -46,7 +48,7 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler {
private var _binding: FragmentAnimeExtensionsBinding? = null private var _binding: FragmentAnimeExtensionsBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private lateinit var extensionsRecyclerView: RecyclerView private lateinit var extensionsRecyclerView: RecyclerView
private val skipIcons = loadData("skip_extension_icons") ?: false private val skipIcons = PrefWrapper.getVal(PrefName.SkipExtensionIcons, false)
private val animeExtensionManager: AnimeExtensionManager = Injekt.get() private val animeExtensionManager: AnimeExtensionManager = Injekt.get()
private val extensionsAdapter = AnimeExtensionsAdapter( private val extensionsAdapter = AnimeExtensionsAdapter(
{ pkg -> { pkg ->

View file

@ -27,6 +27,8 @@ import ani.dantotsu.databinding.FragmentMangaExtensionsBinding
import ani.dantotsu.loadData import ani.dantotsu.loadData
import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.LanguageMapper
import ani.dantotsu.settings.extensionprefs.MangaSourcePreferencesFragment import ani.dantotsu.settings.extensionprefs.MangaSourcePreferencesFragment
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.snackString import ani.dantotsu.snackString
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
@ -45,7 +47,7 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler {
private var _binding: FragmentMangaExtensionsBinding? = null private var _binding: FragmentMangaExtensionsBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private lateinit var extensionsRecyclerView: RecyclerView private lateinit var extensionsRecyclerView: RecyclerView
private val skipIcons = loadData("skip_extension_icons") ?: false private val skipIcons = PrefWrapper.getVal(PrefName.SkipExtensionIcons, false)
private val mangaExtensionManager: MangaExtensionManager = Injekt.get() private val mangaExtensionManager: MangaExtensionManager = Injekt.get()
private val extensionsAdapter = MangaExtensionsAdapter( private val extensionsAdapter = MangaExtensionsAdapter(
{ pkg -> { pkg ->

View file

@ -24,6 +24,8 @@ import ani.dantotsu.loadData
import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.LanguageMapper
import ani.dantotsu.parsers.novel.NovelExtension import ani.dantotsu.parsers.novel.NovelExtension
import ani.dantotsu.parsers.novel.NovelExtensionManager import ani.dantotsu.parsers.novel.NovelExtensionManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.snackString import ani.dantotsu.snackString
import com.google.firebase.crashlytics.FirebaseCrashlytics import com.google.firebase.crashlytics.FirebaseCrashlytics
import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.notification.Notifications
@ -37,7 +39,7 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler {
private var _binding: FragmentNovelExtensionsBinding? = null private var _binding: FragmentNovelExtensionsBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private lateinit var extensionsRecyclerView: RecyclerView private lateinit var extensionsRecyclerView: RecyclerView
val skipIcons = loadData("skip_extension_icons") ?: false val skipIcons = PrefWrapper.getVal(PrefName.SkipExtensionIcons, false)
private val novelExtensionManager: NovelExtensionManager = Injekt.get() private val novelExtensionManager: NovelExtensionManager = Injekt.get()
private val extensionsAdapter = NovelExtensionsAdapter( private val extensionsAdapter = NovelExtensionsAdapter(
{ pkg -> { pkg ->

View file

@ -95,7 +95,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
var speedsName = curSpeedArr.map { "${it}x" }.toTypedArray() var speedsName = curSpeedArr.map { "${it}x" }.toTypedArray()
binding.playerSettingsSpeed.text = binding.playerSettingsSpeed.text =
getString(R.string.default_playback_speed, speedsName[settings.defaultSpeed]) getString(R.string.default_playback_speed, speedsName[settings.defaultSpeed])
val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme) val speedDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.default_speed)) .setTitle(getString(R.string.default_speed))
binding.playerSettingsSpeed.setOnClickListener { binding.playerSettingsSpeed.setOnClickListener {
val dialog = val dialog =
@ -246,7 +246,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
} }
val resizeModes = arrayOf("Original", "Zoom", "Stretch") val resizeModes = arrayOf("Original", "Zoom", "Stretch")
val resizeDialog = AlertDialog.Builder(this, R.style.DialogTheme) val resizeDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.default_resize_mode)) .setTitle(getString(R.string.default_resize_mode))
binding.playerResizeMode.setOnClickListener { binding.playerResizeMode.setOnClickListener {
val dialog = val dialog =
@ -332,7 +332,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
"Blue", "Blue",
"Magenta" "Magenta"
) )
val primaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme) val primaryColorDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.primary_sub_color)) .setTitle(getString(R.string.primary_sub_color))
binding.videoSubColorPrimary.setOnClickListener { binding.videoSubColorPrimary.setOnClickListener {
val dialog = primaryColorDialog.setSingleChoiceItems( val dialog = primaryColorDialog.setSingleChoiceItems(
@ -359,7 +359,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
"Magenta", "Magenta",
"Transparent" "Transparent"
) )
val secondaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme) val secondaryColorDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.outline_sub_color)) .setTitle(getString(R.string.outline_sub_color))
binding.videoSubColorSecondary.setOnClickListener { binding.videoSubColorSecondary.setOnClickListener {
val dialog = secondaryColorDialog.setSingleChoiceItems( val dialog = secondaryColorDialog.setSingleChoiceItems(
@ -373,7 +373,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None") val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None")
val outlineDialog = AlertDialog.Builder(this, R.style.DialogTheme) val outlineDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.outline_type)) .setTitle(getString(R.string.outline_type))
binding.videoSubOutline.setOnClickListener { binding.videoSubOutline.setOnClickListener {
val dialog = outlineDialog.setSingleChoiceItems( val dialog = outlineDialog.setSingleChoiceItems(
@ -400,7 +400,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
"Blue", "Blue",
"Magenta" "Magenta"
) )
val subBackgroundDialog = AlertDialog.Builder(this, R.style.DialogTheme) val subBackgroundDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.outline_sub_color)) .setTitle(getString(R.string.outline_sub_color))
binding.videoSubColorBackground.setOnClickListener { binding.videoSubColorBackground.setOnClickListener {
val dialog = subBackgroundDialog.setSingleChoiceItems( val dialog = subBackgroundDialog.setSingleChoiceItems(
@ -428,7 +428,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
"Blue", "Blue",
"Magenta" "Magenta"
) )
val subWindowDialog = AlertDialog.Builder(this, R.style.DialogTheme) val subWindowDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.outline_sub_color)) .setTitle(getString(R.string.outline_sub_color))
binding.videoSubColorWindow.setOnClickListener { binding.videoSubColorWindow.setOnClickListener {
val dialog = subWindowDialog.setSingleChoiceItems( val dialog = subWindowDialog.setSingleChoiceItems(
@ -449,7 +449,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
"Century Gothic", "Century Gothic",
"Century Gothic Bold" "Century Gothic Bold"
) )
val fontDialog = AlertDialog.Builder(this, R.style.DialogTheme) val fontDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.subtitle_font)) .setTitle(getString(R.string.subtitle_font))
binding.videoSubFont.setOnClickListener { binding.videoSubFont.setOnClickListener {
val dialog = fontDialog.setSingleChoiceItems(fonts, settings.font) { dialog, count -> val dialog = fontDialog.setSingleChoiceItems(fonts, settings.font) { dialog, count ->

View file

@ -207,15 +207,15 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
val managers = arrayOf("Default", "1DM", "ADM") val managers = arrayOf("Default", "1DM", "ADM")
val downloadManagerDialog = val downloadManagerDialog =
AlertDialog.Builder(this, R.style.DialogTheme).setTitle("Download Manager") AlertDialog.Builder(this, R.style.MyPopup).setTitle("Download Manager")
var downloadManager = loadData<Int>("settings_download_manager") ?: 0 var downloadManager = PrefWrapper.getVal(PrefName.DownloadManager, 0)
binding.settingsDownloadManager.setOnClickListener { binding.settingsDownloadManager.setOnClickListener {
val dialog = downloadManagerDialog.setSingleChoiceItems( val dialog = downloadManagerDialog.setSingleChoiceItems(
managers, managers,
downloadManager downloadManager
) { dialog, count -> ) { dialog, count ->
downloadManager = count downloadManager = count
saveData("settings_download_manager", downloadManager) PrefWrapper.setVal(PrefName.DownloadManager, downloadManager)
dialog.dismiss() dialog.dismiss()
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
@ -287,13 +287,13 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
} }
} }
binding.skipExtensionIcons.isChecked = loadData("skip_extension_icons") ?: false binding.skipExtensionIcons.isChecked = PrefWrapper.getVal(PrefName.SkipExtensionIcons, false)
binding.skipExtensionIcons.setOnCheckedChangeListener { _, isChecked -> binding.skipExtensionIcons.setOnCheckedChangeListener { _, isChecked ->
saveData("skip_extension_icons", isChecked) PrefWrapper.getVal(PrefName.SkipExtensionIcons, isChecked)
} }
binding.NSFWExtension.isChecked = loadData("NSFWExtension") ?: true binding.NSFWExtension.isChecked = PrefWrapper.getVal(PrefName.NSFWExtension, true)
binding.NSFWExtension.setOnCheckedChangeListener { _, isChecked -> binding.NSFWExtension.setOnCheckedChangeListener { _, isChecked ->
saveData("NSFWExtension", isChecked) PrefWrapper.setVal(PrefName.NSFWExtension,isChecked)
} }
@ -348,37 +348,37 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
Toast.makeText(this, "Restart app to apply changes", Toast.LENGTH_LONG).show() Toast.makeText(this, "Restart app to apply changes", Toast.LENGTH_LONG).show()
} }
binding.settingsDownloadInSd.isChecked = loadData("sd_dl") ?: false binding.settingsDownloadInSd.isChecked = PrefWrapper.getVal(PrefName.SdDl, false)
binding.settingsDownloadInSd.setOnCheckedChangeListener { _, isChecked -> binding.settingsDownloadInSd.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) { if (isChecked) {
val arrayOfFiles = ContextCompat.getExternalFilesDirs(this, null) val arrayOfFiles = ContextCompat.getExternalFilesDirs(this, null)
if (arrayOfFiles.size > 1 && arrayOfFiles[1] != null) { if (arrayOfFiles.size > 1 && arrayOfFiles[1] != null) {
saveData("sd_dl", true) PrefWrapper.setVal(PrefName.SdDl, true)
} else { } else {
binding.settingsDownloadInSd.isChecked = false binding.settingsDownloadInSd.isChecked = false
saveData("sd_dl", false) PrefWrapper.setVal(PrefName.SdDl, true)
snackString(getString(R.string.noSdFound)) snackString(getString(R.string.noSdFound))
} }
} else saveData("sd_dl", false) } else PrefWrapper.setVal(PrefName.SdDl, true)
} }
binding.settingsContinueMedia.isChecked = loadData("continue_media") ?: true binding.settingsContinueMedia.isChecked = PrefWrapper.getVal(PrefName.ContinueMedia, true)
binding.settingsContinueMedia.setOnCheckedChangeListener { _, isChecked -> binding.settingsContinueMedia.setOnCheckedChangeListener { _, isChecked ->
saveData("continue_media", isChecked) PrefWrapper.setVal(PrefName.ContinueMedia, isChecked)
} }
binding.settingsRecentlyListOnly.isChecked = loadData("recently_list_only") ?: false binding.settingsRecentlyListOnly.isChecked = PrefWrapper.getVal(PrefName.RecentlyListOnly, false)
binding.settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked -> binding.settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked ->
saveData("recently_list_only", isChecked) PrefWrapper.setVal(PrefName.RecentlyListOnly, isChecked)
} }
binding.settingsShareUsername.isChecked = PrefWrapper.getVal(PrefName.SharedUserID, true) binding.settingsShareUsername.isChecked = PrefWrapper.getVal(PrefName.SharedUserID, true)
binding.settingsShareUsername.setOnCheckedChangeListener { _, isChecked -> binding.settingsShareUsername.setOnCheckedChangeListener { _, isChecked ->
PrefWrapper.setVal(PrefName.SharedUserID, isChecked) PrefWrapper.setVal(PrefName.SharedUserID, isChecked)
} }
binding.settingsPreferDub.isChecked = loadData("settings_prefer_dub") ?: false binding.settingsPreferDub.isChecked = PrefWrapper.getVal(PrefName.SettingsPreferDub, false)
binding.settingsPreferDub.setOnCheckedChangeListener { _, isChecked -> binding.settingsPreferDub.setOnCheckedChangeListener { _, isChecked ->
saveData("settings_prefer_dub", isChecked) PrefWrapper.setVal(PrefName.SettingsPreferDub, isChecked)
} }
binding.settingsPinnedMangaSources.setOnClickListener { binding.settingsPinnedMangaSources.setOnClickListener {
@ -599,7 +599,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
} }
} }
var curTime = loadData<Int>("subscriptions_time_s") ?: defaultTime var curTime = PrefWrapper.getVal(PrefName.SubscriptionsTimeS, defaultTime)
val timeNames = timeMinutes.map { val timeNames = timeMinutes.map {
val mins = it % 60 val mins = it % 60
val hours = it / 60 val hours = it / 60
@ -608,14 +608,14 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
}.toTypedArray() }.toTypedArray()
binding.settingsSubscriptionsTime.text = binding.settingsSubscriptionsTime.text =
getString(R.string.subscriptions_checking_time_s, timeNames[curTime]) getString(R.string.subscriptions_checking_time_s, timeNames[curTime])
val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme) val speedDialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(R.string.subscriptions_checking_time) .setTitle(R.string.subscriptions_checking_time)
binding.settingsSubscriptionsTime.setOnClickListener { binding.settingsSubscriptionsTime.setOnClickListener {
val dialog = speedDialog.setSingleChoiceItems(timeNames, curTime) { dialog, i -> val dialog = speedDialog.setSingleChoiceItems(timeNames, curTime) { dialog, i ->
curTime = i curTime = i
binding.settingsSubscriptionsTime.text = binding.settingsSubscriptionsTime.text =
getString(R.string.subscriptions_checking_time_s, timeNames[i]) getString(R.string.subscriptions_checking_time_s, timeNames[i])
saveData("subscriptions_time_s", curTime) PrefWrapper.setVal(PrefName.SubscriptionsTimeS, curTime)
dialog.dismiss() dialog.dismiss()
startSubscription(true) startSubscription(true)
}.show() }.show()
@ -628,9 +628,9 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
} }
binding.settingsNotificationsCheckingSubscriptions.isChecked = binding.settingsNotificationsCheckingSubscriptions.isChecked =
loadData("subscription_checking_notifications") ?: true PrefWrapper.getVal(PrefName.SubscriptionCheckingNotifications, true)
binding.settingsNotificationsCheckingSubscriptions.setOnCheckedChangeListener { _, isChecked -> binding.settingsNotificationsCheckingSubscriptions.setOnCheckedChangeListener { _, isChecked ->
saveData("subscription_checking_notifications", isChecked) PrefWrapper.setVal(PrefName.SubscriptionCheckingNotifications, isChecked)
if (isChecked) if (isChecked)
Notifications.createChannel( Notifications.createChannel(
this, this,
@ -648,9 +648,10 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
} }
binding.settingsCheckUpdate.isChecked = loadData("check_update") ?: true binding.settingsCheckUpdate.isChecked = PrefWrapper.getVal(PrefName.CheckUpdate, true)
binding.settingsCheckUpdate.setOnCheckedChangeListener { _, isChecked -> binding.settingsCheckUpdate.setOnCheckedChangeListener { _, isChecked ->
saveData("check_update", isChecked) saveData("check_update", isChecked)
PrefWrapper.setVal(PrefName.CheckUpdate, isChecked)
if (!isChecked) { if (!isChecked) {
snackString(getString(R.string.long_click_to_check_update)) snackString(getString(R.string.long_click_to_check_update))
} }

View file

@ -41,7 +41,7 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
val views = resources.getStringArray(R.array.home_layouts) val views = resources.getStringArray(R.array.home_layouts)
binding.uiSettingsHomeLayout.setOnClickListener { binding.uiSettingsHomeLayout.setOnClickListener {
val dialog = AlertDialog.Builder(this, R.style.DialogTheme) val dialog = AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.home_layout_show)).apply { .setTitle(getString(R.string.home_layout_show)).apply {
setMultiChoiceItems( setMultiChoiceItems(
views, views,

View file

@ -19,8 +19,9 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import ani.dantotsu.R import ani.dantotsu.R
import ani.dantotsu.databinding.ItemExtensionAllBinding import ani.dantotsu.databinding.ItemExtensionAllBinding
import ani.dantotsu.loadData
import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.LanguageMapper
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
@ -92,15 +93,16 @@ class AnimeExtensionPagingSource(
val availableExtensions = val availableExtensions =
availableExtensionsFlow.filterNot { it.pkgName in installedExtensions } availableExtensionsFlow.filterNot { it.pkgName in installedExtensions }
val query = searchQuery val query = searchQuery
val isNsfwEnabled: Boolean = loadData("NSFWExtension") ?: true val isNsfwEnabled: Boolean = PrefWrapper.getVal(PrefName.NSFWExtension,true)
val filteredExtensions = if (query.isEmpty()) { val filteredExtensions = if (query.isEmpty()) {
availableExtensions availableExtensions
} else { } else {
availableExtensions.filter { it.name.contains(query, ignoreCase = true) } availableExtensions.filter { it.name.contains(query, ignoreCase = true) }
} }
val filternfsw = val lang = PrefWrapper.getVal(PrefName.LangSort, "all")
if (isNsfwEnabled) filteredExtensions else filteredExtensions.filterNot { it.isNsfw } val langFilter = if (lang != "all") filteredExtensions.filter { it.lang == lang } else filteredExtensions
val filternfsw = if (isNsfwEnabled) langFilter else langFilter.filterNot { it.isNsfw }
return try { return try {
val sublist = filternfsw.subList( val sublist = filternfsw.subList(
fromIndex = position, fromIndex = position,
@ -126,7 +128,7 @@ class AnimeExtensionAdapter(private val clickListener: OnAnimeInstallClickListen
DIFF_CALLBACK DIFF_CALLBACK
) { ) {
private val skipIcons = loadData("skip_extension_icons") ?: false private val skipIcons = PrefWrapper.getVal(PrefName.SkipExtensionIcons, false)
companion object { companion object {
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<AnimeExtension.Available>() { private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<AnimeExtension.Available>() {

View file

@ -21,6 +21,8 @@ import ani.dantotsu.R
import ani.dantotsu.databinding.ItemExtensionAllBinding import ani.dantotsu.databinding.ItemExtensionAllBinding
import ani.dantotsu.loadData import ani.dantotsu.loadData
import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.LanguageMapper
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
import eu.kanade.tachiyomi.extension.manga.model.MangaExtension import eu.kanade.tachiyomi.extension.manga.model.MangaExtension
@ -92,14 +94,15 @@ class MangaExtensionPagingSource(
val availableExtensions = val availableExtensions =
availableExtensionsFlow.filterNot { it.pkgName in installedExtensions } availableExtensionsFlow.filterNot { it.pkgName in installedExtensions }
val query = searchQuery val query = searchQuery
val isNsfwEnabled: Boolean = loadData("NSFWExtension") ?: true val isNsfwEnabled: Boolean = PrefWrapper.getVal(PrefName.NSFWExtension,true)
val filteredExtensions = if (query.isEmpty()) { val filteredExtensions = if (query.isEmpty()) {
availableExtensions availableExtensions
} else { } else {
availableExtensions.filter { it.name.contains(query, ignoreCase = true) } availableExtensions.filter { it.name.contains(query, ignoreCase = true) }
} }
val filternfsw = val lang = PrefWrapper.getVal(PrefName.LangSort, "all")
if (isNsfwEnabled) filteredExtensions else filteredExtensions.filterNot { it.isNsfw } val langFilter = if (lang != "all") filteredExtensions.filter { it.lang == lang } else filteredExtensions
val filternfsw = if (isNsfwEnabled) langFilter else langFilter.filterNot { it.isNsfw }
return try { return try {
val sublist = filternfsw.subList( val sublist = filternfsw.subList(
fromIndex = position, fromIndex = position,
@ -125,7 +128,7 @@ class MangaExtensionAdapter(private val clickListener: OnMangaInstallClickListen
DIFF_CALLBACK DIFF_CALLBACK
) { ) {
private val skipIcons = loadData("skip_extension_icons") ?: false private val skipIcons = PrefWrapper.getVal(PrefName.SkipExtensionIcons, false)
companion object { companion object {
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<MangaExtension.Available>() { private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<MangaExtension.Available>() {

View file

@ -22,6 +22,8 @@ import ani.dantotsu.loadData
import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.LanguageMapper
import ani.dantotsu.parsers.novel.NovelExtension import ani.dantotsu.parsers.novel.NovelExtension
import ani.dantotsu.parsers.novel.NovelExtensionManager import ani.dantotsu.parsers.novel.NovelExtensionManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -93,7 +95,7 @@ class NovelExtensionPagingSource(
val availableExtensions = val availableExtensions =
availableExtensionsFlow.filterNot { it.pkgName in installedExtensions } availableExtensionsFlow.filterNot { it.pkgName in installedExtensions }
val query = searchQuery val query = searchQuery
val isNsfwEnabled: Boolean = loadData("NFSWExtension") ?: true val isNsfwEnabled: Boolean = PrefWrapper.getVal(PrefName.NSFWExtension,true)
val filteredExtensions = if (query.isEmpty()) { val filteredExtensions = if (query.isEmpty()) {
availableExtensions availableExtensions
} else { } else {
@ -130,7 +132,7 @@ class NovelExtensionAdapter(private val clickListener: OnNovelInstallClickListen
DIFF_CALLBACK DIFF_CALLBACK
) { ) {
private val skipIcons = loadData("skip_extension_icons") ?: false private val skipIcons = PrefWrapper.getVal(PrefName.SkipExtensionIcons, false)
companion object { companion object {
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<NovelExtension.Available>() { private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<NovelExtension.Available>() {

View file

@ -1,8 +1,11 @@
package ani.dantotsu.settings.saving package ani.dantotsu.settings.saving
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import ani.dantotsu.settings.saving.internal.Compat
import ani.dantotsu.settings.saving.internal.Location import ani.dantotsu.settings.saving.internal.Location
import ani.dantotsu.snackString
object PrefWrapper { object PrefWrapper {
@ -15,7 +18,7 @@ object PrefWrapper {
private var animeDownloadsPreferences: SharedPreferences? = null private var animeDownloadsPreferences: SharedPreferences? = null
private var protectedPreferences: SharedPreferences? = null private var protectedPreferences: SharedPreferences? = null
fun init(context: Context) { fun init(context: Context) { //must be called in Application class or will crash
generalPreferences = context.getSharedPreferences(Location.General.location, Context.MODE_PRIVATE) generalPreferences = context.getSharedPreferences(Location.General.location, Context.MODE_PRIVATE)
animePreferences = context.getSharedPreferences(Location.Anime.location, Context.MODE_PRIVATE) animePreferences = context.getSharedPreferences(Location.Anime.location, Context.MODE_PRIVATE)
mangaPreferences = context.getSharedPreferences(Location.Manga.location, Context.MODE_PRIVATE) mangaPreferences = context.getSharedPreferences(Location.Manga.location, Context.MODE_PRIVATE)
@ -24,27 +27,19 @@ object PrefWrapper {
irrelevantPreferences = context.getSharedPreferences(Location.Irrelevant.location, Context.MODE_PRIVATE) irrelevantPreferences = context.getSharedPreferences(Location.Irrelevant.location, Context.MODE_PRIVATE)
animeDownloadsPreferences = context.getSharedPreferences(Location.AnimeDownloads.location, Context.MODE_PRIVATE) animeDownloadsPreferences = context.getSharedPreferences(Location.AnimeDownloads.location, Context.MODE_PRIVATE)
protectedPreferences = context.getSharedPreferences(Location.Protected.location, Context.MODE_PRIVATE) protectedPreferences = context.getSharedPreferences(Location.Protected.location, Context.MODE_PRIVATE)
Compat.importOldPrefs(context)
} }
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun <T> setVal(prefName: PrefName, value: T) { fun <T> setVal(prefName: PrefName, value: T) {
val pref = when (prefName.data.prefLocation) { val pref = getPrefLocation(prefName)
Location.General -> generalPreferences with(pref.edit()) {
Location.Anime -> animePreferences
Location.Manga -> mangaPreferences
Location.Player -> playerPreferences
Location.Reader -> readerPreferences
Location.Irrelevant -> irrelevantPreferences
Location.AnimeDownloads -> animeDownloadsPreferences
Location.Protected -> protectedPreferences
}
with(pref!!.edit()) {
when (prefName.data.type) { when (prefName.data.type) {
Boolean::class -> putBoolean(prefName.name, value as Boolean) Boolean::class -> putBoolean(prefName.name, value as Boolean)
Int::class -> putInt(prefName.name, value as Int) Int::class -> putInt(prefName.name, value as Int)
Float::class -> putFloat(prefName.name, value as Float) Float::class -> putFloat(prefName.name, value as Float)
Long::class -> putLong(prefName.name, value as Long) Long::class -> putLong(prefName.name, value as Long)
String::class -> putString(prefName.name, value as String) String::class -> putString(prefName.name, value as String?)
Set::class -> putStringSet(prefName.name, value as Set<String>) Set::class -> putStringSet(prefName.name, value as Set<String>)
else -> throw IllegalArgumentException("Type not supported") else -> throw IllegalArgumentException("Type not supported")
} }
@ -55,70 +50,53 @@ object PrefWrapper {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun <T> getVal(prefName: PrefName, default: T) : T { fun <T> getVal(prefName: PrefName, default: T) : T {
return try { return try {
val pref = when (prefName.data.prefLocation) { val pref = getPrefLocation(prefName)
Location.General -> generalPreferences
Location.Anime -> animePreferences
Location.Manga -> mangaPreferences
Location.Player -> playerPreferences
Location.Reader -> readerPreferences
Location.Irrelevant -> irrelevantPreferences
Location.AnimeDownloads -> animeDownloadsPreferences
Location.Protected -> protectedPreferences
}
when (prefName.data.type) { when (prefName.data.type) {
Boolean::class -> pref!!.getBoolean(prefName.name, default as Boolean) as T Boolean::class -> pref.getBoolean(prefName.name, default as Boolean) as T
Int::class -> pref!!.getInt(prefName.name, default as Int) as T Int::class -> pref.getInt(prefName.name, default as Int) as T
Float::class -> pref!!.getFloat(prefName.name, default as Float) as T Float::class -> pref.getFloat(prefName.name, default as Float) as T
Long::class -> pref!!.getLong(prefName.name, default as Long) as T Long::class -> pref.getLong(prefName.name, default as Long) as T
String::class -> pref!!.getString(prefName.name, default as String) as T String::class -> pref.getString(prefName.name, default as String?) as T
Set::class -> pref!!.getStringSet(prefName.name, default as Set<String>) as T Set::class -> pref.getStringSet(prefName.name, default as Set<String>) as T
else -> throw IllegalArgumentException("Type not supported") else -> throw IllegalArgumentException("Type not supported")
} }
} catch (e: Exception) { } catch (e: Exception) {
snackString("Error getting preference: ${e.message}")
default default
} }
} }
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun <T> getLiveVal(prefName: PrefName, default: T) : SharedPreferenceLiveData<T> { fun <T> getLiveVal(prefName: PrefName, default: T) : SharedPreferenceLiveData<T> {
val pref = when (prefName.data.prefLocation) { val pref = getPrefLocation(prefName)
Location.General -> generalPreferences
Location.Anime -> animePreferences
Location.Manga -> mangaPreferences
Location.Player -> playerPreferences
Location.Reader -> readerPreferences
Location.Irrelevant -> irrelevantPreferences
Location.AnimeDownloads -> animeDownloadsPreferences
Location.Protected -> protectedPreferences
}
return when (prefName.data.type) { return when (prefName.data.type) {
Boolean::class -> SharedPreferenceBooleanLiveData( Boolean::class -> SharedPreferenceBooleanLiveData(
pref!!, pref,
prefName.name, prefName.name,
default as Boolean default as Boolean
) as SharedPreferenceLiveData<T> ) as SharedPreferenceLiveData<T>
Int::class -> SharedPreferenceIntLiveData( Int::class -> SharedPreferenceIntLiveData(
pref!!, pref,
prefName.name, prefName.name,
default as Int default as Int
) as SharedPreferenceLiveData<T> ) as SharedPreferenceLiveData<T>
Float::class -> SharedPreferenceFloatLiveData( Float::class -> SharedPreferenceFloatLiveData(
pref!!, pref,
prefName.name, prefName.name,
default as Float default as Float
) as SharedPreferenceLiveData<T> ) as SharedPreferenceLiveData<T>
Long::class -> SharedPreferenceLongLiveData( Long::class -> SharedPreferenceLongLiveData(
pref!!, pref,
prefName.name, prefName.name,
default as Long default as Long
) as SharedPreferenceLiveData<T> ) as SharedPreferenceLiveData<T>
String::class -> SharedPreferenceStringLiveData( String::class -> SharedPreferenceStringLiveData(
pref!!, pref,
prefName.name, prefName.name,
default as String default as String
) as SharedPreferenceLiveData<T> ) as SharedPreferenceLiveData<T>
Set::class -> SharedPreferenceStringSetLiveData( Set::class -> SharedPreferenceStringSetLiveData(
pref!!, pref,
prefName.name, prefName.name,
default as Set<String> default as Set<String>
) as SharedPreferenceLiveData<T> ) as SharedPreferenceLiveData<T>
@ -127,17 +105,8 @@ object PrefWrapper {
} }
fun removeVal(prefName: PrefName) { fun removeVal(prefName: PrefName) {
val pref = when (prefName.data.prefLocation) { val pref = getPrefLocation(prefName)
Location.General -> generalPreferences with(pref.edit()) {
Location.Anime -> animePreferences
Location.Manga -> mangaPreferences
Location.Player -> playerPreferences
Location.Reader -> readerPreferences
Location.Irrelevant -> irrelevantPreferences
Location.AnimeDownloads -> animeDownloadsPreferences
Location.Protected -> protectedPreferences
}
with(pref!!.edit()) {
remove(prefName.name) remove(prefName.name)
apply() apply()
} }
@ -211,4 +180,17 @@ object PrefWrapper {
?: throw ClassCastException("Cannot cast to SharedPreferenceLiveData<Set<String>>") ?: throw ClassCastException("Cannot cast to SharedPreferenceLiveData<Set<String>>")
fun getAnimeDownloadPreferences(): SharedPreferences = animeDownloadsPreferences!! //needs to be used externally fun getAnimeDownloadPreferences(): SharedPreferences = animeDownloadsPreferences!! //needs to be used externally
private fun getPrefLocation(prefName: PrefName): SharedPreferences {
return when (prefName.data.prefLocation) {
Location.General -> generalPreferences
Location.Anime -> animePreferences
Location.Manga -> mangaPreferences
Location.Player -> playerPreferences
Location.Reader -> readerPreferences
Location.Irrelevant -> irrelevantPreferences
Location.AnimeDownloads -> animeDownloadsPreferences
Location.Protected -> protectedPreferences
}!!
}
} }

View file

@ -13,6 +13,16 @@ enum class PrefName(val data: Pref) {
UseSourceTheme(Pref(Location.General, Boolean::class)), UseSourceTheme(Pref(Location.General, Boolean::class)),
UseMaterialYou(Pref(Location.General, Boolean::class)), UseMaterialYou(Pref(Location.General, Boolean::class)),
Theme(Pref(Location.General, String::class)), Theme(Pref(Location.General, String::class)),
DownloadManager(Pref(Location.General, Int::class)),
NSFWExtension(Pref(Location.General, Boolean::class)),
SkipExtensionIcons(Pref(Location.General, Boolean::class)),
SdDl(Pref(Location.General, Boolean::class)),
ContinueMedia(Pref(Location.General, Boolean::class)),
RecentlyListOnly(Pref(Location.General, Boolean::class)),
SettingsPreferDub(Pref(Location.General, Boolean::class)),
SubscriptionsTimeS(Pref(Location.General, Int::class)),
SubscriptionCheckingNotifications(Pref(Location.General, Boolean::class)),
CheckUpdate(Pref(Location.General, Boolean::class)),
//Anime //Anime
AnimeListSortOrder(Pref(Location.Anime, String::class)), AnimeListSortOrder(Pref(Location.Anime, String::class)),
@ -26,13 +36,16 @@ enum class PrefName(val data: Pref) {
PopularMangaList(Pref(Location.Manga, Boolean::class)), PopularMangaList(Pref(Location.Manga, Boolean::class)),
MangaSearchHistory(Pref(Location.Manga, Set::class)), MangaSearchHistory(Pref(Location.Manga, Set::class)),
//Irrelevant //Irrelevant
Incognito(Pref(Location.Irrelevant, Boolean::class)), Incognito(Pref(Location.Irrelevant, Boolean::class)),
OfflineMode(Pref(Location.Irrelevant, Boolean::class)), OfflineMode(Pref(Location.Irrelevant, Boolean::class)),
DownloadsKeys(Pref(Location.Irrelevant, String::class)), DownloadsKeys(Pref(Location.Irrelevant, String::class)),
NovelLastExtCheck(Pref(Location.Irrelevant, Long::class)), NovelLastExtCheck(Pref(Location.Irrelevant, Long::class)),
SomethingSpecial(Pref(Location.Irrelevant, Boolean::class)), SomethingSpecial(Pref(Location.Irrelevant, Boolean::class)),
AllowOpeningLinks(Pref(Location.Irrelevant, Boolean::class)),
SearchStyle(Pref(Location.Irrelevant, Int::class)),
HasUpdatedPrefs(Pref(Location.Irrelevant, Boolean::class)),
LangSort(Pref(Location.Irrelevant, String::class)),
//Protected //Protected
DiscordToken(Pref(Location.Protected, String::class)), DiscordToken(Pref(Location.Protected, String::class)),

View file

@ -0,0 +1,18 @@
package ani.dantotsu.settings.saving.internal
import android.content.Context
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
class Compat {
companion object {
fun importOldPrefs(context: Context) {
if (PrefWrapper.getVal(PrefName.HasUpdatedPrefs, false)) return
val oldPrefs = context.getSharedPreferences("downloads_pref", Context.MODE_PRIVATE)
val jsonString = oldPrefs.getString("downloads_key", null)
PrefWrapper.setVal(PrefName.DownloadsKeys, jsonString)
oldPrefs.edit().clear().apply()
PrefWrapper.setVal(PrefName.HasUpdatedPrefs, true)
}
}
}

View file

@ -7,8 +7,9 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import ani.dantotsu.currContext import ani.dantotsu.currContext
import ani.dantotsu.isOnline import ani.dantotsu.isOnline
import ani.dantotsu.loadData
import ani.dantotsu.logger import ani.dantotsu.logger
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes
@ -43,7 +44,7 @@ class AlarmReceiver : BroadcastReceiver() {
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
) )
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val curTime = loadData<Int>("subscriptions_time_s", context) ?: defaultTime val curTime = PrefWrapper.getVal(PrefName.SubscriptionsTimeS, defaultTime)
if (timeMinutes[curTime] > 0) if (timeMinutes[curTime] > 0)
alarmManager.setRepeating( alarmManager.setRepeating(

View file

@ -8,6 +8,8 @@ import androidx.core.app.NotificationManagerCompat
import ani.dantotsu.* import ani.dantotsu.*
import ani.dantotsu.parsers.Episode import ani.dantotsu.parsers.Episode
import ani.dantotsu.parsers.MangaChapter import ani.dantotsu.parsers.MangaChapter
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
@ -41,7 +43,7 @@ class Subscription {
val notificationManager = NotificationManagerCompat.from(context) val notificationManager = NotificationManagerCompat.from(context)
val progressEnabled = val progressEnabled =
loadData("subscription_checking_notifications", context) ?: true PrefWrapper.getVal(PrefName.SubscriptionCheckingNotifications, true)
val progressNotification = if (progressEnabled) getProgressNotification( val progressNotification = if (progressEnabled) getProgressNotification(
context, context,
subscriptions.size subscriptions.size

View file

@ -16,6 +16,8 @@ import ani.dantotsu.parsers.MangaChapter
import ani.dantotsu.parsers.MangaParser import ani.dantotsu.parsers.MangaParser
import ani.dantotsu.parsers.MangaSources import ani.dantotsu.parsers.MangaSources
import ani.dantotsu.saveData import ani.dantotsu.saveData
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.tryWithSuspend import ani.dantotsu.tryWithSuspend
import kotlinx.coroutines.withTimeoutOrNull import kotlinx.coroutines.withTimeoutOrNull
@ -29,7 +31,7 @@ class SubscriptionHelper {
): Selected { ): Selected {
val data = loadData<Selected>("${mediaId}-select", context) ?: Selected().let { val data = loadData<Selected>("${mediaId}-select", context) ?: Selected().let {
it.sourceIndex = 0 it.sourceIndex = 0
it.preferDub = loadData("settings_prefer_dub", context) ?: false it.preferDub = PrefWrapper.getVal(PrefName.SettingsPreferDub, false)
it it
} }
return data return data

View file

@ -9,6 +9,8 @@ import androidx.work.PeriodicWorkRequest
import androidx.work.WorkManager import androidx.work.WorkManager
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import ani.dantotsu.loadData import ani.dantotsu.loadData
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime
import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -29,7 +31,7 @@ class SubscriptionWorker(val context: Context, params: WorkerParameters) :
private const val SUBSCRIPTION_WORK_NAME = "work_subscription" private const val SUBSCRIPTION_WORK_NAME = "work_subscription"
fun enqueue(context: Context) { fun enqueue(context: Context) {
val curTime = loadData<Int>("subscriptions_time_s") ?: defaultTime val curTime = PrefWrapper.getVal(PrefName.SubscriptionsTimeS, defaultTime)
if (timeMinutes[curTime] > 0L) { if (timeMinutes[curTime] > 0L) {
val constraints = val constraints =
Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build() Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()

File diff suppressed because it is too large Load diff

View file

@ -631,9 +631,9 @@
<string name="extension_specific_dns">Extension-specific DNS</string> <string name="extension_specific_dns">Extension-specific DNS</string>
<string name="theme_">Theme:</string> <string name="theme_">Theme:</string>
<string name="user_agent">User Agent</string> <string name="user_agent">User Agent</string>
<string name="custom_theme">Custom Theme</string> <string name="custom_theme">Custom Theme:</string>
<string name="use_custom_theme">Custom theme</string> <string name="use_custom_theme">Custom theme</string>
<string name="use_unique_theme_for_each_item">Color same as Anime/Manga cover</string> <string name="use_unique_theme_for_each_item">Theme as Anime/Manga </string>
<string name="oled_theme_variant">OLED theme variant</string> <string name="oled_theme_variant">OLED theme variant</string>
<string name="installed_anime">Installed Anime</string> <string name="installed_anime">Installed Anime</string>
<string name="available_anime">Available Anime</string> <string name="available_anime">Available Anime</string>

View file

@ -62,17 +62,24 @@
</style> </style>
<style name="MyPopup" parent=""> <style name="MyPopup" parent="">
<item name="android:fontFamily">@font/poppins_bold</item>
<item name="android:textColor">?attr/colorOnBackground</item>
<item name="android:popupBackground">?attr/colorSurface</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:fontFamily">@font/poppins_semi_bold</item>
<item name="android:textColor">?attr/colorOnBackground</item>
<item name="android:windowTitleStyle">@style/HeadingText</item>
<item name="android:popupBackground">?attr/colorSurface</item>
<item name="android:windowBackground">@drawable/shape_corner_16dp</item> <item name="android:windowBackground">@drawable/shape_corner_16dp</item>
<item name="android:windowIsFloating">true</item> <item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
</style> </style>
<style name="HeadingText">
<item name="android:fontFamily">@font/poppins_bold</item>
<item name="android:textColor">?attr/colorPrimary</item>
<item name="android:textSize">58sp</item>
</style>
<style name="BottomNavBar" parent=""> <style name="BottomNavBar" parent="">
<!-- set background color to transparent --> <!-- set background color to transparent -->
<item name="android:background">@android:color/transparent</item> <item name="android:background">@android:color/transparent</item>

View file

@ -44,16 +44,6 @@
<item name="android:navigationBarColor">@color/nav_bg</item> <item name="android:navigationBarColor">@color/nav_bg</item>
</style> </style>
<style name="DialogTheme" parent="Theme.Dantotsu">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@drawable/shape_corner_16dp</item>
</style>
<style name="Theme.Dantotsu.ALLBLACK" parent="Theme.Base"> <style name="Theme.Dantotsu.ALLBLACK" parent="Theme.Base">
<item name="colorPrimary">@color/bg_black</item> <item name="colorPrimary">@color/bg_black</item>
<item name="colorOnPrimary">@color/bg_black</item> <item name="colorOnPrimary">@color/bg_black</item>