From b30047804a5cb361372e71bd56f5bb67e06c30c4 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Mon, 27 May 2024 05:58:51 -0500 Subject: [PATCH] feat: setting to hide red dot --- .../ani/dantotsu/download/DownloadsManager.kt | 5 ++-- .../ani/dantotsu/home/AnimePageAdapter.kt | 8 +++---- .../java/ani/dantotsu/home/HomeFragment.kt | 2 ++ .../ani/dantotsu/home/MangaPageAdapter.kt | 5 ++-- .../settings/UserInterfaceSettingsActivity.kt | 4 ++++ .../dantotsu/settings/saving/Preferences.kt | 1 + .../activity_user_interface_settings.xml | 23 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 8 files changed, 41 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt index 11b6ad4c..771684db 100644 --- a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt +++ b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt @@ -349,7 +349,8 @@ class DownloadsManager(private val context: Context) { private fun getBaseDirectory(context: Context): DocumentFile? { val baseDirectory = Uri.parse(PrefManager.getVal(PrefName.DownloadsDir)) if (baseDirectory == Uri.EMPTY) return null - return DocumentFile.fromTreeUri(context, baseDirectory) + val base = DocumentFile.fromTreeUri(context, baseDirectory) ?: return null + return base.findOrCreateFolder(BASE_LOCATION, false) } private val lock = Any() @@ -364,7 +365,7 @@ class DownloadsManager(private val context: Context) { createDirectory(validName) } else { val folder = findFolder(validName) - return folder ?: createDirectory(validName) + folder ?: createDirectory(validName) } } } diff --git a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt index 9c61920b..0f31fca2 100644 --- a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt @@ -111,8 +111,8 @@ class AnimePageAdapter : RecyclerView.Adapter 0) View.VISIBLE else View.GONE + trendingBinding.notificationCount.isVisible = Anilist.unreadNotificationCount > 0 + && PrefManager.getVal(PrefName.ShowNotificationRedDot) == true trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() listOf( @@ -295,8 +295,8 @@ class AnimePageAdapter : RecyclerView.Adapter 0) View.VISIBLE else View.GONE + trendingBinding.notificationCount.isVisible = Anilist.unreadNotificationCount > 0 + && PrefManager.getVal(PrefName.ShowNotificationRedDot) == true trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() } } diff --git a/app/src/main/java/ani/dantotsu/home/HomeFragment.kt b/app/src/main/java/ani/dantotsu/home/HomeFragment.kt index cb541c17..a66506d9 100644 --- a/app/src/main/java/ani/dantotsu/home/HomeFragment.kt +++ b/app/src/main/java/ani/dantotsu/home/HomeFragment.kt @@ -92,6 +92,7 @@ class HomeFragment : Fragment() { ) binding.homeUserDataProgressBar.visibility = View.GONE binding.homeNotificationCount.isVisible = Anilist.unreadNotificationCount > 0 + && PrefManager.getVal(PrefName.ShowNotificationRedDot) == true binding.homeNotificationCount.text = Anilist.unreadNotificationCount.toString() binding.homeAnimeList.setOnClickListener { @@ -511,6 +512,7 @@ class HomeFragment : Fragment() { if (!model.loaded) Refresh.activity[1]!!.postValue(true) if (_binding != null) { binding.homeNotificationCount.isVisible = Anilist.unreadNotificationCount > 0 + && PrefManager.getVal(PrefName.ShowNotificationRedDot) == true binding.homeNotificationCount.text = Anilist.unreadNotificationCount.toString() } super.onResume() diff --git a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt index 2e3e6a8c..2577e3b2 100644 --- a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt @@ -80,6 +80,7 @@ class MangaPageAdapter : RecyclerView.Adapter 0 + && PrefManager.getVal(PrefName.ShowNotificationRedDot) == true trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() trendingBinding.searchBar.hint = "MANGA" trendingBinding.searchBarText.setOnClickListener { @@ -296,8 +297,8 @@ class MangaPageAdapter : RecyclerView.Adapter 0) View.VISIBLE else View.GONE + trendingBinding.notificationCount.isVisible = Anilist.unreadNotificationCount > 0 + && PrefManager.getVal(PrefName.ShowNotificationRedDot) == true trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() } } diff --git a/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt index a33ddb2e..8d1a9582 100644 --- a/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt @@ -65,6 +65,10 @@ class UserInterfaceSettingsActivity : AppCompatActivity() { PrefManager.setVal(PrefName.ImmersiveMode, isChecked) restartApp() } + binding.uiSettingsHideRedDot.isChecked = !PrefManager.getVal(PrefName.ShowNotificationRedDot) + binding.uiSettingsHideRedDot.setOnCheckedChangeListener { _, isChecked -> + PrefManager.setVal(PrefName.ShowNotificationRedDot, !isChecked) + } binding.uiSettingsBannerAnimation.isChecked = PrefManager.getVal(PrefName.BannerAnimations) binding.uiSettingsBannerAnimation.setOnCheckedChangeListener { _, isChecked -> PrefManager.setVal(PrefName.BannerAnimations, isChecked) 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 fe6db422..b4e43ac8 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -82,6 +82,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files MangaListSortOrder(Pref(Location.UI, String::class, "score")), CommentSortOrder(Pref(Location.UI, String::class, "newest")), FollowerLayout(Pref(Location.UI, Int::class, 0)), + ShowNotificationRedDot(Pref(Location.UI, Boolean::class, true)), //Player diff --git a/app/src/main/res/layout/activity_user_interface_settings.xml b/app/src/main/res/layout/activity_user_interface_settings.xml index 071ad499..4a21bb5b 100644 --- a/app/src/main/res/layout/activity_user_interface_settings.xml +++ b/app/src/main/res/layout/activity_user_interface_settings.xml @@ -122,6 +122,29 @@ + + + + Biometric Authentication Use your fingerprint or face to unlock the app Enable Forgot Password (hold clear button for 10 seconds) + Hide Notification Dot