reformat
This commit is contained in:
parent
1df528c0dc
commit
afa960c808
171 changed files with 3458 additions and 1915 deletions
|
@ -53,7 +53,8 @@ class AnimeExtensionsFragment : Fragment(),
|
|||
binding.allAnimeExtensionsRecyclerView.isNestedScrollingEnabled = false
|
||||
binding.allAnimeExtensionsRecyclerView.adapter = adapter
|
||||
binding.allAnimeExtensionsRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||
(binding.allAnimeExtensionsRecyclerView.layoutManager as LinearLayoutManager).isItemPrefetchEnabled = true
|
||||
(binding.allAnimeExtensionsRecyclerView.layoutManager as LinearLayoutManager).isItemPrefetchEnabled =
|
||||
true
|
||||
|
||||
lifecycleScope.launch {
|
||||
viewModel.pagerFlow.collectLatest {
|
||||
|
|
|
@ -11,9 +11,11 @@ import ani.dantotsu.setAnimation
|
|||
|
||||
class DevelopersAdapter(private val developers: Array<Developer>) :
|
||||
RecyclerView.Adapter<DevelopersAdapter.DeveloperViewHolder>() {
|
||||
private val uiSettings = loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()
|
||||
private val uiSettings =
|
||||
loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()
|
||||
|
||||
inner class DeveloperViewHolder(val binding: ItemDeveloperBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class DeveloperViewHolder(val binding: ItemDeveloperBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
openLinkInBrowser(developers[bindingAdapterPosition].url)
|
||||
|
@ -22,7 +24,13 @@ class DevelopersAdapter(private val developers: Array<Developer>) :
|
|||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DeveloperViewHolder {
|
||||
return DeveloperViewHolder(ItemDeveloperBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
||||
return DeveloperViewHolder(
|
||||
ItemDeveloperBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: DeveloperViewHolder, position: Int) {
|
||||
|
|
|
@ -13,13 +13,37 @@ class DevelopersDialogFragment : BottomSheetDialogFragment() {
|
|||
private val binding get() = _binding!!
|
||||
|
||||
private val developers = arrayOf(
|
||||
Developer("rebelonion","https://avatars.githubusercontent.com/u/87634197?v=4","Owner and Maintainer","https://github.com/rebelonion"),
|
||||
Developer("Wai What", "https://avatars.githubusercontent.com/u/149729762?v=4", "Icon Designer", "https://github.com/WaiWhat"),
|
||||
Developer("Aayush262", "https://avatars.githubusercontent.com/u/99584765?v=4", "Contributor", "https://github.com/aayush2622"),
|
||||
Developer("MarshMeadow", "https://avatars.githubusercontent.com/u/88599122?v=4", "Beta Icon Designer", "https://github.com/MarshMeadow?tab=repositories"),
|
||||
Developer(
|
||||
"rebelonion",
|
||||
"https://avatars.githubusercontent.com/u/87634197?v=4",
|
||||
"Owner and Maintainer",
|
||||
"https://github.com/rebelonion"
|
||||
),
|
||||
Developer(
|
||||
"Wai What",
|
||||
"https://avatars.githubusercontent.com/u/149729762?v=4",
|
||||
"Icon Designer",
|
||||
"https://github.com/WaiWhat"
|
||||
),
|
||||
Developer(
|
||||
"Aayush262",
|
||||
"https://avatars.githubusercontent.com/u/99584765?v=4",
|
||||
"Contributor",
|
||||
"https://github.com/aayush2622"
|
||||
),
|
||||
Developer(
|
||||
"MarshMeadow",
|
||||
"https://avatars.githubusercontent.com/u/88599122?v=4",
|
||||
"Beta Icon Designer",
|
||||
"https://github.com/MarshMeadow?tab=repositories"
|
||||
),
|
||||
)
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetDevelopersBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
|
|
@ -6,11 +6,8 @@ import android.os.Build.VERSION.*
|
|||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.AutoCompleteTextView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.SearchView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
|
@ -20,16 +17,13 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
|
|||
import androidx.viewpager2.widget.ViewPager2
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.databinding.ActivityExtensionsBinding
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class ExtensionsActivity : AppCompatActivity() {
|
||||
class ExtensionsActivity : AppCompatActivity() {
|
||||
private val restartMainActivity = object : OnBackPressedCallback(false) {
|
||||
override fun handleOnBackPressed() = startMainActivity(this@ExtensionsActivity)
|
||||
}
|
||||
|
@ -104,7 +98,8 @@ class ExtensionsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
val currentFragment = supportFragmentManager.findFragmentByTag("f${viewPager.currentItem}")
|
||||
val currentFragment =
|
||||
supportFragmentManager.findFragmentByTag("f${viewPager.currentItem}")
|
||||
if (currentFragment is SearchQueryHandler) {
|
||||
currentFragment.updateContentBasedOnQuery(s?.toString()?.trim())
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.ActivityFaqBinding
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class FAQActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityFaqBinding
|
||||
|
@ -107,7 +107,7 @@ class FAQActivity : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
LangSet.setLocale(this)
|
||||
ThemeManager(this).applyTheme()
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityFaqBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -12,14 +12,25 @@ import ani.dantotsu.setAnimation
|
|||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
||||
|
||||
class FAQAdapter(private val questions: List<Triple<Int, String, String>>, private val manager: FragmentManager) :
|
||||
class FAQAdapter(
|
||||
private val questions: List<Triple<Int, String, String>>,
|
||||
private val manager: FragmentManager
|
||||
) :
|
||||
RecyclerView.Adapter<FAQAdapter.FAQViewHolder>() {
|
||||
private val uiSettings = loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()
|
||||
private val uiSettings =
|
||||
loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()
|
||||
|
||||
inner class FAQViewHolder(val binding: ItemQuestionBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
inner class FAQViewHolder(val binding: ItemQuestionBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FAQViewHolder {
|
||||
return FAQViewHolder(ItemQuestionBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
||||
return FAQViewHolder(
|
||||
ItemQuestionBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: FAQViewHolder, position: Int) {
|
||||
|
@ -33,7 +44,8 @@ class FAQAdapter(private val questions: List<Triple<Int, String, String>>, priva
|
|||
setTitleText(faq.second)
|
||||
addView(
|
||||
TextView(b.context).apply {
|
||||
val markWon = Markwon.builder(b.context).usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
val markWon = Markwon.builder(b.context)
|
||||
.usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
markWon.setMarkdown(this, faq.third)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -14,10 +14,19 @@ class ForksDialogFragment : BottomSheetDialogFragment() {
|
|||
private val binding get() = _binding!!
|
||||
|
||||
private val developers = arrayOf(
|
||||
Developer("Dantotsu","https://avatars.githubusercontent.com/u/87634197?v=4","rebelonion","https://github.com/rebelonion/Dantotsu"),
|
||||
Developer(
|
||||
"Dantotsu",
|
||||
"https://avatars.githubusercontent.com/u/87634197?v=4",
|
||||
"rebelonion",
|
||||
"https://github.com/rebelonion/Dantotsu"
|
||||
),
|
||||
)
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetDevelopersBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.databinding.FragmentAnimeExtensionsBinding
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.others.LanguageMapper
|
||||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.settings.extensionprefs.AnimeSourcePreferencesFragment
|
||||
import ani.dantotsu.snackString
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
|
@ -47,84 +46,86 @@ class InstalledAnimeExtensionsFragment : Fragment() {
|
|||
private lateinit var extensionsRecyclerView: RecyclerView
|
||||
val skipIcons = loadData("skip_extension_icons") ?: false
|
||||
private val animeExtensionManager: AnimeExtensionManager = Injekt.get()
|
||||
private val extensionsAdapter = AnimeExtensionsAdapter({ pkg ->
|
||||
val allSettings = pkg.sources.filterIsInstance<ConfigurableAnimeSource>()
|
||||
if (allSettings.isNotEmpty()) {
|
||||
var selectedSetting = allSettings[0]
|
||||
if (allSettings.size > 1) {
|
||||
val names = allSettings.map { it.lang }.toTypedArray()
|
||||
var selectedIndex = 0
|
||||
AlertDialog.Builder(requireContext(), R.style.MyPopup)
|
||||
.setTitle("Select a Source")
|
||||
.setSingleChoiceItems(names, selectedIndex) { _, which ->
|
||||
selectedIndex = which
|
||||
}
|
||||
.setPositiveButton("OK") { dialog, _ ->
|
||||
selectedSetting = allSettings[selectedIndex]
|
||||
dialog.dismiss()
|
||||
|
||||
// Move the fragment transaction here
|
||||
val eActivity = requireActivity() as ExtensionsActivity
|
||||
eActivity.runOnUiThread {
|
||||
val fragment =
|
||||
AnimeSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
|
||||
eActivity.findViewById<ViewPager2>(R.id.viewPager).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TabLayout>(R.id.tabLayout).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TextInputLayout>(R.id.searchView).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
|
||||
View.GONE
|
||||
}
|
||||
parentFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.slide_up, R.anim.slide_down)
|
||||
.replace(R.id.fragmentExtensionsContainer, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit()
|
||||
private val extensionsAdapter = AnimeExtensionsAdapter(
|
||||
{ pkg ->
|
||||
val allSettings = pkg.sources.filterIsInstance<ConfigurableAnimeSource>()
|
||||
if (allSettings.isNotEmpty()) {
|
||||
var selectedSetting = allSettings[0]
|
||||
if (allSettings.size > 1) {
|
||||
val names = allSettings.map { it.lang }.toTypedArray()
|
||||
var selectedIndex = 0
|
||||
AlertDialog.Builder(requireContext(), R.style.MyPopup)
|
||||
.setTitle("Select a Source")
|
||||
.setSingleChoiceItems(names, selectedIndex) { _, which ->
|
||||
selectedIndex = which
|
||||
}
|
||||
}
|
||||
.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.cancel()
|
||||
return@setNegativeButton
|
||||
}
|
||||
.show()
|
||||
} else {
|
||||
// If there's only one setting, proceed with the fragment transaction
|
||||
val eActivity = requireActivity() as ExtensionsActivity
|
||||
eActivity.runOnUiThread {
|
||||
val fragment =
|
||||
AnimeSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
.setPositiveButton("OK") { dialog, _ ->
|
||||
selectedSetting = allSettings[selectedIndex]
|
||||
dialog.dismiss()
|
||||
|
||||
eActivity.findViewById<ViewPager2>(R.id.viewPager).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TabLayout>(R.id.tabLayout).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TextInputLayout>(R.id.searchView).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
|
||||
View.GONE
|
||||
// Move the fragment transaction here
|
||||
val eActivity = requireActivity() as ExtensionsActivity
|
||||
eActivity.runOnUiThread {
|
||||
val fragment =
|
||||
AnimeSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
|
||||
eActivity.findViewById<ViewPager2>(R.id.viewPager).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TabLayout>(R.id.tabLayout).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TextInputLayout>(R.id.searchView).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
|
||||
View.GONE
|
||||
}
|
||||
parentFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.slide_up, R.anim.slide_down)
|
||||
.replace(R.id.fragmentExtensionsContainer, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
parentFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.slide_up, R.anim.slide_down)
|
||||
.replace(R.id.fragmentExtensionsContainer, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit()
|
||||
.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.cancel()
|
||||
return@setNegativeButton
|
||||
}
|
||||
.show()
|
||||
} else {
|
||||
// If there's only one setting, proceed with the fragment transaction
|
||||
val eActivity = requireActivity() as ExtensionsActivity
|
||||
eActivity.runOnUiThread {
|
||||
val fragment =
|
||||
AnimeSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
|
||||
eActivity.findViewById<ViewPager2>(R.id.viewPager).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TabLayout>(R.id.tabLayout).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<TextInputLayout>(R.id.searchView).visibility =
|
||||
View.VISIBLE
|
||||
eActivity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
|
||||
View.GONE
|
||||
}
|
||||
parentFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.slide_up, R.anim.slide_down)
|
||||
.replace(R.id.fragmentExtensionsContainer, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hide ViewPager2 and TabLayout
|
||||
val activity = requireActivity() as ExtensionsActivity
|
||||
activity.findViewById<ViewPager2>(R.id.viewPager).visibility = View.GONE
|
||||
activity.findViewById<TabLayout>(R.id.tabLayout).visibility = View.GONE
|
||||
activity.findViewById<TextInputLayout>(R.id.searchView).visibility = View.GONE
|
||||
activity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility = View.VISIBLE
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Source is not configurable", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
},
|
||||
// Hide ViewPager2 and TabLayout
|
||||
val activity = requireActivity() as ExtensionsActivity
|
||||
activity.findViewById<ViewPager2>(R.id.viewPager).visibility = View.GONE
|
||||
activity.findViewById<TabLayout>(R.id.tabLayout).visibility = View.GONE
|
||||
activity.findViewById<TextInputLayout>(R.id.searchView).visibility = View.GONE
|
||||
activity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
|
||||
View.VISIBLE
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Source is not configurable", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
},
|
||||
{ pkg ->
|
||||
if (isAdded) { // Check if the fragment is currently added to its activity
|
||||
val context = requireContext() // Store context in a variable
|
||||
|
@ -228,7 +229,7 @@ class InstalledAnimeExtensionsFragment : Fragment() {
|
|||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val extension = getItem(position) // Use getItem() from ListAdapter
|
||||
val nsfw = if (extension.isNsfw) "(18+)" else ""
|
||||
val lang= LanguageMapper.mapLanguageCodeToName(extension.lang)
|
||||
val lang = LanguageMapper.mapLanguageCodeToName(extension.lang)
|
||||
holder.extensionNameTextView.text = extension.name
|
||||
holder.extensionVersionTextView.text = "$lang ${extension.versionName} $nsfw"
|
||||
if (!skipIcons) {
|
||||
|
@ -249,10 +250,11 @@ class InstalledAnimeExtensionsFragment : Fragment() {
|
|||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val extensionNameTextView: TextView = view.findViewById(R.id.extensionNameTextView)
|
||||
val extensionVersionTextView: TextView = view.findViewById(R.id.extensionVersionTextView)
|
||||
val extensionVersionTextView: TextView =
|
||||
view.findViewById(R.id.extensionVersionTextView)
|
||||
val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView)
|
||||
val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView)
|
||||
val closeTextView: ImageView = view.findViewById(R.id.closeTextView)
|
||||
val closeTextView: ImageView = view.findViewById(R.id.closeTextView)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -24,8 +24,8 @@ import androidx.viewpager2.widget.ViewPager2
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.FragmentMangaExtensionsBinding
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.settings.extensionprefs.MangaSourcePreferencesFragment
|
||||
import ani.dantotsu.others.LanguageMapper
|
||||
import ani.dantotsu.settings.extensionprefs.MangaSourcePreferencesFragment
|
||||
import ani.dantotsu.snackString
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
|
@ -71,9 +71,10 @@ class InstalledMangaExtensionsFragment : Fragment() {
|
|||
dialog.dismiss()
|
||||
|
||||
// Move the fragment transaction here
|
||||
val fragment = MangaSourcePreferencesFragment().getInstance(selectedSetting.id){
|
||||
changeUIVisibility(true)
|
||||
}
|
||||
val fragment =
|
||||
MangaSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
changeUIVisibility(true)
|
||||
}
|
||||
parentFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.slide_up, R.anim.slide_down)
|
||||
.replace(R.id.fragmentExtensionsContainer, fragment)
|
||||
|
@ -88,7 +89,7 @@ class InstalledMangaExtensionsFragment : Fragment() {
|
|||
.show()
|
||||
} else {
|
||||
// If there's only one setting, proceed with the fragment transaction
|
||||
val fragment = MangaSourcePreferencesFragment().getInstance(selectedSetting.id){
|
||||
val fragment = MangaSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
changeUIVisibility(true)
|
||||
}
|
||||
parentFragmentManager.beginTransaction()
|
||||
|
@ -106,59 +107,60 @@ class InstalledMangaExtensionsFragment : Fragment() {
|
|||
}
|
||||
},
|
||||
{ pkg ->
|
||||
if (isAdded) { // Check if the fragment is currently added to its activity
|
||||
val context = requireContext() // Store context in a variable
|
||||
val notificationManager =
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once
|
||||
if (isAdded) { // Check if the fragment is currently added to its activity
|
||||
val context = requireContext() // Store context in a variable
|
||||
val notificationManager =
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once
|
||||
|
||||
if (pkg.hasUpdate) {
|
||||
mangaExtensionManager.updateExtension(pkg)
|
||||
.observeOn(AndroidSchedulers.mainThread()) // Observe on main thread
|
||||
.subscribe(
|
||||
{ installStep ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_sync_24)
|
||||
.setContentTitle("Updating extension")
|
||||
.setContentText("Step: $installStep")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
FirebaseCrashlytics.getInstance().recordException(error)
|
||||
Log.e("MangaExtensionsAdapter", "Error: ", error) // Log the error
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_ERROR
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_info_24)
|
||||
.setContentTitle("Update failed: ${error.message}")
|
||||
.setContentText("Error: ${error.message}")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
notificationManager.notify(1, builder.build())
|
||||
snackString("Update failed: ${error.message}")
|
||||
},
|
||||
{
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(androidx.media3.ui.R.drawable.exo_ic_check)
|
||||
.setContentTitle("Update complete")
|
||||
.setContentText("The extension has been successfully updated.")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
snackString("Extension updated")
|
||||
}
|
||||
)
|
||||
} else {
|
||||
mangaExtensionManager.uninstallExtension(pkg.pkgName)
|
||||
snackString("Extension uninstalled")
|
||||
if (pkg.hasUpdate) {
|
||||
mangaExtensionManager.updateExtension(pkg)
|
||||
.observeOn(AndroidSchedulers.mainThread()) // Observe on main thread
|
||||
.subscribe(
|
||||
{ installStep ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_sync_24)
|
||||
.setContentTitle("Updating extension")
|
||||
.setContentText("Step: $installStep")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
FirebaseCrashlytics.getInstance().recordException(error)
|
||||
Log.e("MangaExtensionsAdapter", "Error: ", error) // Log the error
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_ERROR
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_info_24)
|
||||
.setContentTitle("Update failed: ${error.message}")
|
||||
.setContentText("Error: ${error.message}")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
notificationManager.notify(1, builder.build())
|
||||
snackString("Update failed: ${error.message}")
|
||||
},
|
||||
{
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(androidx.media3.ui.R.drawable.exo_ic_check)
|
||||
.setContentTitle("Update complete")
|
||||
.setContentText("The extension has been successfully updated.")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
snackString("Extension updated")
|
||||
}
|
||||
)
|
||||
} else {
|
||||
mangaExtensionManager.uninstallExtension(pkg.pkgName)
|
||||
snackString("Extension uninstalled")
|
||||
}
|
||||
}
|
||||
}
|
||||
}, skipIcons)
|
||||
}, skipIcons
|
||||
)
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -230,7 +232,8 @@ class InstalledMangaExtensionsFragment : Fragment() {
|
|||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val extensionNameTextView: TextView = view.findViewById(R.id.extensionNameTextView)
|
||||
val extensionVersionTextView: TextView = view.findViewById(R.id.extensionVersionTextView)
|
||||
val extensionVersionTextView: TextView =
|
||||
view.findViewById(R.id.extensionVersionTextView)
|
||||
val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView)
|
||||
val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView)
|
||||
val closeTextView: ImageView = view.findViewById(R.id.closeTextView)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ani.dantotsu.settings
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
|
@ -8,7 +7,6 @@ import android.util.Log
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
|
@ -19,23 +17,17 @@ import androidx.recyclerview.widget.DiffUtil
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.FragmentMangaExtensionsBinding
|
||||
import ani.dantotsu.databinding.FragmentNovelExtensionsBinding
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.others.LanguageMapper
|
||||
import ani.dantotsu.parsers.novel.NovelExtension
|
||||
import ani.dantotsu.parsers.novel.NovelExtensionManager
|
||||
import ani.dantotsu.snackString
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -47,8 +39,8 @@ class InstalledNovelExtensionsFragment : Fragment() {
|
|||
val skipIcons = loadData("skip_extension_icons") ?: false
|
||||
private val novelExtensionManager: NovelExtensionManager = Injekt.get()
|
||||
private val extensionsAdapter = NovelExtensionsAdapter({ pkg ->
|
||||
Toast.makeText(requireContext(), "Source is not configurable", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
Toast.makeText(requireContext(), "Source is not configurable", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
},
|
||||
{ pkg ->
|
||||
if (isAdded) { // Check if the fragment is currently added to its activity
|
||||
|
@ -99,11 +91,12 @@ class InstalledNovelExtensionsFragment : Fragment() {
|
|||
}
|
||||
)
|
||||
} else {
|
||||
novelExtensionManager.uninstallExtension(pkg.pkgName, currContext()?:context)
|
||||
novelExtensionManager.uninstallExtension(pkg.pkgName, currContext() ?: context)
|
||||
snackString("Extension uninstalled")
|
||||
}
|
||||
}
|
||||
}, skipIcons)
|
||||
}, skipIcons
|
||||
)
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -126,10 +119,6 @@ class InstalledNovelExtensionsFragment : Fragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView();_binding = null
|
||||
}
|
||||
|
@ -159,7 +148,7 @@ class InstalledNovelExtensionsFragment : Fragment() {
|
|||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val extension = getItem(position) // Use getItem() from ListAdapter
|
||||
val nsfw = ""
|
||||
val nsfw = ""
|
||||
val lang = LanguageMapper.mapLanguageCodeToName("all")
|
||||
holder.extensionNameTextView.text = extension.name
|
||||
holder.extensionVersionTextView.text = "$lang ${extension.versionName} $nsfw"
|
||||
|
@ -181,7 +170,8 @@ class InstalledNovelExtensionsFragment : Fragment() {
|
|||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val extensionNameTextView: TextView = view.findViewById(R.id.extensionNameTextView)
|
||||
val extensionVersionTextView: TextView = view.findViewById(R.id.extensionVersionTextView)
|
||||
val extensionVersionTextView: TextView =
|
||||
view.findViewById(R.id.extensionVersionTextView)
|
||||
val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView)
|
||||
val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView)
|
||||
val closeTextView: ImageView = view.findViewById(R.id.closeTextView)
|
||||
|
|
|
@ -10,25 +10,23 @@ import androidx.core.app.NotificationCompat
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.paging.PagingData
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.FragmentMangaExtensionsBinding
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.manga.model.MangaExtension
|
||||
import kotlinx.coroutines.launch
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import ani.dantotsu.settings.paging.MangaExtensionAdapter
|
||||
import ani.dantotsu.settings.paging.MangaExtensionsViewModel
|
||||
import ani.dantotsu.settings.paging.MangaExtensionsViewModelFactory
|
||||
import ani.dantotsu.settings.paging.OnMangaInstallClickListener
|
||||
import ani.dantotsu.snackString
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.manga.model.MangaExtension
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class MangaExtensionsFragment : Fragment(),
|
||||
SearchQueryHandler, OnMangaInstallClickListener {
|
||||
|
@ -56,7 +54,8 @@ class MangaExtensionsFragment : Fragment(),
|
|||
binding.allMangaExtensionsRecyclerView.isNestedScrollingEnabled = false
|
||||
binding.allMangaExtensionsRecyclerView.adapter = adapter
|
||||
binding.allMangaExtensionsRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||
(binding.allMangaExtensionsRecyclerView.layoutManager as LinearLayoutManager).isItemPrefetchEnabled = true
|
||||
(binding.allMangaExtensionsRecyclerView.layoutManager as LinearLayoutManager).isItemPrefetchEnabled =
|
||||
true
|
||||
|
||||
lifecycleScope.launch {
|
||||
viewModel.pagerFlow.collectLatest { pagingData ->
|
||||
|
@ -129,5 +128,4 @@ class MangaExtensionsFragment : Fragment(),
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -13,8 +13,6 @@ import androidx.lifecycle.lifecycleScope
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.FragmentNovelExtensionsBinding
|
||||
import ani.dantotsu.logger
|
||||
import ani.dantotsu.parsers.novel.FileObserver.fileObserver
|
||||
import ani.dantotsu.parsers.novel.NovelExtension
|
||||
import ani.dantotsu.parsers.novel.NovelExtensionManager
|
||||
import ani.dantotsu.settings.paging.NovelExtensionAdapter
|
||||
|
@ -24,11 +22,7 @@ import ani.dantotsu.settings.paging.OnNovelInstallClickListener
|
|||
import ani.dantotsu.snackString
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.observeOn
|
||||
import kotlinx.coroutines.flow.subscribe
|
||||
import kotlinx.coroutines.launch
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
@ -59,7 +53,8 @@ class NovelExtensionsFragment : Fragment(),
|
|||
binding.allNovelExtensionsRecyclerView.isNestedScrollingEnabled = false
|
||||
binding.allNovelExtensionsRecyclerView.adapter = adapter
|
||||
binding.allNovelExtensionsRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||
(binding.allNovelExtensionsRecyclerView.layoutManager as LinearLayoutManager).isItemPrefetchEnabled = true
|
||||
(binding.allNovelExtensionsRecyclerView.layoutManager as LinearLayoutManager).isItemPrefetchEnabled =
|
||||
true
|
||||
|
||||
lifecycleScope.launch {
|
||||
viewModel.pagerFlow.collectLatest { pagingData ->
|
||||
|
@ -132,5 +127,4 @@ class NovelExtensionsFragment : Fragment(),
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -11,13 +11,20 @@ import androidx.activity.addCallback
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.ActivityPlayerSettingsBinding
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.parsers.Subtitle
|
||||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.toast
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
@ -26,14 +33,14 @@ class PlayerSettingsActivity : AppCompatActivity() {
|
|||
lateinit var binding: ActivityPlayerSettingsBinding
|
||||
private val player = "player_settings"
|
||||
|
||||
var media:Media?=null
|
||||
var subtitle:Subtitle?=null
|
||||
var media: Media? = null
|
||||
var subtitle: Subtitle? = null
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
LangSet.setLocale(this)
|
||||
ThemeManager(this).applyTheme()
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityPlayerSettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
@ -55,7 +62,12 @@ ThemeManager(this).applyTheme()
|
|||
bottomMargin = navBarHeight
|
||||
}
|
||||
|
||||
val settings = loadData<PlayerSettings>(player, toast = false) ?: PlayerSettings().apply { saveData(player, this) }
|
||||
val settings = loadData<PlayerSettings>(player, toast = false) ?: PlayerSettings().apply {
|
||||
saveData(
|
||||
player,
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
binding.playerSettingsBack.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
|
@ -68,28 +80,36 @@ ThemeManager(this).applyTheme()
|
|||
saveData(player, settings)
|
||||
}
|
||||
|
||||
binding.playerSettingsQualityHeight.setText((loadData<Int>("maxHeight", toast = false) ?: 480).toString())
|
||||
binding.playerSettingsQualityHeight.setText(
|
||||
(loadData<Int>("maxHeight", toast = false) ?: 480).toString()
|
||||
)
|
||||
binding.playerSettingsQualityHeight.addTextChangedListener {
|
||||
val height = binding.playerSettingsQualityHeight.text.toString().toIntOrNull()
|
||||
saveData("maxHeight", height)
|
||||
}
|
||||
binding.playerSettingsQualityWidth.setText((loadData<Int>("maxWidth", toast = false) ?: 720).toString())
|
||||
binding.playerSettingsQualityWidth.setText(
|
||||
(loadData<Int>("maxWidth", toast = false) ?: 720).toString()
|
||||
)
|
||||
binding.playerSettingsQualityWidth.addTextChangedListener {
|
||||
val height = binding.playerSettingsQualityWidth.text.toString().toIntOrNull()
|
||||
saveData("maxWidth", height)
|
||||
}
|
||||
|
||||
|
||||
val speeds = arrayOf(0.25f, 0.33f, 0.5f, 0.66f, 0.75f, 1f, 1.25f, 1.33f, 1.5f, 1.66f, 1.75f, 2f)
|
||||
val speeds =
|
||||
arrayOf(0.25f, 0.33f, 0.5f, 0.66f, 0.75f, 1f, 1.25f, 1.33f, 1.5f, 1.66f, 1.75f, 2f)
|
||||
val cursedSpeeds = arrayOf(1f, 1.25f, 1.5f, 1.75f, 2f, 2.5f, 3f, 4f, 5f, 10f, 25f, 50f)
|
||||
var curSpeedArr = if (settings.cursedSpeeds) cursedSpeeds else speeds
|
||||
var speedsName = curSpeedArr.map { "${it}x" }.toTypedArray()
|
||||
binding.playerSettingsSpeed.text = getString(R.string.default_playback_speed, speedsName[settings.defaultSpeed])
|
||||
val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.default_speed))
|
||||
binding.playerSettingsSpeed.text =
|
||||
getString(R.string.default_playback_speed, speedsName[settings.defaultSpeed])
|
||||
val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.default_speed))
|
||||
binding.playerSettingsSpeed.setOnClickListener {
|
||||
speedDialog.setSingleChoiceItems(speedsName, settings.defaultSpeed) { dialog, i ->
|
||||
settings.defaultSpeed = i
|
||||
binding.playerSettingsSpeed.text = getString(R.string.default_playback_speed, speedsName[i])
|
||||
binding.playerSettingsSpeed.text =
|
||||
getString(R.string.default_playback_speed, speedsName[i])
|
||||
saveData(player, settings)
|
||||
dialog.dismiss()
|
||||
}.show()
|
||||
|
@ -101,7 +121,8 @@ ThemeManager(this).applyTheme()
|
|||
curSpeedArr = if (settings.cursedSpeeds) cursedSpeeds else speeds
|
||||
settings.defaultSpeed = if (settings.cursedSpeeds) 0 else 5
|
||||
speedsName = curSpeedArr.map { "${it}x" }.toTypedArray()
|
||||
binding.playerSettingsSpeed.text = getString(R.string.default_playback_speed, speedsName[settings.defaultSpeed])
|
||||
binding.playerSettingsSpeed.text =
|
||||
getString(R.string.default_playback_speed, speedsName[settings.defaultSpeed])
|
||||
saveData(player, settings)
|
||||
}
|
||||
|
||||
|
@ -155,7 +176,8 @@ ThemeManager(this).applyTheme()
|
|||
if (isChecked) snackString(getString(R.string.very_bold))
|
||||
saveData(player, settings)
|
||||
}
|
||||
binding.playerSettingsCompletePercentage.value = (settings.watchPercentage * 100).roundToInt().toFloat()
|
||||
binding.playerSettingsCompletePercentage.value =
|
||||
(settings.watchPercentage * 100).roundToInt().toFloat()
|
||||
binding.playerSettingsCompletePercentage.addOnChangeListener { _, value, _ ->
|
||||
settings.watchPercentage = value / 100
|
||||
saveData(player, settings)
|
||||
|
@ -230,7 +252,8 @@ ThemeManager(this).applyTheme()
|
|||
}
|
||||
|
||||
val resizeModes = arrayOf("Original", "Zoom", "Stretch")
|
||||
val resizeDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.default_resize_mode))
|
||||
val resizeDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.default_resize_mode))
|
||||
binding.playerResizeMode.setOnClickListener {
|
||||
resizeDialog.setSingleChoiceItems(resizeModes, settings.resize) { dialog, count ->
|
||||
settings.resize = count
|
||||
|
@ -244,7 +267,11 @@ ThemeManager(this).applyTheme()
|
|||
R.string.restart_app, Snackbar.LENGTH_SHORT
|
||||
).apply {
|
||||
val mainIntent =
|
||||
Intent.makeRestartActivityTask(context.packageManager.getLaunchIntentForPackage(context.packageName)!!.component)
|
||||
Intent.makeRestartActivityTask(
|
||||
context.packageManager.getLaunchIntentForPackage(
|
||||
context.packageName
|
||||
)!!.component
|
||||
)
|
||||
setAction("Do it!") {
|
||||
context.startActivity(mainIntent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
|
@ -256,7 +283,7 @@ ThemeManager(this).applyTheme()
|
|||
fun toggleButton(button: android.widget.Button, toggle: Boolean) {
|
||||
button.isClickable = toggle
|
||||
button.alpha = when (toggle) {
|
||||
true -> 1f
|
||||
true -> 1f
|
||||
false -> 0.5f
|
||||
}
|
||||
}
|
||||
|
@ -269,21 +296,24 @@ ThemeManager(this).applyTheme()
|
|||
binding.subtitleFontSizeCard.isEnabled = isChecked
|
||||
binding.subtitleFontSizeCard.isClickable = isChecked
|
||||
binding.subtitleFontSizeCard.alpha = when (isChecked) {
|
||||
true -> 1f
|
||||
true -> 1f
|
||||
false -> 0.5f
|
||||
}
|
||||
binding.subtitleFontSize.isEnabled = isChecked
|
||||
binding.subtitleFontSize.isClickable = isChecked
|
||||
binding.subtitleFontSize.alpha = when (isChecked) {
|
||||
true -> 1f
|
||||
false -> 0.5f
|
||||
}
|
||||
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.isEnabled = isChecked
|
||||
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.isClickable = isChecked
|
||||
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.alpha = when (isChecked) {
|
||||
true -> 1f
|
||||
true -> 1f
|
||||
false -> 0.5f
|
||||
}
|
||||
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.isEnabled =
|
||||
isChecked
|
||||
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.isClickable =
|
||||
isChecked
|
||||
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.alpha =
|
||||
when (isChecked) {
|
||||
true -> 1f
|
||||
false -> 0.5f
|
||||
}
|
||||
}
|
||||
binding.subSwitch.isChecked = settings.subtitles
|
||||
binding.subSwitch.setOnCheckedChangeListener { _, isChecked ->
|
||||
|
@ -293,10 +323,26 @@ ThemeManager(this).applyTheme()
|
|||
restartApp()
|
||||
}
|
||||
val colorsPrimary =
|
||||
arrayOf("Black", "Dark Gray", "Gray", "Light Gray", "White", "Red", "Yellow", "Green", "Cyan", "Blue", "Magenta")
|
||||
val primaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.primary_sub_color))
|
||||
arrayOf(
|
||||
"Black",
|
||||
"Dark Gray",
|
||||
"Gray",
|
||||
"Light Gray",
|
||||
"White",
|
||||
"Red",
|
||||
"Yellow",
|
||||
"Green",
|
||||
"Cyan",
|
||||
"Blue",
|
||||
"Magenta"
|
||||
)
|
||||
val primaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.primary_sub_color))
|
||||
binding.videoSubColorPrimary.setOnClickListener {
|
||||
primaryColorDialog.setSingleChoiceItems(colorsPrimary, settings.primaryColor) { dialog, count ->
|
||||
primaryColorDialog.setSingleChoiceItems(
|
||||
colorsPrimary,
|
||||
settings.primaryColor
|
||||
) { dialog, count ->
|
||||
settings.primaryColor = count
|
||||
saveData(player, settings)
|
||||
dialog.dismiss()
|
||||
|
@ -316,16 +362,21 @@ ThemeManager(this).applyTheme()
|
|||
"Magenta",
|
||||
"Transparent"
|
||||
)
|
||||
val secondaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.outline_sub_color))
|
||||
val secondaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.outline_sub_color))
|
||||
binding.videoSubColorSecondary.setOnClickListener {
|
||||
secondaryColorDialog.setSingleChoiceItems(colorsSecondary, settings.secondaryColor) { dialog, count ->
|
||||
secondaryColorDialog.setSingleChoiceItems(
|
||||
colorsSecondary,
|
||||
settings.secondaryColor
|
||||
) { dialog, count ->
|
||||
settings.secondaryColor = count
|
||||
saveData(player, settings)
|
||||
dialog.dismiss()
|
||||
}.show()
|
||||
}
|
||||
val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None")
|
||||
val outlineDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.outline_type))
|
||||
val outlineDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.outline_type))
|
||||
binding.videoSubOutline.setOnClickListener {
|
||||
outlineDialog.setSingleChoiceItems(typesOutline, settings.outline) { dialog, count ->
|
||||
settings.outline = count
|
||||
|
@ -347,9 +398,13 @@ ThemeManager(this).applyTheme()
|
|||
"Blue",
|
||||
"Magenta"
|
||||
)
|
||||
val subBackgroundDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.outline_sub_color))
|
||||
val subBackgroundDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.outline_sub_color))
|
||||
binding.videoSubColorBackground.setOnClickListener {
|
||||
subBackgroundDialog.setSingleChoiceItems(colorsSubBackground, settings.subBackground) { dialog, count ->
|
||||
subBackgroundDialog.setSingleChoiceItems(
|
||||
colorsSubBackground,
|
||||
settings.subBackground
|
||||
) { dialog, count ->
|
||||
settings.subBackground = count
|
||||
saveData(player, settings)
|
||||
dialog.dismiss()
|
||||
|
@ -370,16 +425,28 @@ ThemeManager(this).applyTheme()
|
|||
"Blue",
|
||||
"Magenta"
|
||||
)
|
||||
val subWindowDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.outline_sub_color))
|
||||
val subWindowDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.outline_sub_color))
|
||||
binding.videoSubColorWindow.setOnClickListener {
|
||||
subWindowDialog.setSingleChoiceItems(colorsSubWindow, settings.subWindow) { dialog, count ->
|
||||
subWindowDialog.setSingleChoiceItems(
|
||||
colorsSubWindow,
|
||||
settings.subWindow
|
||||
) { dialog, count ->
|
||||
settings.subWindow = count
|
||||
saveData(player, settings)
|
||||
dialog.dismiss()
|
||||
}.show()
|
||||
}
|
||||
val fonts = arrayOf("Poppins Semi Bold", "Poppins Bold", "Poppins", "Poppins Thin","Century Gothic","Century Gothic Bold")
|
||||
val fontDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.subtitle_font))
|
||||
val fonts = arrayOf(
|
||||
"Poppins Semi Bold",
|
||||
"Poppins Bold",
|
||||
"Poppins",
|
||||
"Poppins Thin",
|
||||
"Century Gothic",
|
||||
"Century Gothic Bold"
|
||||
)
|
||||
val fontDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.subtitle_font))
|
||||
binding.videoSubFont.setOnClickListener {
|
||||
fontDialog.setSingleChoiceItems(fonts, settings.font) { dialog, count ->
|
||||
settings.font = count
|
||||
|
|
|
@ -9,11 +9,11 @@ import ani.dantotsu.databinding.ActivityReaderSettingsBinding
|
|||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
|
||||
class ReaderSettingsActivity : AppCompatActivity() {
|
||||
lateinit var binding: ActivityReaderSettingsBinding
|
||||
|
@ -21,7 +21,7 @@ class ReaderSettingsActivity : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
LangSet.setLocale(this)
|
||||
ThemeManager(this).applyTheme()
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityReaderSettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
@ -31,7 +31,12 @@ ThemeManager(this).applyTheme()
|
|||
bottomMargin = navBarHeight
|
||||
}
|
||||
|
||||
val settings = loadData<ReaderSettings>(reader, toast = false) ?: ReaderSettings().apply { saveData(reader, this) }
|
||||
val settings = loadData<ReaderSettings>(reader, toast = false) ?: ReaderSettings().apply {
|
||||
saveData(
|
||||
reader,
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
binding.readerSettingsBack.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
|
@ -43,13 +48,13 @@ ThemeManager(this).applyTheme()
|
|||
settings.showSource = isChecked
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
||||
|
||||
binding.readerSettingsSystemBars.isChecked = settings.showSystemBars
|
||||
binding.readerSettingsSystemBars.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.showSystemBars = isChecked
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
||||
|
||||
binding.readerSettingsAutoWebToon.isChecked = settings.autoDetectWebtoon
|
||||
binding.readerSettingsAutoWebToon.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.autoDetectWebtoon = isChecked
|
||||
|
@ -63,7 +68,8 @@ ThemeManager(this).applyTheme()
|
|||
binding.readerSettingsContinuous
|
||||
)
|
||||
|
||||
binding.readerSettingsLayoutText.text = resources.getStringArray(R.array.manga_layouts)[settings.default.layout.ordinal]
|
||||
binding.readerSettingsLayoutText.text =
|
||||
resources.getStringArray(R.array.manga_layouts)[settings.default.layout.ordinal]
|
||||
var selectedLayout = layoutList[settings.default.layout.ordinal]
|
||||
selectedLayout.alpha = 1f
|
||||
|
||||
|
@ -72,17 +78,23 @@ ThemeManager(this).applyTheme()
|
|||
selectedLayout.alpha = 0.33f
|
||||
selectedLayout = imageButton
|
||||
selectedLayout.alpha = 1f
|
||||
settings.default.layout = CurrentReaderSettings.Layouts[index]?:CurrentReaderSettings.Layouts.CONTINUOUS
|
||||
binding.readerSettingsLayoutText.text = resources.getStringArray(R.array.manga_layouts)[settings.default.layout.ordinal]
|
||||
settings.default.layout =
|
||||
CurrentReaderSettings.Layouts[index] ?: CurrentReaderSettings.Layouts.CONTINUOUS
|
||||
binding.readerSettingsLayoutText.text =
|
||||
resources.getStringArray(R.array.manga_layouts)[settings.default.layout.ordinal]
|
||||
saveData(reader, settings)
|
||||
}
|
||||
}
|
||||
|
||||
binding.readerSettingsDirectionText.text = resources.getStringArray(R.array.manga_directions)[settings.default.direction.ordinal]
|
||||
binding.readerSettingsDirectionText.text =
|
||||
resources.getStringArray(R.array.manga_directions)[settings.default.direction.ordinal]
|
||||
binding.readerSettingsDirection.rotation = 90f * (settings.default.direction.ordinal)
|
||||
binding.readerSettingsDirection.setOnClickListener {
|
||||
settings.default.direction = CurrentReaderSettings.Directions[settings.default.direction.ordinal + 1] ?: CurrentReaderSettings.Directions.TOP_TO_BOTTOM
|
||||
binding.readerSettingsDirectionText.text = resources.getStringArray(R.array.manga_directions)[settings.default.direction.ordinal]
|
||||
settings.default.direction =
|
||||
CurrentReaderSettings.Directions[settings.default.direction.ordinal + 1]
|
||||
?: CurrentReaderSettings.Directions.TOP_TO_BOTTOM
|
||||
binding.readerSettingsDirectionText.text =
|
||||
resources.getStringArray(R.array.manga_directions)[settings.default.direction.ordinal]
|
||||
binding.readerSettingsDirection.rotation = 90f * (settings.default.direction.ordinal)
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
@ -102,7 +114,8 @@ ThemeManager(this).applyTheme()
|
|||
selectedDual.alpha = 0.33f
|
||||
selectedDual = imageButton
|
||||
selectedDual.alpha = 1f
|
||||
settings.default.dualPageMode = CurrentReaderSettings.DualPageModes[index] ?: CurrentReaderSettings.DualPageModes.Automatic
|
||||
settings.default.dualPageMode = CurrentReaderSettings.DualPageModes[index]
|
||||
?: CurrentReaderSettings.DualPageModes.Automatic
|
||||
binding.readerSettingsDualPageText.text = settings.default.dualPageMode.toString()
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
@ -149,29 +162,29 @@ ThemeManager(this).applyTheme()
|
|||
}
|
||||
|
||||
binding.readerSettingsOverscroll.isChecked = settings.default.overScrollMode
|
||||
binding.readerSettingsOverscroll.setOnCheckedChangeListener { _,isChecked ->
|
||||
binding.readerSettingsOverscroll.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.default.overScrollMode = isChecked
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
||||
binding.readerSettingsVolumeButton.isChecked = settings.default.volumeButtons
|
||||
binding.readerSettingsVolumeButton.setOnCheckedChangeListener { _,isChecked ->
|
||||
binding.readerSettingsVolumeButton.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.default.volumeButtons = isChecked
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
||||
binding.readerSettingsWrapImages.isChecked = settings.default.wrapImages
|
||||
binding.readerSettingsWrapImages.setOnCheckedChangeListener { _,isChecked ->
|
||||
binding.readerSettingsWrapImages.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.default.wrapImages = isChecked
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
||||
binding.readerSettingsLongClickImage.isChecked = settings.default.longClickImage
|
||||
binding.readerSettingsLongClickImage.setOnCheckedChangeListener { _,isChecked ->
|
||||
binding.readerSettingsLongClickImage.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.default.longClickImage = isChecked
|
||||
saveData(reader, settings)
|
||||
}
|
||||
|
||||
|
||||
//Update Progress
|
||||
binding.readerSettingsAskUpdateProgress.isChecked = settings.askIndividual
|
||||
binding.readerSettingsAskUpdateProgress.setOnCheckedChangeListener { _, isChecked ->
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.AlertDialog
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.os.Build
|
||||
import android.os.Build.*
|
||||
import android.os.Build.VERSION.*
|
||||
import android.os.Bundle
|
||||
|
@ -27,6 +26,7 @@ import ani.dantotsu.connections.mal.MAL
|
|||
import ani.dantotsu.databinding.ActivitySettingsBinding
|
||||
import ani.dantotsu.others.AppUpdater
|
||||
import ani.dantotsu.others.CustomBottomDialog
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
import ani.dantotsu.parsers.MangaSources
|
||||
import ani.dantotsu.subcriptions.Notifications
|
||||
|
@ -35,7 +35,6 @@ import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime
|
|||
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
|
||||
import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.skydoves.colorpickerview.listeners.ColorListener
|
||||
|
@ -75,13 +74,14 @@ class SettingsActivity : AppCompatActivity() {
|
|||
fun getArch(): String {
|
||||
SUPPORTED_ABIS.forEach {
|
||||
when (it) {
|
||||
"arm64-v8a" -> return "aarch64"
|
||||
"arm64-v8a" -> return "aarch64"
|
||||
"armeabi-v7a" -> return "arm"
|
||||
"x86_64" -> return "x86_64"
|
||||
"x86" -> return "i686"
|
||||
"x86_64" -> return "x86_64"
|
||||
"x86" -> return "i686"
|
||||
}
|
||||
}
|
||||
return System.getProperty("os.arch") ?: System.getProperty("os.product.cpu.abi") ?: "Unknown Architecture"
|
||||
return System.getProperty("os.arch") ?: System.getProperty("os.product.cpu.abi")
|
||||
?: "Unknown Architecture"
|
||||
}
|
||||
|
||||
val info = """
|
||||
|
@ -106,41 +106,68 @@ class SettingsActivity : AppCompatActivity() {
|
|||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
binding.settingsUseMaterialYou.isChecked = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_material_you", false)
|
||||
binding.settingsUseMaterialYou.isChecked =
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean(
|
||||
"use_material_you",
|
||||
false
|
||||
)
|
||||
binding.settingsUseMaterialYou.setOnCheckedChangeListener { _, isChecked ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putBoolean("use_material_you", isChecked).apply()
|
||||
if(isChecked) binding.settingsUseCustomTheme.isChecked = false
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putBoolean("use_material_you", isChecked).apply()
|
||||
if (isChecked) binding.settingsUseCustomTheme.isChecked = false
|
||||
restartApp()
|
||||
}
|
||||
|
||||
binding.settingsUseCustomTheme.isChecked = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_custom_theme", false)
|
||||
binding.settingsUseCustomTheme.isChecked =
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean(
|
||||
"use_custom_theme",
|
||||
false
|
||||
)
|
||||
binding.settingsUseCustomTheme.setOnCheckedChangeListener { _, isChecked ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putBoolean("use_custom_theme", isChecked).apply()
|
||||
if(isChecked) {
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putBoolean("use_custom_theme", isChecked).apply()
|
||||
if (isChecked) {
|
||||
binding.settingsUseMaterialYou.isChecked = false
|
||||
}
|
||||
|
||||
restartApp()
|
||||
}
|
||||
|
||||
binding.settingsUseSourceTheme.isChecked = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_source_theme", false)
|
||||
binding.settingsUseSourceTheme.isChecked =
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean(
|
||||
"use_source_theme",
|
||||
false
|
||||
)
|
||||
binding.settingsUseSourceTheme.setOnCheckedChangeListener { _, isChecked ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putBoolean("use_source_theme", isChecked).apply()
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putBoolean("use_source_theme", isChecked).apply()
|
||||
}
|
||||
|
||||
binding.settingsUseOLED.isChecked = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_oled", false)
|
||||
binding.settingsUseOLED.isChecked =
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_oled", false)
|
||||
binding.settingsUseOLED.setOnCheckedChangeListener { _, isChecked ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putBoolean("use_oled", isChecked).apply()
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putBoolean("use_oled", isChecked).apply()
|
||||
restartApp()
|
||||
}
|
||||
|
||||
val themeString = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getString("theme", "PURPLE")!!
|
||||
binding.themeSwitcher.setText(themeString.substring(0, 1) + themeString.substring(1).lowercase())
|
||||
val themeString =
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getString("theme", "PURPLE")!!
|
||||
binding.themeSwitcher.setText(
|
||||
themeString.substring(0, 1) + themeString.substring(1).lowercase()
|
||||
)
|
||||
|
||||
binding.themeSwitcher.setAdapter(ArrayAdapter(this, R.layout.item_dropdown, ThemeManager.Companion.Theme.values().map { it.theme.substring(0, 1) + it.theme.substring(1).lowercase() }))
|
||||
binding.themeSwitcher.setAdapter(
|
||||
ArrayAdapter(
|
||||
this,
|
||||
R.layout.item_dropdown,
|
||||
ThemeManager.Companion.Theme.values()
|
||||
.map { it.theme.substring(0, 1) + it.theme.substring(1).lowercase() })
|
||||
)
|
||||
|
||||
binding.themeSwitcher.setOnItemClickListener { _, _, i, _ ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putString("theme", ThemeManager.Companion.Theme.values()[i].theme).apply()
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putString("theme", ThemeManager.Companion.Theme.values()[i].theme).apply()
|
||||
//ActivityHelper.shouldRefreshMainActivity = true
|
||||
binding.themeSwitcher.clearFocus()
|
||||
restartApp()
|
||||
|
@ -148,14 +175,15 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
|
||||
binding.customTheme.setOnClickListener{
|
||||
binding.customTheme.setOnClickListener {
|
||||
var passedColor: Int = 0
|
||||
val dialogView = layoutInflater.inflate(R.layout.dialog_color_picker, null)
|
||||
val alertDialog = AlertDialog.Builder(this ,R.style.MyPopup)
|
||||
val alertDialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||
.setTitle("Custom Theme")
|
||||
.setView(dialogView)
|
||||
.setPositiveButton("OK") { dialog, _ ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putInt("custom_theme_int", passedColor).apply()
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putInt("custom_theme_int", passedColor).apply()
|
||||
logger("Custom Theme: $passedColor")
|
||||
dialog.dismiss()
|
||||
restartApp()
|
||||
|
@ -164,7 +192,8 @@ class SettingsActivity : AppCompatActivity() {
|
|||
dialog.dismiss()
|
||||
}
|
||||
.create()
|
||||
val colorPickerView = dialogView.findViewById<com.skydoves.colorpickerview.ColorPickerView>(R.id.colorPickerView)
|
||||
val colorPickerView =
|
||||
dialogView.findViewById<com.skydoves.colorpickerview.ColorPickerView>(R.id.colorPickerView)
|
||||
colorPickerView.setColorListener(ColorListener { color, fromUser ->
|
||||
val linearLayout = dialogView.findViewById<LinearLayout>(R.id.linear)
|
||||
passedColor = color
|
||||
|
@ -175,17 +204,27 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
//val animeSource = loadData<Int>("settings_def_anime_source_s")?.let { if (it >= AnimeSources.names.size) 0 else it } ?: 0
|
||||
val animeSource = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getInt("settings_def_anime_source_s_r", 0)
|
||||
val animeSource = getSharedPreferences(
|
||||
"Dantotsu",
|
||||
Context.MODE_PRIVATE
|
||||
).getInt("settings_def_anime_source_s_r", 0)
|
||||
if (AnimeSources.names.isNotEmpty() && animeSource in 0 until AnimeSources.names.size) {
|
||||
binding.animeSource.setText(AnimeSources.names[animeSource], false)
|
||||
|
||||
}
|
||||
|
||||
binding.animeSource.setAdapter(ArrayAdapter(this, R.layout.item_dropdown, AnimeSources.names))
|
||||
binding.animeSource.setAdapter(
|
||||
ArrayAdapter(
|
||||
this,
|
||||
R.layout.item_dropdown,
|
||||
AnimeSources.names
|
||||
)
|
||||
)
|
||||
|
||||
binding.animeSource.setOnItemClickListener { _, _, i, _ ->
|
||||
//saveData("settings_def_anime_source_s", i)
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putInt("settings_def_anime_source_s_r", i).apply()
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putInt("settings_def_anime_source_s_r", i).apply()
|
||||
binding.animeSource.clearFocus()
|
||||
}
|
||||
|
||||
|
@ -194,7 +233,8 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
val managers = arrayOf("Default", "1DM", "ADM")
|
||||
val downloadManagerDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle("Download Manager")
|
||||
val downloadManagerDialog =
|
||||
AlertDialog.Builder(this, R.style.DialogTheme).setTitle("Download Manager")
|
||||
var downloadManager = loadData<Int>("settings_download_manager") ?: 0
|
||||
binding.settingsDownloadManager.setOnClickListener {
|
||||
downloadManagerDialog.setSingleChoiceItems(managers, downloadManager) { dialog, count ->
|
||||
|
@ -204,11 +244,12 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}.show()
|
||||
}
|
||||
|
||||
binding.settingsForceLegacyInstall.isChecked = extensionInstaller.get() == BasePreferences.ExtensionInstaller.LEGACY
|
||||
binding.settingsForceLegacyInstall.isChecked =
|
||||
extensionInstaller.get() == BasePreferences.ExtensionInstaller.LEGACY
|
||||
binding.settingsForceLegacyInstall.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
extensionInstaller.set(BasePreferences.ExtensionInstaller.LEGACY)
|
||||
}else{
|
||||
} else {
|
||||
extensionInstaller.set(BasePreferences.ExtensionInstaller.PACKAGEINSTALLER)
|
||||
}
|
||||
}
|
||||
|
@ -223,11 +264,11 @@ class SettingsActivity : AppCompatActivity() {
|
|||
|
||||
}
|
||||
|
||||
binding.userAgent.setOnClickListener{
|
||||
binding.userAgent.setOnClickListener {
|
||||
val dialogView = layoutInflater.inflate(R.layout.dialog_user_agent, null)
|
||||
val editText = dialogView.findViewById<TextInputEditText>(R.id.userAgentTextBox)
|
||||
editText.setText(networkPreferences.defaultUserAgent().get())
|
||||
val alertDialog = AlertDialog.Builder(this ,R.style.MyPopup)
|
||||
val alertDialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||
.setTitle("User Agent")
|
||||
.setView(dialogView)
|
||||
.setPositiveButton("OK") { dialog, _ ->
|
||||
|
@ -235,7 +276,8 @@ class SettingsActivity : AppCompatActivity() {
|
|||
dialog.dismiss()
|
||||
}
|
||||
.setNeutralButton("Reset") { dialog, _ ->
|
||||
networkPreferences.defaultUserAgent().set("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:110.0) Gecko/20100101 Firefox/110.0") // Reset to default or empty
|
||||
networkPreferences.defaultUserAgent()
|
||||
.set("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:110.0) Gecko/20100101 Firefox/110.0") // Reset to default or empty
|
||||
editText.setText("")
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
@ -248,7 +290,22 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
|
||||
val exDns = listOf("None", "Cloudflare", "Google", "AdGuard", "Quad9", "AliDNS", "DNSPod", "360", "Quad101", "Mullvad", "Controld", "Njalla", "Shecan", "Libre")
|
||||
val exDns = listOf(
|
||||
"None",
|
||||
"Cloudflare",
|
||||
"Google",
|
||||
"AdGuard",
|
||||
"Quad9",
|
||||
"AliDNS",
|
||||
"DNSPod",
|
||||
"360",
|
||||
"Quad101",
|
||||
"Mullvad",
|
||||
"Controld",
|
||||
"Njalla",
|
||||
"Shecan",
|
||||
"Libre"
|
||||
)
|
||||
binding.settingsExtensionDns.setText(exDns[networkPreferences.dohProvider().get()], false)
|
||||
binding.settingsExtensionDns.setAdapter(ArrayAdapter(this, R.layout.item_dropdown, exDns))
|
||||
binding.settingsExtensionDns.setOnItemClickListener { _, _, i, _ ->
|
||||
|
@ -295,19 +352,29 @@ class SettingsActivity : AppCompatActivity() {
|
|||
saveData("settings_prefer_dub", isChecked)
|
||||
}
|
||||
|
||||
//val mangaSource = loadData<Int>("settings_def_manga_source_s")?.let { if (it >= MangaSources.names.size) 0 else it } ?: 0
|
||||
val mangaSource = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getInt("settings_def_manga_source_s_r", 0)
|
||||
if (MangaSources.names.isNotEmpty() && mangaSource in 0 until MangaSources.names.size) {
|
||||
binding.mangaSource.setText(MangaSources.names[mangaSource], false)
|
||||
//val mangaSource = loadData<Int>("settings_def_manga_source_s")?.let { if (it >= MangaSources.names.size) 0 else it } ?: 0
|
||||
val mangaSource = getSharedPreferences(
|
||||
"Dantotsu",
|
||||
Context.MODE_PRIVATE
|
||||
).getInt("settings_def_manga_source_s_r", 0)
|
||||
if (MangaSources.names.isNotEmpty() && mangaSource in 0 until MangaSources.names.size) {
|
||||
binding.mangaSource.setText(MangaSources.names[mangaSource], false)
|
||||
}
|
||||
|
||||
// Set up the dropdown adapter.
|
||||
binding.mangaSource.setAdapter(ArrayAdapter(this, R.layout.item_dropdown, MangaSources.names))
|
||||
binding.mangaSource.setAdapter(
|
||||
ArrayAdapter(
|
||||
this,
|
||||
R.layout.item_dropdown,
|
||||
MangaSources.names
|
||||
)
|
||||
)
|
||||
|
||||
// Set up the item click listener for the dropdown.
|
||||
binding.mangaSource.setOnItemClickListener { _, _, i, _ ->
|
||||
//saveData("settings_def_manga_source_s", i)
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putInt("settings_def_manga_source_s_r", i).apply()
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||
.putInt("settings_def_manga_source_s_r", i).apply()
|
||||
binding.mangaSource.clearFocus()
|
||||
}
|
||||
|
||||
|
@ -316,10 +383,11 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
val uiSettings: UserInterfaceSettings =
|
||||
loadData("ui_settings", toast = false) ?: UserInterfaceSettings().apply { saveData("ui_settings", this) }
|
||||
loadData("ui_settings", toast = false)
|
||||
?: UserInterfaceSettings().apply { saveData("ui_settings", this) }
|
||||
var previous: View = when (uiSettings.darkMode) {
|
||||
null -> binding.settingsUiAuto
|
||||
true -> binding.settingsUiDark
|
||||
null -> binding.settingsUiAuto
|
||||
true -> binding.settingsUiDark
|
||||
false -> binding.settingsUiLight
|
||||
}
|
||||
previous.alpha = 1f
|
||||
|
@ -349,9 +417,9 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
var previousStart: View = when (uiSettings.defaultStartUpTab) {
|
||||
0 -> binding.uiSettingsAnime
|
||||
1 -> binding.uiSettingsHome
|
||||
2 -> binding.uiSettingsManga
|
||||
0 -> binding.uiSettingsAnime
|
||||
1 -> binding.uiSettingsHome
|
||||
2 -> binding.uiSettingsManga
|
||||
else -> binding.uiSettingsHome
|
||||
}
|
||||
previousStart.alpha = 1f
|
||||
|
@ -383,9 +451,9 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
var previousEp: View = when (uiSettings.animeDefaultView) {
|
||||
0 -> binding.settingsEpList
|
||||
1 -> binding.settingsEpGrid
|
||||
2 -> binding.settingsEpCompact
|
||||
0 -> binding.settingsEpList
|
||||
1 -> binding.settingsEpGrid
|
||||
2 -> binding.settingsEpCompact
|
||||
else -> binding.settingsEpList
|
||||
}
|
||||
previousEp.alpha = 1f
|
||||
|
@ -410,8 +478,8 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
var previousChp: View = when (uiSettings.mangaDefaultView) {
|
||||
0 -> binding.settingsChpList
|
||||
1 -> binding.settingsChpCompact
|
||||
0 -> binding.settingsChpList
|
||||
1 -> binding.settingsChpCompact
|
||||
else -> binding.settingsChpList
|
||||
}
|
||||
previousChp.alpha = 1f
|
||||
|
@ -466,11 +534,16 @@ class SettingsActivity : AppCompatActivity() {
|
|||
binding.settingsLogo.setSafeOnClickListener {
|
||||
cursedCounter++
|
||||
(binding.settingsLogo.drawable as Animatable).start()
|
||||
if (cursedCounter % 7 == 0){
|
||||
if (cursedCounter % 7 == 0) {
|
||||
snackString("youwu have been cuwsed :pwayge:")
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putBoolean("use_cursed_lang",
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_cursed_lang", false).not()).apply()
|
||||
} else{
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putBoolean(
|
||||
"use_cursed_lang",
|
||||
getSharedPreferences(
|
||||
"Dantotsu",
|
||||
Context.MODE_PRIVATE
|
||||
).getBoolean("use_cursed_lang", false).not()
|
||||
).apply()
|
||||
} else {
|
||||
snackString(array[(Math.random() * array.size).toInt()], this)
|
||||
}
|
||||
|
||||
|
@ -504,12 +577,15 @@ class SettingsActivity : AppCompatActivity() {
|
|||
if (it > 0) "${if (hours > 0) "$hours hrs " else ""}${if (mins > 0) "$mins mins" else ""}"
|
||||
else getString(R.string.do_not_update)
|
||||
}.toTypedArray()
|
||||
binding.settingsSubscriptionsTime.text = getString(R.string.subscriptions_checking_time_s, timeNames[curTime])
|
||||
val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(R.string.subscriptions_checking_time)
|
||||
binding.settingsSubscriptionsTime.text =
|
||||
getString(R.string.subscriptions_checking_time_s, timeNames[curTime])
|
||||
val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(R.string.subscriptions_checking_time)
|
||||
binding.settingsSubscriptionsTime.setOnClickListener {
|
||||
speedDialog.setSingleChoiceItems(timeNames, curTime) { dialog, i ->
|
||||
curTime = i
|
||||
binding.settingsSubscriptionsTime.text = getString(R.string.subscriptions_checking_time_s, timeNames[i])
|
||||
binding.settingsSubscriptionsTime.text =
|
||||
getString(R.string.subscriptions_checking_time_s, timeNames[i])
|
||||
saveData("subscriptions_time_s", curTime)
|
||||
dialog.dismiss()
|
||||
startSubscription(true)
|
||||
|
@ -521,7 +597,8 @@ class SettingsActivity : AppCompatActivity() {
|
|||
true
|
||||
}
|
||||
|
||||
binding.settingsNotificationsCheckingSubscriptions.isChecked = loadData("subscription_checking_notifications") ?: true
|
||||
binding.settingsNotificationsCheckingSubscriptions.isChecked =
|
||||
loadData("subscription_checking_notifications") ?: true
|
||||
binding.settingsNotificationsCheckingSubscriptions.setOnCheckedChangeListener { _, isChecked ->
|
||||
saveData("subscription_checking_notifications", isChecked)
|
||||
if (isChecked)
|
||||
|
@ -570,7 +647,8 @@ class SettingsActivity : AppCompatActivity() {
|
|||
setTitleText(title)
|
||||
addView(
|
||||
TextView(it.context).apply {
|
||||
val markWon = Markwon.builder(it.context).usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
val markWon = Markwon.builder(it.context)
|
||||
.usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
markWon.setMarkdown(this, full)
|
||||
}
|
||||
)
|
||||
|
@ -624,14 +702,24 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
if (Discord.token != null) {
|
||||
val id = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE).getString("discord_id", null)
|
||||
val avatar = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE).getString("discord_avatar", null)
|
||||
val username = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE).getString("discord_username", null)
|
||||
val id = getSharedPreferences(
|
||||
getString(R.string.preference_file_key),
|
||||
Context.MODE_PRIVATE
|
||||
).getString("discord_id", null)
|
||||
val avatar = getSharedPreferences(
|
||||
getString(R.string.preference_file_key),
|
||||
Context.MODE_PRIVATE
|
||||
).getString("discord_avatar", null)
|
||||
val username = getSharedPreferences(
|
||||
getString(R.string.preference_file_key),
|
||||
Context.MODE_PRIVATE
|
||||
).getString("discord_username", null)
|
||||
if (id != null && avatar != null) {
|
||||
binding.settingsDiscordAvatar.loadImage("https://cdn.discordapp.com/avatars/$id/$avatar.png")
|
||||
}
|
||||
binding.settingsDiscordUsername.visibility = View.VISIBLE
|
||||
binding.settingsDiscordUsername.text = username ?: Discord.token?.replace(Regex("."),"*")
|
||||
binding.settingsDiscordUsername.text =
|
||||
username ?: Discord.token?.replace(Regex("."), "*")
|
||||
binding.settingsDiscordLogin.setText(R.string.logout)
|
||||
binding.settingsDiscordLogin.setOnClickListener {
|
||||
Discord.removeSavedToken(this)
|
||||
|
@ -676,13 +764,18 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun restartApp() {
|
||||
Snackbar.make(
|
||||
binding.root,
|
||||
R.string.restart_app, Snackbar.LENGTH_SHORT
|
||||
).apply {
|
||||
val mainIntent =
|
||||
Intent.makeRestartActivityTask(context.packageManager.getLaunchIntentForPackage(context.packageName)!!.component)
|
||||
Intent.makeRestartActivityTask(
|
||||
context.packageManager.getLaunchIntentForPackage(
|
||||
context.packageName
|
||||
)!!.component
|
||||
)
|
||||
setAction("Do it!") {
|
||||
context.startActivity(mainIntent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
|
|
|
@ -10,21 +10,31 @@ import android.util.TypedValue
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Switch
|
||||
import androidx.core.content.ContextCompat
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.BottomSheetDialogFragment
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.others.imagesearch.ImageSearchActivity
|
||||
import ani.dantotsu.databinding.BottomSheetSettingsBinding
|
||||
import ani.dantotsu.download.DownloadContainerActivity
|
||||
import ani.dantotsu.download.manga.OfflineMangaFragment
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.others.imagesearch.ImageSearchActivity
|
||||
import ani.dantotsu.setSafeOnClickListener
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.toast
|
||||
|
||||
|
||||
class SettingsDialogFragment(val pageType: PageType) : BottomSheetDialogFragment() {
|
||||
private var _binding: BottomSheetSettingsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetSettingsBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -43,7 +53,7 @@ class SettingsDialogFragment(val pageType: PageType) : BottomSheetDialogFragment
|
|||
binding.settingsLogin.setOnClickListener {
|
||||
Anilist.removeSavedToken(it.context)
|
||||
dismiss()
|
||||
startMainActivity(requireActivity(),)
|
||||
startMainActivity(requireActivity())
|
||||
}
|
||||
binding.settingsUsername.text = Anilist.username
|
||||
binding.settingsUserAvatar.loadImage(Anilist.avatar)
|
||||
|
@ -73,15 +83,17 @@ class SettingsDialogFragment(val pageType: PageType) : BottomSheetDialogFragment
|
|||
dismiss()
|
||||
}
|
||||
binding.settingsDownloads.setSafeOnClickListener {
|
||||
when(pageType) {
|
||||
when (pageType) {
|
||||
PageType.MANGA -> {
|
||||
val intent = Intent(activity, DownloadContainerActivity::class.java)
|
||||
intent.putExtra("FRAGMENT_CLASS_NAME", OfflineMangaFragment::class.java.name)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
PageType.ANIME -> {
|
||||
try {
|
||||
val arrayOfFiles = ContextCompat.getExternalFilesDirs(requireContext(), null)
|
||||
val arrayOfFiles =
|
||||
ContextCompat.getExternalFilesDirs(requireContext(), null)
|
||||
startActivity(
|
||||
if (loadData<Boolean>("sd_dl") == true && arrayOfFiles.size > 1 && arrayOfFiles[0] != null && arrayOfFiles[1] != null) {
|
||||
val parentDirectory = arrayOfFiles[1].toString()
|
||||
|
@ -93,9 +105,11 @@ class SettingsDialogFragment(val pageType: PageType) : BottomSheetDialogFragment
|
|||
toast(getString(R.string.file_manager_not_found))
|
||||
}
|
||||
}
|
||||
|
||||
PageType.HOME -> {
|
||||
try {
|
||||
val arrayOfFiles = ContextCompat.getExternalFilesDirs(requireContext(), null)
|
||||
val arrayOfFiles =
|
||||
ContextCompat.getExternalFilesDirs(requireContext(), null)
|
||||
startActivity(
|
||||
if (loadData<Boolean>("sd_dl") == true && arrayOfFiles.size > 1 && arrayOfFiles[0] != null && arrayOfFiles[1] != null) {
|
||||
val parentDirectory = arrayOfFiles[1].toString()
|
||||
|
@ -118,8 +132,8 @@ class SettingsDialogFragment(val pageType: PageType) : BottomSheetDialogFragment
|
|||
_binding = null
|
||||
}
|
||||
|
||||
companion object{
|
||||
enum class PageType{
|
||||
companion object {
|
||||
enum class PageType {
|
||||
MANGA, ANIME, HOME
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,15 @@ data class UserInterfaceSettings(
|
|||
var immersiveMode: Boolean = false,
|
||||
var smallView: Boolean = true,
|
||||
var defaultStartUpTab: Int = 1,
|
||||
var homeLayoutShow: MutableList<Boolean> = mutableListOf(true, false, false, true, false, false, true),
|
||||
var homeLayoutShow: MutableList<Boolean> = mutableListOf(
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
),
|
||||
|
||||
//Animations
|
||||
var bannerAnimations: Boolean = true,
|
||||
|
|
|
@ -6,10 +6,15 @@ import android.os.Bundle
|
|||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.ActivityUserInterfaceSettingsBinding
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
class UserInterfaceSettingsActivity : AppCompatActivity() {
|
||||
|
@ -18,7 +23,7 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
LangSet.setLocale(this)
|
||||
ThemeManager(this).applyTheme()
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityUserInterfaceSettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
@ -28,7 +33,8 @@ ThemeManager(this).applyTheme()
|
|||
bottomMargin = navBarHeight
|
||||
}
|
||||
|
||||
val settings = loadData<UserInterfaceSettings>(ui, toast = false) ?: UserInterfaceSettings().apply { saveData(ui, this) }
|
||||
val settings = loadData<UserInterfaceSettings>(ui, toast = false)
|
||||
?: UserInterfaceSettings().apply { saveData(ui, this) }
|
||||
|
||||
binding.uiSettingsBack.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
|
@ -36,8 +42,12 @@ ThemeManager(this).applyTheme()
|
|||
|
||||
val views = resources.getStringArray(R.array.home_layouts)
|
||||
binding.uiSettingsHomeLayout.setOnClickListener {
|
||||
AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.home_layout_show)).apply {
|
||||
setMultiChoiceItems(views, settings.homeLayoutShow.toBooleanArray()) { _, i, value ->
|
||||
AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.home_layout_show)).apply {
|
||||
setMultiChoiceItems(
|
||||
views,
|
||||
settings.homeLayoutShow.toBooleanArray()
|
||||
) { _, i, value ->
|
||||
settings.homeLayoutShow[i] = value
|
||||
saveData(ui, settings)
|
||||
}
|
||||
|
@ -100,7 +110,11 @@ ThemeManager(this).applyTheme()
|
|||
R.string.restart_app, Snackbar.LENGTH_SHORT
|
||||
).apply {
|
||||
val mainIntent =
|
||||
Intent.makeRestartActivityTask(context.packageManager.getLaunchIntentForPackage(context.packageName)!!.component)
|
||||
Intent.makeRestartActivityTask(
|
||||
context.packageManager.getLaunchIntentForPackage(
|
||||
context.packageName
|
||||
)!!.component
|
||||
)
|
||||
setAction("Do it!") {
|
||||
context.startActivity(mainIntent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package ani.dantotsu.settings.extensionprefs
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.DialogPreference
|
||||
|
@ -14,11 +10,6 @@ import androidx.preference.EditTextPreference
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.forEach
|
||||
import androidx.preference.getOnBindEditTextListener
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.settings.ExtensionsActivity
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import eu.kanade.tachiyomi.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore
|
||||
|
@ -33,9 +24,14 @@ class AnimeSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
preferenceScreen = populateAnimePreferenceScreen()
|
||||
//set background color
|
||||
val color = TypedValue()
|
||||
requireContext().theme.resolveAttribute(com.google.android.material.R.attr.backgroundColor, color, true)
|
||||
requireContext().theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.backgroundColor,
|
||||
color,
|
||||
true
|
||||
)
|
||||
view?.setBackgroundColor(color.data)
|
||||
}
|
||||
|
||||
private var onCloseAction: (() -> Unit)? = null
|
||||
|
||||
|
||||
|
@ -48,7 +44,8 @@ class AnimeSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
val sourceId = requireArguments().getLong(SOURCE_ID)
|
||||
val source = Injekt.get<AnimeSourceManager>().get(sourceId)!!
|
||||
check(source is ConfigurableAnimeSource)
|
||||
val sharedPreferences = requireContext().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE)
|
||||
val sharedPreferences =
|
||||
requireContext().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE)
|
||||
val dataStore = SharedPreferencesDataStore(sharedPreferences)
|
||||
preferenceManager.preferenceDataStore = dataStore
|
||||
val sourceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||
|
@ -75,7 +72,11 @@ class AnimeSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
|
||||
return sourceScreen
|
||||
}
|
||||
fun getInstance(sourceId: Long, onCloseAction: (() -> Unit)? = null): AnimeSourcePreferencesFragment {
|
||||
|
||||
fun getInstance(
|
||||
sourceId: Long,
|
||||
onCloseAction: (() -> Unit)? = null
|
||||
): AnimeSourcePreferencesFragment {
|
||||
val fragment = AnimeSourcePreferencesFragment()
|
||||
fragment.arguments = bundleOf(SOURCE_ID to sourceId)
|
||||
fragment.onCloseAction = onCloseAction
|
||||
|
|
|
@ -2,8 +2,6 @@ package ani.dantotsu.settings.extensionprefs
|
|||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.DialogPreference
|
||||
|
@ -11,11 +9,6 @@ import androidx.preference.EditTextPreference
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.forEach
|
||||
import androidx.preference.getOnBindEditTextListener
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.settings.ExtensionsActivity
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import eu.kanade.tachiyomi.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
|
@ -29,6 +22,7 @@ class MangaSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
preferenceScreen = populateMangaPreferenceScreen()
|
||||
}
|
||||
|
||||
private var onCloseAction: (() -> Unit)? = null
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -41,7 +35,8 @@ class MangaSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
val sourceId = requireArguments().getLong(SOURCE_ID)
|
||||
val source = Injekt.get<MangaSourceManager>().get(sourceId)!!
|
||||
check(source is ConfigurableSource)
|
||||
val sharedPreferences = requireContext().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE)
|
||||
val sharedPreferences =
|
||||
requireContext().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE)
|
||||
val dataStore = SharedPreferencesDataStore(sharedPreferences)
|
||||
preferenceManager.preferenceDataStore = dataStore
|
||||
val sourceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||
|
@ -65,7 +60,11 @@ class MangaSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
|
||||
return sourceScreen
|
||||
}
|
||||
fun getInstance(sourceId: Long, onCloseAction: (() -> Unit)? = null): MangaSourcePreferencesFragment {
|
||||
|
||||
fun getInstance(
|
||||
sourceId: Long,
|
||||
onCloseAction: (() -> Unit)? = null
|
||||
): MangaSourcePreferencesFragment {
|
||||
val fragment = MangaSourcePreferencesFragment()
|
||||
fragment.arguments = bundleOf(SOURCE_ID to sourceId)
|
||||
fragment.onCloseAction = onCloseAction
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ani.dantotsu.settings.paging
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
|
@ -47,9 +46,11 @@ class AnimeExtensionsViewModel(
|
|||
fun setSearchQuery(query: String) {
|
||||
searchQuery.value = query
|
||||
}
|
||||
|
||||
fun invalidatePager() {
|
||||
currentPagingSource?.invalidate()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
val pagerFlow: Flow<PagingData<AnimeExtension.Available>> = searchQuery.flatMapLatest { query ->
|
||||
Pager(
|
||||
|
@ -77,7 +78,8 @@ class AnimeExtensionPagingSource(
|
|||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, AnimeExtension.Available> {
|
||||
val position = params.key ?: 0
|
||||
val installedExtensions = installedExtensionsFlow.first().map { it.pkgName }.toSet()
|
||||
val availableExtensions = availableExtensionsFlow.first().filterNot { it.pkgName in installedExtensions }
|
||||
val availableExtensions =
|
||||
availableExtensionsFlow.first().filterNot { it.pkgName in installedExtensions }
|
||||
val query = searchQuery.first()
|
||||
val isNsfwEnabled: Boolean = loadData("NFSWExtension") ?: true
|
||||
|
||||
|
@ -86,7 +88,7 @@ class AnimeExtensionPagingSource(
|
|||
} else {
|
||||
availableExtensions.filter { it.name.contains(query, ignoreCase = true) }
|
||||
}
|
||||
val filternfsw = if(isNsfwEnabled) {
|
||||
val filternfsw = if (isNsfwEnabled) {
|
||||
filteredExtensions
|
||||
} else {
|
||||
filteredExtensions.filterNot { it.isNsfw }
|
||||
|
@ -120,12 +122,18 @@ class AnimeExtensionAdapter(private val clickListener: OnAnimeInstallClickListen
|
|||
|
||||
companion object {
|
||||
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<AnimeExtension.Available>() {
|
||||
override fun areItemsTheSame(oldItem: AnimeExtension.Available, newItem: AnimeExtension.Available): Boolean {
|
||||
override fun areItemsTheSame(
|
||||
oldItem: AnimeExtension.Available,
|
||||
newItem: AnimeExtension.Available
|
||||
): Boolean {
|
||||
// Your logic here
|
||||
return oldItem.pkgName == newItem.pkgName
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: AnimeExtension.Available, newItem: AnimeExtension.Available): Boolean {
|
||||
override fun areContentsTheSame(
|
||||
oldItem: AnimeExtension.Available,
|
||||
newItem: AnimeExtension.Available
|
||||
): Boolean {
|
||||
// Your logic here
|
||||
return oldItem == newItem
|
||||
}
|
||||
|
@ -133,7 +141,8 @@ class AnimeExtensionAdapter(private val clickListener: OnAnimeInstallClickListen
|
|||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AnimeExtensionViewHolder {
|
||||
val binding = ItemExtensionAllBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val binding =
|
||||
ItemExtensionAllBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return AnimeExtensionViewHolder(binding)
|
||||
}
|
||||
|
||||
|
@ -149,7 +158,8 @@ class AnimeExtensionAdapter(private val clickListener: OnAnimeInstallClickListen
|
|||
}
|
||||
}
|
||||
|
||||
inner class AnimeExtensionViewHolder(private val binding: ItemExtensionAllBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class AnimeExtensionViewHolder(private val binding: ItemExtensionAllBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
binding.closeTextView.setOnClickListener {
|
||||
val extension = getItem(bindingAdapterPosition)
|
||||
|
@ -158,11 +168,12 @@ class AnimeExtensionAdapter(private val clickListener: OnAnimeInstallClickListen
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
val extensionIconImageView: ImageView = binding.extensionIconImageView
|
||||
|
||||
fun bind(extension: AnimeExtension.Available) {
|
||||
fun bind(extension: AnimeExtension.Available) {
|
||||
val nsfw = if (extension.isNsfw) "(18+)" else ""
|
||||
val lang= LanguageMapper.mapLanguageCodeToName(extension.lang)
|
||||
val lang = LanguageMapper.mapLanguageCodeToName(extension.lang)
|
||||
binding.extensionNameTextView.text = extension.name
|
||||
binding.extensionVersionTextView.text = "$lang ${extension.versionName} $nsfw"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ani.dantotsu.settings.paging
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
|
@ -79,7 +78,8 @@ class MangaExtensionPagingSource(
|
|||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MangaExtension.Available> {
|
||||
val position = params.key ?: 0
|
||||
val installedExtensions = installedExtensionsFlow.first().map { it.pkgName }.toSet()
|
||||
val availableExtensions = availableExtensionsFlow.first().filterNot { it.pkgName in installedExtensions }
|
||||
val availableExtensions =
|
||||
availableExtensionsFlow.first().filterNot { it.pkgName in installedExtensions }
|
||||
val query = searchQuery.first()
|
||||
val isNsfwEnabled: Boolean = loadData("NFSWExtension") ?: true
|
||||
val filteredExtensions = if (query.isEmpty()) {
|
||||
|
@ -87,7 +87,7 @@ class MangaExtensionPagingSource(
|
|||
} else {
|
||||
availableExtensions.filter { it.name.contains(query, ignoreCase = true) }
|
||||
}
|
||||
val filternfsw = if(isNsfwEnabled) {
|
||||
val filternfsw = if (isNsfwEnabled) {
|
||||
filteredExtensions
|
||||
} else {
|
||||
filteredExtensions.filterNot { it.isNsfw }
|
||||
|
@ -121,18 +121,25 @@ class MangaExtensionAdapter(private val clickListener: OnMangaInstallClickListen
|
|||
|
||||
companion object {
|
||||
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<MangaExtension.Available>() {
|
||||
override fun areItemsTheSame(oldItem: MangaExtension.Available, newItem: MangaExtension.Available): Boolean {
|
||||
override fun areItemsTheSame(
|
||||
oldItem: MangaExtension.Available,
|
||||
newItem: MangaExtension.Available
|
||||
): Boolean {
|
||||
return oldItem.pkgName == newItem.pkgName
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: MangaExtension.Available, newItem: MangaExtension.Available): Boolean {
|
||||
override fun areContentsTheSame(
|
||||
oldItem: MangaExtension.Available,
|
||||
newItem: MangaExtension.Available
|
||||
): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MangaExtensionViewHolder {
|
||||
val binding = ItemExtensionAllBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val binding =
|
||||
ItemExtensionAllBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return MangaExtensionViewHolder(binding)
|
||||
}
|
||||
|
||||
|
@ -148,7 +155,8 @@ class MangaExtensionAdapter(private val clickListener: OnMangaInstallClickListen
|
|||
}
|
||||
}
|
||||
|
||||
inner class MangaExtensionViewHolder(private val binding: ItemExtensionAllBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class MangaExtensionViewHolder(private val binding: ItemExtensionAllBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
binding.closeTextView.setOnClickListener {
|
||||
val extension = getItem(bindingAdapterPosition)
|
||||
|
@ -157,10 +165,11 @@ class MangaExtensionAdapter(private val clickListener: OnMangaInstallClickListen
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
val extensionIconImageView: ImageView = binding.extensionIconImageView
|
||||
fun bind(extension: MangaExtension.Available) {
|
||||
val nsfw = if (extension.isNsfw) "(18+)" else ""
|
||||
val lang= LanguageMapper.mapLanguageCodeToName(extension.lang)
|
||||
val lang = LanguageMapper.mapLanguageCodeToName(extension.lang)
|
||||
binding.extensionNameTextView.text = extension.name
|
||||
binding.extensionVersionTextView.text = "$lang ${extension.versionName} $nsfw"
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@ class NovelExtensionPagingSource(
|
|||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, NovelExtension.Available> {
|
||||
val position = params.key ?: 0
|
||||
val installedExtensions = installedExtensionsFlow.first().map { it.pkgName }.toSet()
|
||||
val availableExtensions = availableExtensionsFlow.first().filterNot { it.pkgName in installedExtensions }
|
||||
val availableExtensions =
|
||||
availableExtensionsFlow.first().filterNot { it.pkgName in installedExtensions }
|
||||
val query = searchQuery.first()
|
||||
val isNsfwEnabled: Boolean = loadData("NFSWExtension") ?: true
|
||||
val filteredExtensions = if (query.isEmpty()) {
|
||||
|
@ -123,18 +124,25 @@ class NovelExtensionAdapter(private val clickListener: OnNovelInstallClickListen
|
|||
|
||||
companion object {
|
||||
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<NovelExtension.Available>() {
|
||||
override fun areItemsTheSame(oldItem: NovelExtension.Available, newItem: NovelExtension.Available): Boolean {
|
||||
override fun areItemsTheSame(
|
||||
oldItem: NovelExtension.Available,
|
||||
newItem: NovelExtension.Available
|
||||
): Boolean {
|
||||
return oldItem.pkgName == newItem.pkgName
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: NovelExtension.Available, newItem: NovelExtension.Available): Boolean {
|
||||
override fun areContentsTheSame(
|
||||
oldItem: NovelExtension.Available,
|
||||
newItem: NovelExtension.Available
|
||||
): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NovelExtensionViewHolder {
|
||||
val binding = ItemExtensionAllBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val binding =
|
||||
ItemExtensionAllBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return NovelExtensionViewHolder(binding)
|
||||
}
|
||||
|
||||
|
@ -150,7 +158,8 @@ class NovelExtensionAdapter(private val clickListener: OnNovelInstallClickListen
|
|||
}
|
||||
}
|
||||
|
||||
inner class NovelExtensionViewHolder(private val binding: ItemExtensionAllBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class NovelExtensionViewHolder(private val binding: ItemExtensionAllBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
binding.closeTextView.setOnClickListener {
|
||||
val extension = getItem(bindingAdapterPosition)
|
||||
|
@ -159,10 +168,11 @@ class NovelExtensionAdapter(private val clickListener: OnNovelInstallClickListen
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
val extensionIconImageView: ImageView = binding.extensionIconImageView
|
||||
fun bind(extension: NovelExtension.Available) {
|
||||
val nsfw = ""
|
||||
val lang= LanguageMapper.mapLanguageCodeToName("all")
|
||||
val lang = LanguageMapper.mapLanguageCodeToName("all")
|
||||
binding.extensionNameTextView.text = extension.name
|
||||
binding.extensionVersionTextView.text = "$lang ${extension.versionName} $nsfw"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue