Fix keyboard issues

Fix an issue where the keyboard will stay visible even after navigating away from the search UI. May also fix a memory leak, unsure.
This commit is contained in:
OxygenCobalt 2021-01-07 11:26:38 -07:00
parent 6627de4b62
commit e46e9a26c2
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
5 changed files with 188 additions and 83 deletions

View file

@ -1,74 +1,170 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<vector <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="108dp"
android:width="108dp" android:width="108dp"
android:viewportHeight="108" android:height="108dp"
android:viewportWidth="108" android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android"> android:viewportHeight="108">
<path android:fillColor="#111111" <path
android:pathData="M0,0h108v108h-108z"/> android:fillColor="#111111"
<path android:fillColor="#00000000" android:pathData="M9,0L9,108" android:pathData="M0,0h108v108h-108z" />
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> <path
<path android:fillColor="#00000000" android:pathData="M19,0L19,108" android:fillColor="#00000000"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:pathData="M9,0L9,108"
<path android:fillColor="#00000000" android:pathData="M29,0L29,108" android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeColor="#15FFFFFF" />
<path android:fillColor="#00000000" android:pathData="M39,0L39,108" <path
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:fillColor="#00000000"
<path android:fillColor="#00000000" android:pathData="M49,0L49,108" android:pathData="M19,0L19,108"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeWidth="0.8"
<path android:fillColor="#00000000" android:pathData="M59,0L59,108" android:strokeColor="#15FFFFFF" />
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> <path
<path android:fillColor="#00000000" android:pathData="M69,0L69,108" android:fillColor="#00000000"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:pathData="M29,0L29,108"
<path android:fillColor="#00000000" android:pathData="M79,0L79,108" android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeColor="#15FFFFFF" />
<path android:fillColor="#00000000" android:pathData="M89,0L89,108" <path
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:fillColor="#00000000"
<path android:fillColor="#00000000" android:pathData="M99,0L99,108" android:pathData="M39,0L39,108"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeWidth="0.8"
<path android:fillColor="#00000000" android:pathData="M0,9L108,9" android:strokeColor="#15FFFFFF" />
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> <path
<path android:fillColor="#00000000" android:pathData="M0,19L108,19" android:fillColor="#00000000"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:pathData="M49,0L49,108"
<path android:fillColor="#00000000" android:pathData="M0,29L108,29" android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeColor="#15FFFFFF" />
<path android:fillColor="#00000000" android:pathData="M0,39L108,39" <path
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:fillColor="#00000000"
<path android:fillColor="#00000000" android:pathData="M0,49L108,49" android:pathData="M59,0L59,108"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeWidth="0.8"
<path android:fillColor="#00000000" android:pathData="M0,59L108,59" android:strokeColor="#15FFFFFF" />
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> <path
<path android:fillColor="#00000000" android:pathData="M0,69L108,69" android:fillColor="#00000000"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:pathData="M69,0L69,108"
<path android:fillColor="#00000000" android:pathData="M0,79L108,79" android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeColor="#15FFFFFF" />
<path android:fillColor="#00000000" android:pathData="M0,89L108,89" <path
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:fillColor="#00000000"
<path android:fillColor="#00000000" android:pathData="M0,99L108,99" android:pathData="M79,0L79,108"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeWidth="0.8"
<path android:fillColor="#00000000" android:pathData="M19,29L89,29" android:strokeColor="#15FFFFFF" />
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> <path
<path android:fillColor="#00000000" android:pathData="M19,39L89,39" android:fillColor="#00000000"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:pathData="M89,0L89,108"
<path android:fillColor="#00000000" android:pathData="M19,49L89,49" android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeColor="#15FFFFFF" />
<path android:fillColor="#00000000" android:pathData="M19,59L89,59" <path
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:fillColor="#00000000"
<path android:fillColor="#00000000" android:pathData="M19,69L89,69" android:pathData="M99,0L99,108"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeWidth="0.8"
<path android:fillColor="#00000000" android:pathData="M19,79L89,79" android:strokeColor="#15FFFFFF" />
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> <path
<path android:fillColor="#00000000" android:pathData="M29,19L29,89" android:fillColor="#00000000"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:pathData="M0,9L108,9"
<path android:fillColor="#00000000" android:pathData="M39,19L39,89" android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeColor="#15FFFFFF" />
<path android:fillColor="#00000000" android:pathData="M49,19L49,89" <path
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:fillColor="#00000000"
<path android:fillColor="#00000000" android:pathData="M59,19L59,89" android:pathData="M0,19L108,19"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:strokeWidth="0.8"
<path android:fillColor="#00000000" android:pathData="M69,19L69,89" android:strokeColor="#15FFFFFF" />
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> <path
<path android:fillColor="#00000000" android:pathData="M79,19L79,89" android:fillColor="#00000000"
android:strokeColor="#15FFFFFF" android:strokeWidth="0.8"/> android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#15FFFFFF" />
</vector> </vector>

