[Android] Close the keyboard when a search result is clicked
Nicolas Pomepuy
git at videolan.org
Mon May 9 11:39:03 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri May 6 13:02:58 2022 +0200| [5d935fd0c79ab5a78696555f76cf0755483b7a3d] | committer: Duncan McNamara
Close the keyboard when a search result is clicked
Fixes #2509
> https://code.videolan.org/videolan/vlc-android/commit/5d935fd0c79ab5a78696555f76cf0755483b7a3d
---
.../vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt | 8 ++++++--
.../vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt | 4 ----
.../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt | 5 ++++-
.../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt | 1 +
.../src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt | 2 ++
5 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
index 3dbbd5d9a..9851fcda7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
@@ -45,7 +45,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.snackbar.Snackbar
-import kotlinx.coroutines.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.medialibrary.interfaces.media.Playlist
@@ -240,8 +242,10 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler<Med
if (actionMode != null) {
audioBrowserAdapter.multiSelectHelper.toggleSelection(position)
invalidateActionMode()
- } else
+ } else {
+ if (searchView.visibility == View.VISIBLE) UiTools.setKeyboardVisibility(v, false)
MediaUtils.playTracks(this, viewModel.playlist, position)
+ }
}
override fun onLongClick(v: View, position: Int, item: MediaLibraryItem): Boolean {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
index 86038e02b..4b104dfb4 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
@@ -22,9 +22,7 @@
package org.videolan.vlc.gui
import android.content.Intent
-import android.content.res.Resources
import android.os.Bundle
-import android.util.TypedValue
import android.view.*
import androidx.appcompat.view.ActionMode
import androidx.coordinatorlayout.widget.CoordinatorLayout
@@ -38,7 +36,6 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
-import org.videolan.resources.AppContextProvider
import org.videolan.resources.CTX_PLAY_ALL
import org.videolan.tools.Settings
import org.videolan.tools.dp
@@ -56,7 +53,6 @@ import org.videolan.vlc.gui.view.RecyclerSectionItemGridDecoration
import org.videolan.vlc.media.MediaUtils
import org.videolan.vlc.providers.medialibrary.MedialibraryProvider
import org.videolan.vlc.reloadLibrary
-import org.videolan.vlc.util.Permissions
import org.videolan.vlc.util.getScreenWidth
import org.videolan.vlc.util.onAnyChange
import org.videolan.vlc.viewmodels.mobile.PlaylistsViewModel
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
index 3057dc49d..ef8053ad1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
@@ -41,6 +41,7 @@ import org.videolan.tools.putSingle
import org.videolan.vlc.R
import org.videolan.vlc.gui.ContentActivity
import org.videolan.vlc.gui.PlaylistActivity
+import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.view.FastScroller
import org.videolan.vlc.gui.view.RecyclerSectionItemGridDecoration
import org.videolan.vlc.media.MediaUtils
@@ -212,8 +213,10 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
val i = Intent(activity, PlaylistActivity::class.java)
i.putExtra(AudioBrowserFragment.TAG_ITEM, item)
startActivity(i)
- } else
+ } else {
+ if (inSearchMode()) UiTools.setKeyboardVisibility(v, false)
MediaUtils.openMedia(v.context, item as MediaWrapper)
+ }
}
override fun onCtxAction(position: Int, option: Long) {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index 6b5ac563f..f13b3f214 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -338,6 +338,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
super.onClick(v, position, item)
return
}
+ if (inSearchMode()) UiTools.setKeyboardVisibility(v, false)
if (item.itemType == MediaLibraryItem.TYPE_MEDIA) {
if (item is MediaWrapper && !item.isPresent) {
UiTools.snackerMissing(requireActivity())
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
index e79bbbdf3..f60e7dc4c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
@@ -252,5 +252,7 @@ abstract class MediaBrowserFragment<T : SortableModel> : BaseFragment(), Filtera
searchButtonView.visibility = if (visible) View.VISIBLE else View.GONE
}
+ fun inSearchMode() = searchButtonView.visibility == View.VISIBLE
+
override fun allowedToExpand() = true
}
More information about the Android
mailing list