Skip to content

Commit

Permalink
Remove "fitsSystemWindows" from the coordinatorlayout (it's on the ap…
Browse files Browse the repository at this point in the history
…pbarlayout).

This means we can remove the workaround for the searchview being covered by the status bar.
  • Loading branch information
caarmen committed Jan 5, 2025
1 parent 32b4e0e commit 86669d7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import android.app.Activity
import android.app.SearchManager
import android.content.ContentValues
import android.util.Log
import android.view.View
import androidx.annotation.MainThread
import androidx.lifecycle.viewModelScope
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -69,12 +68,8 @@ class Search constructor(private val searchableActivity: Activity, private val v
}

fun setSearchView(searchView: SearchView, suggestionsViewModel: SuggestionsViewModel) {
// Workaround 1: On older versions (not sure which ones) of Android, the SearchView is partially
// covered by the status bar, unless we make this spacer view visible:
searchView.findViewById<View>(R.id.open_search_view_status_bar_spacer).visibility = View.VISIBLE

searchView.hint =
searchableActivity.getString(R.string.search_hint) // Workaround 2: To hopefully prevent some crashes (!!) :(
searchableActivity.getString(R.string.search_hint) // To hopefully prevent some crashes (!!) :(
// Step 1: Setup suggestions
val suggestionsList: RecyclerView = searchView.findViewById(R.id.search_suggestions_list)
val adapter = SuggestionsAdapter()
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".main.MainActivity">

<androidx.viewpager.widget.ViewPager
Expand Down

0 comments on commit 86669d7

Please sign in to comment.