Skip to content
Snippets Groups Projects
Commit c37280fb authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Remove the length constraint on audio playlist filter

parent 00c5c1d1
No related branches found
No related tags found
1 merge request!144Audio playlist search
Pipeline #7789 passed with stage
in 3 minutes and 41 seconds
......@@ -76,26 +76,35 @@
android:src="?attr/ic_playasaudio_off" />
<org.videolan.vlc.gui.view.HeaderMediaSwitcher
android:id="@+id/audio_media_switcher"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@+id/playlist_playasaudio_off"
app:layout_constraintEnd_toStartOf="@+id/barrier"
android:background="#00000000" />
android:id="@+id/audio_media_switcher"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@+id/playlist_playasaudio_off"
app:layout_constraintEnd_toStartOf="@+id/barrier"
android:background="#00000000"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/playlist_search_text"
android:layout_marginEnd="2dp"
android:focusable="true"
android:visibility="gone">
<EditText
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/search_hint"
android:inputType="textFilter"
android:imeOptions="actionSearch"/>
android:id="@+id/playlist_search_text"
android:focusable="true"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintEnd_toEndOf="@+id/header_play_pause"
app:layout_constraintStart_toEndOf="@+id/playlist_playasaudio_off"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search_hint"
android:inputType="textFilter"
android:imeOptions="actionSearch"/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
......@@ -167,13 +176,14 @@
android:onLongClick="@{fragment::onStopClick}" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:barrierDirection="start"
app:constraint_referenced_ids="header_time, playlist_ab_repeat"/>
android:id="@+id/barrier"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:barrierDirection="start"
app:constraint_referenced_ids="header_time,playlist_search"
tools:layout_editor_absoluteX="609dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
......
......@@ -315,7 +315,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, CoroutineS
}
override fun onSelectionSet(position: Int) {
if (playerState != com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED && playerState != com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HIDDEN) {
if (playerState != BottomSheetBehavior.STATE_COLLAPSED && playerState != com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HIDDEN) {
binding.songsList.scrollToPosition(position)
}
}
......@@ -455,17 +455,17 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, CoroutineS
addTextChangedListener(this@AudioPlayer)
}
UiTools.setKeyboardVisibility(binding.playlistSearchText, false)
if (playerState == com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED) setHeaderVisibilities(false, false, true, true, true, false)
if (playerState == BottomSheetBehavior.STATE_COLLAPSED) setHeaderVisibilities(false, false, true, true, true, false)
else setHeaderVisibilities(true, true, false, false, false, true)
return true
}
override fun onTextChanged(charSequence: CharSequence, start: Int, before: Int, count: Int) {
val length = charSequence.length
if (length > 1) {
if (length > 0) {
playlistModel.filter(charSequence)
handler.removeCallbacks(hideSearchRunnable)
} else if (length == 0) {
} else {
playlistModel.filter(null)
hideSearchField()
}
......
......@@ -50,7 +50,7 @@ class PlaylistFilterDelegate(dataset: MutableLiveData<out List<MediaWrapper>>) :
override suspend fun filteringJob(charSequence: CharSequence?): MutableList<MediaWrapper>? {
if (charSequence !== null) initSource()?.let { list ->
return withContext(Dispatchers.Default) { mutableListOf<MediaWrapper>().apply {
val queryStrings = charSequence.trim().toString().split(" ").asSequence().filter { it.length > 2 }.map { it.toLowerCase() }.toList()
val queryStrings = charSequence.trim().toString().split(" ").asSequence().filter { it.isNotEmpty() }.map { it.toLowerCase() }.toList()
for (media in list) {
val title = MediaUtils.getMediaTitle(media).toLowerCase()
val location = media.location.toLowerCase()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment