[Android] Remove the length constraint on audio playlist filter
Nicolas Pomepuy
git at videolan.org
Thu Jun 27 11:17:12 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Jun 13 10:47:42 2019 +0200| [c37280fbdcec3b265a5de539f4b758b3cfeb86db] | committer: Geoffrey Métais
Remove the length constraint on audio playlist filter
> https://code.videolan.org/videolan/vlc-android/commit/c37280fbdcec3b265a5de539f4b758b3cfeb86db
---
vlc-android/res/layout-land/audio_player.xml | 58 +++++++++++++---------
.../src/org/videolan/vlc/gui/audio/AudioPlayer.kt | 8 +--
.../src/org/videolan/vlc/util/FilterDelegate.kt | 2 +-
3 files changed, 39 insertions(+), 29 deletions(-)
diff --git a/vlc-android/res/layout-land/audio_player.xml b/vlc-android/res/layout-land/audio_player.xml
index 7c209834c..022a0c24f 100644
--- a/vlc-android/res/layout-land/audio_player.xml
+++ b/vlc-android/res/layout-land/audio_player.xml
@@ -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>
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index 15ac8ee70..f12172280 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -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 at 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()
}
diff --git a/vlc-android/src/org/videolan/vlc/util/FilterDelegate.kt b/vlc-android/src/org/videolan/vlc/util/FilterDelegate.kt
index efbd032a7..4c7e66d01 100644
--- a/vlc-android/src/org/videolan/vlc/util/FilterDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/util/FilterDelegate.kt
@@ -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()
More information about the Android
mailing list