View file

@ -26,7 +26,6 @@ import org.oxycblt.auxio.ui.toColor
/** /**
* The primary "Home" [Fragment] for Auxio. * The primary "Home" [Fragment] for Auxio.
* TODO: Dedicated search tab
*/ */
class MainFragment : Fragment() { class MainFragment : Fragment() {
private val playbackModel: PlaybackViewModel by activityViewModels() private val playbackModel: PlaybackViewModel by activityViewModels()

View file

@ -19,14 +19,13 @@ import org.oxycblt.auxio.detail.DetailViewModel
import org.oxycblt.auxio.library.adapters.LibraryAdapter import org.oxycblt.auxio.library.adapters.LibraryAdapter
import org.oxycblt.auxio.library.adapters.SearchAdapter import org.oxycblt.auxio.library.adapters.SearchAdapter
import org.oxycblt.auxio.logD import org.oxycblt.auxio.logD
import org.oxycblt.auxio.logE
import org.oxycblt.auxio.music.Album import org.oxycblt.auxio.music.Album
import org.oxycblt.auxio.music.Artist import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.BaseModel import org.oxycblt.auxio.music.BaseModel
import org.oxycblt.auxio.music.Genre import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.Header import org.oxycblt.auxio.music.Header
import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.PlaybackViewModel
import org.oxycblt.auxio.settings.SettingsManager
import org.oxycblt.auxio.ui.ActionMenu import org.oxycblt.auxio.ui.ActionMenu
import org.oxycblt.auxio.ui.accent import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.applyColor import org.oxycblt.auxio.ui.applyColor
@ -39,15 +38,10 @@ import org.oxycblt.auxio.ui.toColor
/** /**
* A [Fragment] that shows a custom list of [Genre], [Artist], or [Album] data. Also allows for * A [Fragment] that shows a custom list of [Genre], [Artist], or [Album] data. Also allows for
* search functionality. * search functionality.
* FIXME: Heisenleak when navving from search
* FIXME: Heisenleak on older versions
* TODO: Filtering
*/ */
class LibraryFragment : Fragment(), SearchView.OnQueryTextListener { class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
private val libraryModel: LibraryViewModel by activityViewModels() private val libraryModel: LibraryViewModel by activityViewModels()
private val detailModel: DetailViewModel by activityViewModels() private val detailModel: DetailViewModel by activityViewModels()
private val playbackModel: PlaybackViewModel by activityViewModels()
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
@ -213,6 +207,12 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
libraryModel.updateNavigationStatus(false) libraryModel.updateNavigationStatus(false)
} }
override fun onDestroyView() {
requireView().rootView.clearFocus()
super.onDestroyView()
}
override fun onQueryTextSubmit(query: String): Boolean = false override fun onQueryTextSubmit(query: String): Boolean = false
override fun onQueryTextChange(query: String): Boolean { override fun onQueryTextChange(query: String): Boolean {
@ -235,15 +235,13 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
* @param baseModel The data things should be done with * @param baseModel The data things should be done with
*/ */
private fun onItemSelection(baseModel: BaseModel) { private fun onItemSelection(baseModel: BaseModel) {
// If the item is a song [That was selected through search], then update the playback
// to that song instead of doing any navigation
if (baseModel is Song) { if (baseModel is Song) {
val settingsManager = SettingsManager.getInstance() logE("onItemSelection does not support song")
playbackModel.playSong(baseModel, settingsManager.songPlaybackMode)
return return
} }
requireView().rootView.clearFocus()
if (!libraryModel.isNavigating) { if (!libraryModel.isNavigating) {
libraryModel.updateNavigationStatus(true) libraryModel.updateNavigationStatus(true)

View file

@ -156,6 +156,9 @@ class LibraryViewModel : ViewModel(), SettingsManager.Callback {
return data return data
} }
/**
* Update the current filtering mode.
*/
fun updateFilterMode(@IdRes itemId: Int) { fun updateFilterMode(@IdRes itemId: Int) {
val mode = when (itemId) { val mode = when (itemId) {
R.id.option_filter_all -> DisplayMode.SHOW_ALL R.id.option_filter_all -> DisplayMode.SHOW_ALL
@ -172,6 +175,9 @@ class LibraryViewModel : ViewModel(), SettingsManager.Callback {
} }
} }
/**
* Reset the query.
*/
fun resetQuery() { fun resetQuery() {
mSearchResults.value = listOf() mSearchResults.value = listOf()
} }

View file

@ -161,6 +161,12 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
return binding.root return binding.root
} }
override fun onDestroyView() {
requireView().rootView.clearFocus()
super.onDestroyView()
}
override fun onQueryTextChange(newText: String): Boolean { override fun onQueryTextChange(newText: String): Boolean {
songsModel.doSearch(newText, requireContext()) songsModel.doSearch(newText, requireContext())