From 1a346e6b5a6c56950678a1265ed5580da434aba3 Mon Sep 17 00:00:00 2001 From: aayush262 Date: Thu, 1 Feb 2024 23:37:34 +0530 Subject: [PATCH] no changes --- .../media/anime/AnimeWatchFragment.kt | 6 ++-- .../ani/dantotsu/media/anime/ExoplayerView.kt | 6 ++-- .../dantotsu/media/manga/MangaReadFragment.kt | 6 ++-- .../media/novel/NovelResponseAdapter.kt | 2 +- .../dantotsu/settings/ExtensionsActivity.kt | 31 ++++++++++--------- .../settings/PlayerSettingsActivity.kt | 16 +++++----- .../ani/dantotsu/settings/SettingsActivity.kt | 4 +-- .../settings/UserInterfaceSettingsActivity.kt | 2 +- .../settings/paging/AnimePagingSource.kt | 5 +-- .../settings/paging/MangaPagingSource.kt | 5 +-- .../dantotsu/settings/saving/Preferences.kt | 1 + app/src/main/res/values/style.xml | 13 ++++++-- app/src/main/res/values/themes.xml | 10 ------ 13 files changed, 53 insertions(+), 54 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt index ff9a0283356..a8a1b6a1479 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt @@ -383,12 +383,10 @@ class AnimeWatchFragment : Fragment() { if (allSettings.size > 1) { val names = allSettings.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray() - var selectedIndex = 0 val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup) .setTitle("Select a Source") - .setSingleChoiceItems(names, selectedIndex) { dialog, which -> - selectedIndex = which - selectedSetting = allSettings[selectedIndex] + .setSingleChoiceItems(names, -1) { dialog, which -> + selectedSetting = allSettings[which] itemSelected = true dialog.dismiss() diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index 5c9df4b4cba..0025987b1d4 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -543,7 +543,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL exoPlayer.seekTo(exoPlayer.currentPosition + settings.skipTime * 1000) } exoSkip.setOnLongClickListener { - val dialog = Dialog(this, R.style.DialogTheme) + val dialog = Dialog(this, R.style.MyPopup) dialog.setContentView(R.layout.item_seekbar_dialog) dialog.setCancelable(true) dialog.setCanceledOnTouchOutside(true) @@ -1144,7 +1144,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL playbackParameters = PlaybackParameters(speeds[curSpeed]) var speed: Float val speedDialog = - AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.speed)) + AlertDialog.Builder(this, R.style.MyPopup).setTitle(getString(R.string.speed)) exoSpeed.setOnClickListener { val dialog = speedDialog.setSingleChoiceItems(speedsName, curSpeed) { dialog, i -> if (isInitialized) { @@ -1413,7 +1413,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL ) ) ) - val dialog = AlertDialog.Builder(this, R.style.DialogTheme) + val dialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.continue_from, time)).apply { setCancelable(false) setPositiveButton(getString(R.string.yes)) { d, _ -> diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt index e13828bb20a..40e85f82a10 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt @@ -386,12 +386,10 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { if (allSettings.size > 1) { val names = allSettings.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray() - var selectedIndex = 0 val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup) .setTitle("Select a Source") - .setSingleChoiceItems(names, selectedIndex) { dialog, which -> - selectedIndex = which - selectedSetting = allSettings[selectedIndex] + .setSingleChoiceItems(names, -1) { dialog, which -> + selectedSetting = allSettings[which] itemSelected = true dialog.dismiss() diff --git a/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt b/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt index 6d57037456c..49b3fc610c9 100644 --- a/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt @@ -104,7 +104,7 @@ class NovelResponseAdapter( binding.root.setOnLongClickListener { val builder = androidx.appcompat.app.AlertDialog.Builder( fragment.requireContext(), - R.style.DialogTheme + R.style.MyPopup ) builder.setTitle("Delete ${novel.name}?") builder.setMessage("Are you sure you want to delete ${novel.name}?") diff --git a/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt b/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt index 4f51430b836..f0be5db2944 100644 --- a/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt @@ -1,12 +1,12 @@ package ani.dantotsu.settings import android.annotation.SuppressLint +import android.app.AlertDialog import android.os.Build.* 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 androidx.appcompat.app.AppCompatActivity @@ -16,6 +16,9 @@ import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.widget.ViewPager2 import ani.dantotsu.* import ani.dantotsu.databinding.ActivityExtensionsBinding +import ani.dantotsu.others.LanguageMapper +import ani.dantotsu.settings.saving.PrefName +import ani.dantotsu.settings.saving.PrefWrapper import ani.dantotsu.themes.ThemeManager import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator @@ -111,20 +114,20 @@ class ExtensionsActivity : AppCompatActivity() { } }) - initActivity(this) - binding.languageselect.visibility = View.GONE - /* TODO - binding.languageselect.setOnClickListener { - val popup = PopupMenu(this, it) - popup.inflate(R.menu.launguage_selector_menu) - popup.setOnMenuItemClickListener { menuItem -> - true - } - popup.setOnDismissListener { - } - popup.show() - }*/ + binding.languageselect.setOnClickListener { + val languageOptions = LanguageMapper.Companion.Language.entries.map{ it.name }.toTypedArray() + val builder = AlertDialog.Builder(currContext(), R.style.MyPopup) + val listOrder = PrefWrapper.getVal(PrefName.LangSort,"all") + val index = LanguageMapper.Companion.Language.entries.toTypedArray().indexOfFirst{it.code == listOrder} + builder.setTitle("Language") + builder.setSingleChoiceItems(languageOptions, index){ dialog, i -> + PrefWrapper.setVal(PrefName.LangSort, LanguageMapper.Companion.Language.entries[i].code) + dialog.dismiss() + } + val dialog = builder.show() + dialog.window?.setDimAmount(0.8f) + } binding.settingsContainer.updateLayoutParams { topMargin = statusBarHeight bottomMargin = navBarHeight diff --git a/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt index d76ae92b5d7..23d960f1faf 100644 --- a/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt @@ -95,7 +95,7 @@ class PlayerSettingsActivity : AppCompatActivity() { 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) + val speedDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.default_speed)) binding.playerSettingsSpeed.setOnClickListener { val dialog = @@ -246,7 +246,7 @@ class PlayerSettingsActivity : AppCompatActivity() { } val resizeModes = arrayOf("Original", "Zoom", "Stretch") - val resizeDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val resizeDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.default_resize_mode)) binding.playerResizeMode.setOnClickListener { val dialog = @@ -332,7 +332,7 @@ class PlayerSettingsActivity : AppCompatActivity() { "Blue", "Magenta" ) - val primaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val primaryColorDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.primary_sub_color)) binding.videoSubColorPrimary.setOnClickListener { val dialog = primaryColorDialog.setSingleChoiceItems( @@ -359,7 +359,7 @@ class PlayerSettingsActivity : AppCompatActivity() { "Magenta", "Transparent" ) - val secondaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val secondaryColorDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.outline_sub_color)) binding.videoSubColorSecondary.setOnClickListener { val dialog = secondaryColorDialog.setSingleChoiceItems( @@ -373,7 +373,7 @@ class PlayerSettingsActivity : AppCompatActivity() { dialog.window?.setDimAmount(0.8f) } val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None") - val outlineDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val outlineDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.outline_type)) binding.videoSubOutline.setOnClickListener { val dialog = outlineDialog.setSingleChoiceItems( @@ -400,7 +400,7 @@ class PlayerSettingsActivity : AppCompatActivity() { "Blue", "Magenta" ) - val subBackgroundDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val subBackgroundDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.outline_sub_color)) binding.videoSubColorBackground.setOnClickListener { val dialog = subBackgroundDialog.setSingleChoiceItems( @@ -428,7 +428,7 @@ class PlayerSettingsActivity : AppCompatActivity() { "Blue", "Magenta" ) - val subWindowDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val subWindowDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.outline_sub_color)) binding.videoSubColorWindow.setOnClickListener { val dialog = subWindowDialog.setSingleChoiceItems( @@ -449,7 +449,7 @@ class PlayerSettingsActivity : AppCompatActivity() { "Century Gothic", "Century Gothic Bold" ) - val fontDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val fontDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.subtitle_font)) binding.videoSubFont.setOnClickListener { val dialog = fontDialog.setSingleChoiceItems(fonts, settings.font) { dialog, count -> diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt index d99867ee3bb..38cc70cbf88 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt @@ -207,7 +207,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene val managers = arrayOf("Default", "1DM", "ADM") val downloadManagerDialog = - AlertDialog.Builder(this, R.style.DialogTheme).setTitle("Download Manager") + AlertDialog.Builder(this, R.style.MyPopup).setTitle("Download Manager") var downloadManager = PrefWrapper.getVal(PrefName.DownloadManager, 0) binding.settingsDownloadManager.setOnClickListener { val dialog = downloadManagerDialog.setSingleChoiceItems( @@ -608,7 +608,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene }.toTypedArray() binding.settingsSubscriptionsTime.text = getString(R.string.subscriptions_checking_time_s, timeNames[curTime]) - val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme) + val speedDialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(R.string.subscriptions_checking_time) binding.settingsSubscriptionsTime.setOnClickListener { val dialog = speedDialog.setSingleChoiceItems(timeNames, curTime) { dialog, i -> diff --git a/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt index d4d18aa10e2..7e97d3a3347 100644 --- a/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt @@ -41,7 +41,7 @@ class UserInterfaceSettingsActivity : AppCompatActivity() { val views = resources.getStringArray(R.array.home_layouts) binding.uiSettingsHomeLayout.setOnClickListener { - val dialog = AlertDialog.Builder(this, R.style.DialogTheme) + val dialog = AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.home_layout_show)).apply { setMultiChoiceItems( views, diff --git a/app/src/main/java/ani/dantotsu/settings/paging/AnimePagingSource.kt b/app/src/main/java/ani/dantotsu/settings/paging/AnimePagingSource.kt index e5d446c0dd5..065fa58bbf9 100644 --- a/app/src/main/java/ani/dantotsu/settings/paging/AnimePagingSource.kt +++ b/app/src/main/java/ani/dantotsu/settings/paging/AnimePagingSource.kt @@ -100,8 +100,9 @@ class AnimeExtensionPagingSource( } else { availableExtensions.filter { it.name.contains(query, ignoreCase = true) } } - val filternfsw = - if (isNsfwEnabled) filteredExtensions else filteredExtensions.filterNot { it.isNsfw } + val lang = PrefWrapper.getVal(PrefName.LangSort, "all") + val langFilter = if (lang != "all") filteredExtensions.filter { it.lang == lang } else filteredExtensions + val filternfsw = if (isNsfwEnabled) langFilter else langFilter.filterNot { it.isNsfw } return try { val sublist = filternfsw.subList( fromIndex = position, diff --git a/app/src/main/java/ani/dantotsu/settings/paging/MangaPagingSource.kt b/app/src/main/java/ani/dantotsu/settings/paging/MangaPagingSource.kt index 3025ba527e7..d8f0a0e42fe 100644 --- a/app/src/main/java/ani/dantotsu/settings/paging/MangaPagingSource.kt +++ b/app/src/main/java/ani/dantotsu/settings/paging/MangaPagingSource.kt @@ -100,8 +100,9 @@ class MangaExtensionPagingSource( } else { availableExtensions.filter { it.name.contains(query, ignoreCase = true) } } - val filternfsw = - if (isNsfwEnabled) filteredExtensions else filteredExtensions.filterNot { it.isNsfw } + val lang = PrefWrapper.getVal(PrefName.LangSort, "all") + val langFilter = if (lang != "all") filteredExtensions.filter { it.lang == lang } else filteredExtensions + val filternfsw = if (isNsfwEnabled) langFilter else langFilter.filterNot { it.isNsfw } return try { val sublist = filternfsw.subList( fromIndex = position, diff --git a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt index d0ca5e85dbb..f8bf4cb5384 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -45,6 +45,7 @@ enum class PrefName(val data: Pref) { AllowOpeningLinks(Pref(Location.Irrelevant, Boolean::class)), SearchStyle(Pref(Location.Irrelevant, Int::class)), HasUpdatedPrefs(Pref(Location.Irrelevant, Boolean::class)), + LangSort(Pref(Location.Irrelevant, String::class)), //Protected DiscordToken(Pref(Location.Protected, String::class)), diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml index 39fc626017e..852fec11a81 100644 --- a/app/src/main/res/values/style.xml +++ b/app/src/main/res/values/style.xml @@ -62,17 +62,24 @@ + + - -