From 67e03db3d44e610f5506c1f645a9c9197ee4a03e Mon Sep 17 00:00:00 2001
From: Nicolas Pomepuy <nicolas@videolabs.io>
Date: Wed, 2 Apr 2025 14:04:53 +0200
Subject: [PATCH] Add the incognito mode on TV in the settings

---
 .../main/java/org/videolan/television/ui/MainTvFragment.kt | 5 +++++
 .../videolan/television/ui/preferences/PreferencesUi.kt    | 4 ++++
 application/vlc-android/res/xml/preferences_ui.xml         | 7 +++++++
 .../vlc/gui/preferences/PreferenceVisibilityManager.kt     | 4 ++--
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt
index 82568fd1f7..8f6b87be85 100644
--- a/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt
@@ -269,6 +269,11 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
         registerDatasets()
     }
 
+    override fun onResume() {
+        super.onResume()
+        badgeDrawable = ContextCompat.getDrawable(requireContext(), if (Settings.incognitoMode) R.drawable.ic_incognito else R.drawable.icon)
+    }
+
     private fun manageDonationVisibility(donateCard: GenericCardItem) {
         if (activity == null) return
         otherAdapter.remove(donateCard)
diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt
index 433e7c61e4..46046a23c1 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt
@@ -40,6 +40,7 @@ import org.videolan.resources.AppContextProvider
 import org.videolan.television.ui.browser.REQUEST_CODE_RESTART_APP
 import org.videolan.television.ui.dialogs.ConfirmationTvActivity
 import org.videolan.tools.BROWSER_SHOW_HIDDEN_FILES
+import org.videolan.tools.KEY_INCOGNITO
 import org.videolan.tools.KEY_SHOW_HEADERS
 import org.videolan.tools.LocaleUtils
 import org.videolan.tools.PLAYLIST_MODE_VIDEO
@@ -114,6 +115,9 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer
                 Settings.tvUI = sharedPreferences.getBoolean(PREF_TV_UI, false)
                 (activity as PreferencesActivity).setRestartApp()
             }
+            KEY_INCOGNITO -> {
+                Settings.incognitoMode = sharedPreferences.getBoolean(KEY_INCOGNITO, false)
+            }
 
             TV_FOLDERS_FIRST -> Settings.tvFoldersFirst = sharedPreferences.getBoolean(TV_FOLDERS_FIRST, true)
             BROWSER_SHOW_HIDDEN_FILES -> Settings.showHiddenFiles = sharedPreferences.getBoolean(BROWSER_SHOW_HIDDEN_FILES, false)
diff --git a/application/vlc-android/res/xml/preferences_ui.xml b/application/vlc-android/res/xml/preferences_ui.xml
index c6f4baebd6..3a151b0555 100644
--- a/application/vlc-android/res/xml/preferences_ui.xml
+++ b/application/vlc-android/res/xml/preferences_ui.xml
@@ -70,9 +70,16 @@
             android:key="default_sleep_timer"
             android:title="@string/sleep_title"/>
 
+    <CheckBoxPreference
+            app:singleLineTitle="false"
+            android:key="incognito_mode"
+            android:defaultValue="false"
+            android:title="@string/incognito_mode"/>
+
     <CheckBoxPreference
             app:singleLineTitle="false"
             android:key="persistent_incognito"
+            android:dependency="incognito_mode"
             android:defaultValue="true"
             android:summary="@string/persistent_incognito_mode_summary"
             android:title="@string/persistent_incognito_mode"/>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferenceVisibilityManager.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferenceVisibilityManager.kt
index 136daf8904..d3ab707a30 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferenceVisibilityManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferenceVisibilityManager.kt
@@ -34,7 +34,7 @@ import org.videolan.tools.AUDIO_DUCKING
 import org.videolan.tools.BROWSER_SHOW_HIDDEN_FILES
 import org.videolan.tools.KEY_AOUT
 import org.videolan.tools.KEY_APP_THEME
-import org.videolan.tools.KEY_PERSISTENT_INCOGNITO
+import org.videolan.tools.KEY_INCOGNITO
 import org.videolan.tools.KEY_QUICK_PLAY
 import org.videolan.tools.KEY_QUICK_PLAY_DEFAULT
 import org.videolan.tools.LIST_TITLE_ELLIPSIZE
@@ -64,7 +64,7 @@ object PreferenceVisibilityManager {
         //hidden on TV
         KEY_QUICK_PLAY_DEFAULT, KEY_QUICK_PLAY, "secondary_display_category", "secondary_display_category_summary", "enable_clone_mode", SAVE_BRIGHTNESS,
         KEY_APP_THEME, LIST_TITLE_ELLIPSIZE, "enable_headset_detection", "enable_play_on_headset_insertion", "ignore_headset_media_button_presses",
-        "headset_prefs_category", KEY_PERSISTENT_INCOGNITO, "audio_resume_card", LOCKSCREEN_COVER, SHOW_SEEK_IN_COMPACT_NOTIFICATION,
+        "headset_prefs_category", "audio_resume_card", LOCKSCREEN_COVER, SHOW_SEEK_IN_COMPACT_NOTIFICATION,
         "audio_task_removed"-> !forTv
         //only on TV
         TV_FOLDERS_FIRST, BROWSER_SHOW_HIDDEN_FILES, PLAYLIST_MODE_VIDEO, PLAYLIST_MODE_AUDIO -> forTv
-- 
GitLab