Commit e3d5bb79 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Move browser and artists settings in UI

Refs #1041
parent 4944e7e1
......@@ -121,4 +121,26 @@
android:visible="false"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:id="@+id/search_clear_history"/>
<item
android:orderInCategory="3"
android:title="@string/browser_show_all_title"
android:visible="false"
android:checkable="true"
vlc:showAsAction="never"
android:id="@+id/browser_show_all_files" />
<item
android:orderInCategory="3"
android:title="@string/browser_show_hidden_files_title"
android:visible="false"
android:checkable="true"
vlc:showAsAction="never"
android:id="@+id/browser_show_hidden_files" />
<item
android:orderInCategory="3"
android:title="@string/artists_show_all_title"
android:visible="false"
android:checkable="true"
vlc:showAsAction="never"
android:id="@+id/artists_show_all_title" />
</menu>
\ No newline at end of file
......@@ -343,7 +343,6 @@
<string name="popup_keepscreen_title">Keep screen ON in Pop-Up mode</string>
<string name="popup_keepscreen_summary">Always keep screen ON while Pop-Up is displayed, even if video is paused.</string>
<string name="browser_show_hidden_files_title">Show hidden files</string>
<string name="browser_show_hidden_files_summary">Show hidden files in browsers</string>
<string name="subtitles_prefs_category">Subtitles</string>
<string name="subtitles_size_title">Subtitles Size</string>
......@@ -403,7 +402,6 @@
<string name="cast_performance_warning">Casting this video requires conversion. This conversion can use all the available power and could quickly drain your battery.</string>
<string name="casting_connected_renderer">Connected to renderer \'%1$s\'</string>
<string name="artists_show_all_title">Show all artists</string>
<string name="artists_show_all_summary">Show all artists in Artists listing, not only album artists</string>
<string name="extensions_prefs_category">Extensions</string>
<string name="extensions_enable_category">Chose extensions to enable</string>
......@@ -455,8 +453,7 @@
<string name="restart_message">Changes will take effect once application has restarted.\n\nRestart now?</string>
<string name="restart_message_OK">OK</string>
<string name="restart_message_Later">Later</string>
<string name="browser_show_all_title">Show all files in browser</string>
<string name="browser_show_all_summary">Display files that are not recognized as audio or video in browsers</string>
<string name="browser_show_all_title">Show all files</string>
<string name="developer_prefs_category">Developer</string>
<string name="enable_verbose_mode">Verbose</string>
......
......@@ -4,13 +4,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/advanced_prefs_category">
<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="false"
android:key="browser_show_hidden_files"
android:summary="@string/browser_show_hidden_files_summary"
android:title="@string/browser_show_hidden_files_title"/>
<EditTextPreference
android:defaultValue=""
android:key="network_caching"
......
......@@ -24,12 +24,6 @@
android:key="set_locale"
android:title="@string/set_locale"/>
<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="true"
android:key="browser_show_all_files"
android:summary="@string/browser_show_all_summary"
android:title="@string/browser_show_all_title"/>
<ListPreference
android:defaultValue="0"
......@@ -93,11 +87,5 @@
android:key="lockscreen_cover"
android:summary="@string/lockscreen_cover_summary"
android:title="@string/lockscreen_cover_title"/>
<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="false"
android:key="artists_show_all"
android:summary="@string/artists_show_all_summary"
android:title="@string/artists_show_all_title"/>
</PreferenceCategory>
</androidx.preference.PreferenceScreen>
......@@ -256,6 +256,9 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
menu.findItem(R.id.ml_menu_sortby_number).isVisible = false
menu.findItem(R.id.ml_menu_display_grid).isVisible = currentTab in 0..2 && !viewModel.providersInCard[currentTab]
menu.findItem(R.id.ml_menu_display_list).isVisible = currentTab in 0..2 && viewModel.providersInCard[currentTab]
val showAllArtistsItem = menu.findItem(R.id.artists_show_all_title)
showAllArtistsItem.isVisible = currentTab == 0
showAllArtistsItem.isChecked = Settings.getInstance(context).getBoolean(KEY_ARTISTS_SHOW_ALL, false)
}
sortMenuTitles()
}
......@@ -270,6 +273,13 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
Settings.getInstance(requireActivity()).edit().putBoolean(viewModel.displayModeKeys[currentTab], item.itemId == R.id.ml_menu_display_grid).apply()
true
}
R.id.artists_show_all_title -> {
item.isChecked = !Settings.getInstance(requireActivity()).getBoolean(KEY_ARTISTS_SHOW_ALL, true)
Settings.getInstance(requireActivity()).edit().putBoolean(KEY_ARTISTS_SHOW_ALL, item.isChecked).apply()
viewModel.artistsProvider.showAll = item.isChecked
viewModel.refresh()
true
}
else -> super.onOptionsItemSelected(item)
}
}
......
......@@ -111,6 +111,15 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
super.onPrepareOptionsMenu(menu)
menu.findItem(R.id.ml_menu_filter)?.isVisible = enableSearchOption()
menu.findItem(R.id.ml_menu_sortby)?.isVisible = !isRootDirectory
val browserShowAllFiles = menu.findItem(R.id.browser_show_all_files)
browserShowAllFiles.isVisible = true
browserShowAllFiles.isChecked = Settings.getInstance(requireActivity()).getBoolean("browser_show_all_files", true)
val browserShowHiddenFiles = menu.findItem(R.id.browser_show_hidden_files)
browserShowHiddenFiles.isVisible = true
browserShowHiddenFiles.isChecked = Settings.getInstance(requireActivity()).getBoolean("browser_show_hidden_files", true)
}
protected open fun defineIsRoot() = mrl == null
......@@ -372,6 +381,18 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
menu?.let { onPrepareOptionsMenu(it) }
true
}
R.id.browser_show_all_files -> {
item.isChecked = !Settings.getInstance(requireActivity()).getBoolean("browser_show_all_files", true)
Settings.getInstance(requireActivity()).edit().putBoolean("browser_show_all_files", item.isChecked).apply()
viewModel.updateShowAllFiles(item.isChecked)
true
}
R.id.browser_show_hidden_files -> {
item.isChecked = !Settings.getInstance(requireActivity()).getBoolean("browser_show_hidden_files", true)
Settings.getInstance(requireActivity()).edit().putBoolean("browser_show_hidden_files", item.isChecked).apply()
viewModel.updateShowHiddenFiles(item.isChecked)
true
}
else -> super.onOptionsItemSelected(item)
}
}
......
......@@ -51,7 +51,7 @@ const val TAG = "VLC/BrowserProvider"
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<MediaLibraryItem>, val url: String?, private val showHiddenFiles: Boolean) : CoroutineScope, HeaderProvider() {
abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<MediaLibraryItem>, val url: String?, private var showHiddenFiles: Boolean) : CoroutineScope, HeaderProvider() {
override val coroutineContext = Dispatchers.Main.immediate + SupervisorJob()
val loading = MutableLiveData<Boolean>().apply { value = false }
......@@ -61,7 +61,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
private var discoveryJob : Job? = null
private val foldersContentMap = SimpleArrayMap<MediaLibraryItem, MutableList<MediaLibraryItem>>()
private val showAll = Settings.getInstance(context).getBoolean("browser_show_all_files", true)
private var showAll = Settings.getInstance(context).getBoolean("browser_show_all_files", true)
val descriptionUpdate = MutableLiveData<Pair<Int, String>>()
internal val medialibrary = AbstractMedialibrary.getInstance()
......@@ -285,6 +285,16 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
if (url != null) loading.postValue(false)
}
fun updateShowAllFiles(value: Boolean) {
showAll = value
refresh()
}
fun updateShowHiddenFiles(value: Boolean) {
showHiddenFiles = value
refresh()
}
protected fun getList(url: String) = prefetchLists[url]
protected fun removeList(url: String) = prefetchLists.remove(url)
......
......@@ -80,6 +80,14 @@ open class BrowserModel(context: Context, val url: String?, type: Long, showHidd
super.onCleared()
}
fun updateShowAllFiles(value: Boolean) {
provider.updateShowAllFiles(value)
}
fun updateShowHiddenFiles(value: Boolean) {
provider.updateShowHiddenFiles(value)
}
fun addCustomDirectory(path: String) = DirectoryRepository.getInstance(context).addCustomDirectory(path)
fun deleteCustomDirectory(path: String) = DirectoryRepository.getInstance(context).deleteCustomDirectory(path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment