Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix Search View Width #12096

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import android.view.ViewGroup
import android.widget.ImageView
import androidx.annotation.VisibleForTesting
import androidx.appcompat.widget.SearchView
import androidx.core.view.MenuItemCompat
import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
Expand Down Expand Up @@ -89,7 +88,7 @@ class UnifiedSearchFragment : Fragment(), Injectable, UnifiedSearchListInterface

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
vm = ViewModelProvider(this, vmFactory).get(UnifiedSearchViewModel::class.java)
vm = ViewModelProvider(this, vmFactory)[UnifiedSearchViewModel::class.java]
setUpViewModel()

val query = savedInstanceState?.getString(ARG_QUERY) ?: arguments?.getString(ARG_QUERY)
Expand Down Expand Up @@ -125,7 +124,7 @@ class UnifiedSearchFragment : Fragment(), Injectable, UnifiedSearchListInterface
binding.emptyList.emptyListViewText.text =
requireContext().getString(R.string.file_list_empty_unified_search_no_results)
binding.emptyList.emptyListIcon.setImageDrawable(
viewThemeUtils.platform.tintPrimaryDrawable(requireContext(), R.drawable.ic_search_grey)
viewThemeUtils.platform.tintDrawable(requireContext(), R.drawable.ic_search_grey)
)
}
}
Expand All @@ -151,10 +150,12 @@ class UnifiedSearchFragment : Fragment(), Injectable, UnifiedSearchListInterface
}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@Suppress("DEPRECATION")
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = ListFragmentBinding.inflate(inflater, container, false)
binding.listRoot.updatePadding(top = resources.getDimension(R.dimen.standard_half_padding).toInt())
setUpBinding()

setHasOptionsMenu(true)
return binding.root
}
Expand Down Expand Up @@ -223,8 +224,14 @@ class UnifiedSearchFragment : Fragment(), Injectable, UnifiedSearchListInterface
@Deprecated("Deprecated in Java")
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
val item = menu.findItem(R.id.action_search)
searchView = MenuItemCompat.getActionView(item) as SearchView
searchView = item.actionView as SearchView?

// Required to align with TextView width.
// Because this fragment is opened with TextView onClick on the previous screen
searchView?.maxWidth = Integer.MAX_VALUE

viewThemeUtils.androidx.themeToolbarSearchView(searchView!!)

searchView?.setQuery(vm.query.value, false)
searchView?.setOnQueryTextListener(this)
searchView?.isIconified = false
Expand Down
Loading