mirror of
https://github.com/cmclark00/RetroMusicPlayer.git
synced 2025-05-17 23:55:21 +01:00
Add setting to hide search in playlist
This commit is contained in:
parent
b9d3ee6ddb
commit
b74feda9c8
7 changed files with 80 additions and 20 deletions
|
@ -161,4 +161,5 @@ const val CIRCLE_PLAY_BUTTON = "circle_play_button"
|
|||
const val SWIPE_ANYWHERE_NOW_PLAYING = "swipe_anywhere_now_playing"
|
||||
const val PAUSE_HISTORY = "pause_history"
|
||||
const val MANAGE_AUDIO_FOCUS = "manage_audio_focus"
|
||||
const val SWIPE_DOWN_DISMISS = "swipe_to_dismiss"
|
||||
const val SWIPE_DOWN_DISMISS = "swipe_to_dismiss"
|
||||
const val ENABLE_SEARCH_PLAYLIST= "enable_search_playlist"
|
|
@ -107,7 +107,7 @@ class OrderablePlaylistSongAdapter(
|
|||
super.onClick(v)
|
||||
} else {
|
||||
val position = fullDataSet.indexOf(dataSet.get(layoutPosition))
|
||||
MusicPlayerRemote.openQueue(fullDataSet, position, true)
|
||||
MusicPlayerRemote.openQueueKeepShuffleMode(fullDataSet, position, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,4 +167,8 @@ class OrderablePlaylistSongAdapter(
|
|||
}
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun hasSongs(): Boolean {
|
||||
return itemCount > 0 || (filtered && fullDataSet.size > 0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ThemedFastScroller
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
|
@ -79,6 +80,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
// binding.container.transitionName = playlist.playlistEntity.playlistName
|
||||
|
||||
setUpRecyclerView()
|
||||
setUpSearch()
|
||||
setupButtons()
|
||||
viewModel.getPlaylist().observe(viewLifecycleOwner) { playlistWithSongs ->
|
||||
playlist = playlistWithSongs
|
||||
|
@ -120,6 +122,33 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
}
|
||||
}
|
||||
|
||||
private fun setUpSearch() {
|
||||
if (!PreferenceUtil.enableSearchPlaylist) {
|
||||
binding.playlistSearchView.visibility = View.GONE
|
||||
} else {
|
||||
binding.playlistSearchView.visibility = View.VISIBLE
|
||||
}
|
||||
binding.playlistSearchView.addTextChangedListener { text ->
|
||||
lifecycleScope.launch {
|
||||
_searchFlow.emit(text)
|
||||
binding.clearSearch.visibility =
|
||||
if (text.isNullOrBlank()) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
binding.clearSearch.setOnClickListener {
|
||||
lifecycleScope.launch {
|
||||
_searchFlow.emit(null)
|
||||
binding.playlistSearchView.clearText()
|
||||
binding.clearSearch.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
_searchFlow.debounce(300).collect { text ->
|
||||
playlistSongAdapter.onFilter(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpRecyclerView() {
|
||||
playlistSongAdapter = OrderablePlaylistSongAdapter(
|
||||
arguments.extraPlaylistId,
|
||||
|
@ -127,16 +156,6 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
ArrayList(),
|
||||
R.layout.item_queue
|
||||
)
|
||||
binding.playlistSearchView.addTextChangedListener { text ->
|
||||
lifecycleScope.launch {
|
||||
_searchFlow.emit(text)
|
||||
}
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
_searchFlow.debounce(300).collect { text ->
|
||||
playlistSongAdapter.onFilter(text)
|
||||
}
|
||||
}
|
||||
|
||||
val dragDropManager = RecyclerViewDragDropManager()
|
||||
|
||||
|
@ -168,8 +187,18 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
}
|
||||
|
||||
private fun checkIsEmpty() {
|
||||
binding.empty.isVisible = playlistSongAdapter.itemCount == 0
|
||||
binding.emptyText.isVisible = playlistSongAdapter.itemCount == 0
|
||||
if (_binding != null) {
|
||||
if (playlistSongAdapter.itemCount != 0) {
|
||||
binding.empty.isVisible = false
|
||||
} else {
|
||||
binding.empty.isVisible = true
|
||||
if (playlistSongAdapter.hasSongs()) {
|
||||
binding.emptyText.text = getString(R.string.no_search_results)
|
||||
} else {
|
||||
binding.emptyText.text = getString(R.string.no_songs)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
@ -680,6 +680,9 @@ object PreferenceUtil {
|
|||
val rememberLastTab: Boolean
|
||||
get() = sharedPreferences.getBoolean(REMEMBER_LAST_TAB, true)
|
||||
|
||||
val enableSearchPlaylist: Boolean
|
||||
get() = sharedPreferences.getBoolean(ENABLE_SEARCH_PLAYLIST, true)
|
||||
|
||||
var lastTab: Int
|
||||
get() = sharedPreferences
|
||||
.getInt(LAST_USED_TAB, 0)
|
||||
|
|
|
@ -35,16 +35,28 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/play_button"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/clear_search"
|
||||
android:background="@null"
|
||||
android:hint="@string/action_search"
|
||||
android:inputType="text|textAutoComplete"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:padding="12dp"
|
||||
android:textAppearance="@style/TextViewSubtitle1">
|
||||
</com.google.android.material.textfield.TextInputEditText>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/clear_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?roundSelector"
|
||||
android:padding="10dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/playlistSearchView"
|
||||
app:srcCompat="@drawable/ic_close"
|
||||
app:tint="?attr/colorControlNormal"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="0dp"
|
||||
|
@ -131,12 +143,13 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
|
|
|
@ -277,6 +277,7 @@
|
|||
<string name="no_purchase_found">No purchase found.</string>
|
||||
<string name="no_results">No results</string>
|
||||
<string name="no_songs">You have no songs</string>
|
||||
<string name="no_search_results">No search results</string>
|
||||
<string name="normal">Normal</string>
|
||||
<string name="normal_lyrics">Normal lyrics</string>
|
||||
<string name="not_listed_in_media_store"><![CDATA[<b>%s</b> is not listed in the media store.]]></string>
|
||||
|
@ -365,6 +366,7 @@
|
|||
<string name="pref_summary_open_source_licences">License details for open source software</string>
|
||||
<string name="pref_summary_pause_history">When enabled, newly played songs won\'t show in history</string>
|
||||
<string name="pref_summary_remember_tab">Navigate to the last used tab on start</string>
|
||||
<string name="pref_summary_enable_search_playlist">Show a search field in a playlist</string>
|
||||
<string name="pref_summary_show_lyrics">Display synced lyrics over album cover</string>
|
||||
<string name="pref_summary_suggestions">Show New Music Mix on homescreen</string>
|
||||
<string name="pref_summary_swipe_anywhere_now_playing">Enables changing song by swiping anywhere on the now playing screen</string>
|
||||
|
@ -412,6 +414,7 @@
|
|||
<string name="pref_title_open_source_licences">Open source licences</string>
|
||||
<string name="pref_title_pause_history">Pause history</string>
|
||||
<string name="pref_title_remember_tab">Remember last tab</string>
|
||||
<string name="pref_title_enable_search_playlist">Enable search in playlist</string>
|
||||
<string name="pref_title_show_lyrics">Show lyrics</string>
|
||||
<string name="pref_title_suggestions">Show suggestions</string>
|
||||
<string name="pref_title_swipe_anywhere_now_playing">Swipe anywhere to change song</string>
|
||||
|
|
|
@ -67,6 +67,13 @@
|
|||
android:summary="@string/pref_summary_remember_tab"
|
||||
android:title="@string/pref_title_remember_tab" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="enable_search_playlist"
|
||||
android:layout="@layout/list_item_view_switch"
|
||||
android:summary="@string/pref_summary_enable_search_playlist"
|
||||
android:title="@string/pref_title_enable_search_playlist" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_tab_text_mode_titles"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue