[Android] Add incognito mode to all tabs of bottom navigation bar
Baris unsal
git at videolan.org
Fri Jun 9 10:16:02 UTC 2023
vlc-android | branch: master | Baris unsal <e253436 at metu.edu.tr> | Tue May 30 21:59:23 2023 +0300| [da6b66904b0d2b2832a26ff32b2fe610ef44348e] | committer: Nicolas Pomepuy
Add incognito mode to all tabs of bottom navigation bar
> https://code.videolan.org/videolan/vlc-android/commit/da6b66904b0d2b2832a26ff32b2fe610ef44348e
---
application/resources/src/main/res/values/strings.xml | 1 +
application/tools/src/main/java/org/videolan/tools/Settings.kt | 3 +++
application/vlc-android/res/menu/activity_option.xml | 7 +++++++
application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt | 6 ++++++
.../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 2 ++
5 files changed, 19 insertions(+)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 20d9f3f678..74a9d5d41f 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -805,6 +805,7 @@
<string name="validation_delete_playlist">Are you sure you want to delete this playlist?</string>
<string name="validation_delete_playlist_text">This action cannot be undone.</string>
<string name="display_settings">Display settings</string>
+ <string name="incognito_mode">Incognito mode</string>
<string name="display_in_list">Display in list</string>
<string name="display_in_grid">Display in grid</string>
<string name="dump_db_succes">Database dumped on internal storage root</string>
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index b8b06c439e..b41f205608 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -29,6 +29,7 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicat
var showHiddenFiles = false
var showTrackNumber = true
var tvFoldersFirst = true
+ var incognitoMode = false
private var audioControlsChangeListener: (() -> Unit)? = null
lateinit var device : DeviceInfo
private set
@@ -51,6 +52,7 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicat
showHiddenFiles = prefs.getBoolean(BROWSER_SHOW_HIDDEN_FILES, !tvUI)
showTrackNumber = prefs.getBoolean(ALBUMS_SHOW_TRACK_NUMBER, true)
tvFoldersFirst = prefs.getBoolean(TV_FOLDERS_FIRST, true)
+ incognitoMode = prefs.getBoolean(KEY_INCOGNITO, false)
return prefs
}
@@ -83,6 +85,7 @@ const val KEY_VIDEO_CONFIRM_RESUME = "video_confirm_resume"
const val KEY_MEDIALIBRARY_AUTO_RESCAN = "auto_rescan"
const val KEY_TV_ONBOARDING_DONE = "key_tv_onboarding_done"
const val KEY_INCLUDE_MISSING = "include_missing"
+const val KEY_INCOGNITO = "incognito_mode"
//UI
const val LIST_TITLE_ELLIPSIZE = "list_title_ellipsize"
diff --git a/application/vlc-android/res/menu/activity_option.xml b/application/vlc-android/res/menu/activity_option.xml
index 3de11191fb..798b835d1d 100644
--- a/application/vlc-android/res/menu/activity_option.xml
+++ b/application/vlc-android/res/menu/activity_option.xml
@@ -47,6 +47,13 @@
android:title="@string/display_settings"
vlc:showAsAction="ifRoom|collapseActionView"
android:visible="false"/>
+ <item
+ android:orderInCategory="2"
+ android:id="@+id/incognito_mode"
+ android:title="@string/incognito_mode"
+ android:checkable="true"
+ vlc:showAsAction="never"
+ android:visible="true"/>
<item
android:orderInCategory="3"
android:id="@+id/ml_menu_display_list"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
index f8145665fb..cb8d056b93 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
@@ -175,6 +175,7 @@ class MainActivity : ContentActivity(),
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
menu?.findItem(R.id.ml_menu_refresh)?.isVisible = Permissions.canReadStorage(this)
+ menu?.findItem(R.id.incognito_mode)?.isChecked = Settings.getInstance(this).getBoolean(KEY_INCOGNITO, false)
return super.onPrepareOptionsMenu(menu)
}
@@ -191,6 +192,11 @@ class MainActivity : ContentActivity(),
if (Permissions.canReadStorage(this)) forceRefresh()
true
}
+ R.id.incognito_mode -> {
+ Settings.getInstance (this).putSingle(KEY_INCOGNITO, !Settings.getInstance(this).getBoolean(KEY_INCOGNITO, false))
+ item.isChecked = !item.isChecked
+ true
+ }
android.R.id.home ->
// Slide down the audio player or toggle the sidebar
slideDownAudioPlayer()
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index b42e3ba571..451f13d8f2 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -548,6 +548,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
val titleIdx = player.getTitleIdx()
val currentMedia = getCurrentMedia() ?: return at outerLaunch
if (currentMedia.uri.scheme.isSchemeFD()) return at outerLaunch
+ if (Settings.getInstance(AppContextProvider.appContext).getBoolean(KEY_INCOGNITO, false)) return at outerLaunch
//Save progress
val time = player.mediaplayer.time
val length = player.getLength()
@@ -1115,6 +1116,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
private suspend fun savePlaycount(mw: MediaWrapper) {
+ if (Settings.getInstance(AppContextProvider.appContext).getBoolean(KEY_INCOGNITO, false)) return
var currentMedia = mw
if (settings.getBoolean(PLAYBACK_HISTORY, true) && !mw.uri.scheme.isSchemeFD()) withContext(Dispatchers.IO) {
var id = mw.id
More information about the Android
mailing list