From 708ba6d135e08e9712fe74e5270e16844b5b6c15 Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Mon, 22 Jun 2020 16:20:12 -0700 Subject: [PATCH] For #8795: remove redundant ConstraintLayout around BrowserToolbar. This is functionally equivalent to the code before this patch but should be slightly more performant in theory because ConstraintLayout is expensive to inflate. The elevation and layoutParams set dynamically appeared to have no effect with the wrapping view but broke the view when used by itself so I had to remove them. I also updated a few other unnecessary params. Theoretically this may have some perf benefits but I didn't see anything outside noise levels after I took the numbers (but I didn't try very hard). --- .../mozilla/fenix/search/SearchFragment.kt | 2 - .../fenix/search/toolbar/ToolbarView.kt | 10 ----- app/src/main/res/layout/fragment_search.xml | 44 +++++++------------ 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt b/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt index 2190be332bdb..4f5ef089e6f8 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt @@ -294,8 +294,6 @@ class SearchFragment : Fragment(), UserInteractionHandler { view.search_suggestions_onboarding.setOnInflateListener((stubListener)) - view.toolbar_wrapper.clipToOutline = false - fill_link_from_clipboard.setOnClickListener { (activity as HomeActivity) .openToBrowserAndLoad( diff --git a/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt b/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt index bf997e4138e2..31369ed68f53 100644 --- a/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt +++ b/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt @@ -8,7 +8,6 @@ import android.content.Context import android.graphics.Bitmap import android.graphics.drawable.BitmapDrawable import androidx.appcompat.content.res.AppCompatResources -import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.content.ContextCompat import mozilla.components.browser.domains.autocomplete.ShippedDomainsProvider import mozilla.components.browser.toolbar.BrowserToolbar @@ -16,7 +15,6 @@ import mozilla.components.concept.engine.Engine import mozilla.components.concept.storage.HistoryStorage import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature import mozilla.components.support.ktx.android.content.getColorFromAttr -import mozilla.components.support.ktx.android.util.dpToPx import mozilla.components.support.ktx.android.view.hideKeyboard import org.mozilla.fenix.R import org.mozilla.fenix.search.SearchFragmentState @@ -64,8 +62,6 @@ class ToolbarView( view.apply { editMode() - elevation = TOOLBAR_ELEVATION_IN_DP.dpToPx(resources.displayMetrics).toFloat() - setOnUrlCommitListener { // We're hiding the keyboard as early as possible to prevent the engine view // from resizing in case the BrowserFragment is being displayed before the @@ -80,8 +76,6 @@ class ToolbarView( context, ThemeManager.resolveAttribute(R.attr.foundation, context) ) - layoutParams.height = CoordinatorLayout.LayoutParams.MATCH_PARENT - edit.hint = context.getString(R.string.search_hint) edit.colors = edit.colors.copy( @@ -156,8 +150,4 @@ class ToolbarView( view.edit.setIcon(icon, searchState.searchEngineSource.searchEngine.name) } - - companion object { - private const val TOOLBAR_ELEVATION_IN_DP = 16 - } } diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index d9d325649a4f..c2a77fa70aca 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -11,38 +11,24 @@ android:background="?foundation" tools:context=".search.SearchFragment"> - - - - - + app:layout_constraintTop_toTopOf="parent"/> + app:layout_constraintTop_toBottomOf="@id/toolbar">