parent
9269a53b21
commit
988513aa89
|
@ -128,18 +128,19 @@ class SearchFragment : Fragment(), UserInteractionHandler {
|
||||||
searchController
|
searchController
|
||||||
)
|
)
|
||||||
|
|
||||||
awesomeBarView = AwesomeBarView(view.scrollable_area, searchInteractor)
|
awesomeBarView = AwesomeBarView(view.scrollable_area, searchInteractor,
|
||||||
|
view.findViewById(R.id.awesomeBar))
|
||||||
view.scrollView.setOnScrollChangeListener {
|
view.scrollView.setOnScrollChangeListener {
|
||||||
_: NestedScrollView, _: Int, _: Int, _: Int, _: Int ->
|
_: NestedScrollView, _: Int, _: Int, _: Int, _: Int ->
|
||||||
view.hideKeyboard()
|
view.hideKeyboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbarView = ToolbarView(
|
toolbarView = ToolbarView(
|
||||||
view.toolbar_component_wrapper,
|
requireContext(),
|
||||||
searchInteractor,
|
searchInteractor,
|
||||||
historyStorageProvider(),
|
historyStorageProvider(),
|
||||||
isPrivate,
|
isPrivate,
|
||||||
|
view.toolbar,
|
||||||
requireComponents.core.engine
|
requireComponents.core.engine
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,11 @@
|
||||||
|
|
||||||
package org.mozilla.fenix.search.awesomebar
|
package org.mozilla.fenix.search.awesomebar
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.content.res.AppCompatResources.getDrawable
|
import androidx.appcompat.content.res.AppCompatResources.getDrawable
|
||||||
import androidx.core.graphics.BlendModeColorFilterCompat.createBlendModeColorFilterCompat
|
import androidx.core.graphics.BlendModeColorFilterCompat.createBlendModeColorFilterCompat
|
||||||
import androidx.core.graphics.BlendModeCompat.SRC_IN
|
import androidx.core.graphics.BlendModeCompat.SRC_IN
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
|
||||||
import mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
import mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
||||||
import mozilla.components.browser.search.SearchEngine
|
import mozilla.components.browser.search.SearchEngine
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
|
@ -82,14 +79,9 @@ interface AwesomeBarInteractor {
|
||||||
*/
|
*/
|
||||||
class AwesomeBarView(
|
class AwesomeBarView(
|
||||||
private val container: ViewGroup,
|
private val container: ViewGroup,
|
||||||
val interactor: AwesomeBarInteractor
|
val interactor: AwesomeBarInteractor,
|
||||||
) : LayoutContainer {
|
val view: BrowserAwesomeBar
|
||||||
val view: BrowserAwesomeBar = LayoutInflater.from(container.context)
|
) {
|
||||||
.inflate(R.layout.component_awesomebar, container, true)
|
|
||||||
.findViewById(R.id.awesomeBar)
|
|
||||||
|
|
||||||
override val containerView: View?
|
|
||||||
get() = container
|
|
||||||
|
|
||||||
private val sessionProvider: SessionSuggestionProvider
|
private val sessionProvider: SessionSuggestionProvider
|
||||||
private val historyStorageProvider: HistoryStorageSuggestionProvider
|
private val historyStorageProvider: HistoryStorageSuggestionProvider
|
||||||
|
|
|
@ -4,16 +4,12 @@
|
||||||
|
|
||||||
package org.mozilla.fenix.search.toolbar
|
package org.mozilla.fenix.search.toolbar
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.annotation.LayoutRes
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
|
||||||
import mozilla.components.browser.domains.autocomplete.ShippedDomainsProvider
|
import mozilla.components.browser.domains.autocomplete.ShippedDomainsProvider
|
||||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
import mozilla.components.browser.toolbar.BrowserToolbar
|
||||||
import mozilla.components.concept.engine.Engine
|
import mozilla.components.concept.engine.Engine
|
||||||
|
@ -23,7 +19,6 @@ import mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||||
import mozilla.components.support.ktx.android.util.dpToPx
|
import mozilla.components.support.ktx.android.util.dpToPx
|
||||||
import mozilla.components.support.ktx.android.view.hideKeyboard
|
import mozilla.components.support.ktx.android.view.hideKeyboard
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.settings
|
|
||||||
import org.mozilla.fenix.search.SearchFragmentState
|
import org.mozilla.fenix.search.SearchFragmentState
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
|
|
||||||
|
@ -55,27 +50,13 @@ interface ToolbarInteractor {
|
||||||
* View that contains and configures the BrowserToolbar to only be used in its editing mode.
|
* View that contains and configures the BrowserToolbar to only be used in its editing mode.
|
||||||
*/
|
*/
|
||||||
class ToolbarView(
|
class ToolbarView(
|
||||||
private val container: ViewGroup,
|
private val context: Context,
|
||||||
private val interactor: ToolbarInteractor,
|
private val interactor: ToolbarInteractor,
|
||||||
private val historyStorage: HistoryStorage?,
|
private val historyStorage: HistoryStorage?,
|
||||||
private val isPrivate: Boolean,
|
private val isPrivate: Boolean,
|
||||||
|
val view: BrowserToolbar,
|
||||||
engine: Engine
|
engine: Engine
|
||||||
) : LayoutContainer {
|
) {
|
||||||
|
|
||||||
override val containerView: View?
|
|
||||||
get() = container
|
|
||||||
|
|
||||||
private val settings = container.context.settings()
|
|
||||||
|
|
||||||
@LayoutRes
|
|
||||||
private val toolbarLayout = when {
|
|
||||||
settings.shouldUseBottomToolbar -> R.layout.component_bottom_browser_toolbar
|
|
||||||
else -> R.layout.component_browser_top_toolbar
|
|
||||||
}
|
|
||||||
|
|
||||||
val view: BrowserToolbar = LayoutInflater.from(container.context)
|
|
||||||
.inflate(toolbarLayout, container, true)
|
|
||||||
.findViewById(R.id.toolbar)
|
|
||||||
|
|
||||||
private var isInitialized = false
|
private var isInitialized = false
|
||||||
private var hasBeenCanceled = false
|
private var hasBeenCanceled = false
|
||||||
|
@ -97,7 +78,7 @@ class ToolbarView(
|
||||||
|
|
||||||
background =
|
background =
|
||||||
AppCompatResources.getDrawable(
|
AppCompatResources.getDrawable(
|
||||||
container.context, ThemeManager.resolveAttribute(R.attr.foundation, context)
|
context, ThemeManager.resolveAttribute(R.attr.foundation, context)
|
||||||
)
|
)
|
||||||
|
|
||||||
layoutParams.height = CoordinatorLayout.LayoutParams.MATCH_PARENT
|
layoutParams.height = CoordinatorLayout.LayoutParams.MATCH_PARENT
|
||||||
|
@ -105,17 +86,17 @@ class ToolbarView(
|
||||||
edit.hint = context.getString(R.string.search_hint)
|
edit.hint = context.getString(R.string.search_hint)
|
||||||
|
|
||||||
edit.colors = edit.colors.copy(
|
edit.colors = edit.colors.copy(
|
||||||
text = container.context.getColorFromAttr(R.attr.primaryText),
|
text = context.getColorFromAttr(R.attr.primaryText),
|
||||||
hint = container.context.getColorFromAttr(R.attr.secondaryText),
|
hint = context.getColorFromAttr(R.attr.secondaryText),
|
||||||
suggestionBackground = ContextCompat.getColor(
|
suggestionBackground = ContextCompat.getColor(
|
||||||
container.context,
|
context,
|
||||||
R.color.suggestion_highlight_color
|
R.color.suggestion_highlight_color
|
||||||
),
|
),
|
||||||
clear = container.context.getColorFromAttr(R.attr.primaryText)
|
clear = context.getColorFromAttr(R.attr.primaryText)
|
||||||
)
|
)
|
||||||
|
|
||||||
edit.setUrlBackground(
|
edit.setUrlBackground(
|
||||||
AppCompatResources.getDrawable(container.context, R.drawable.search_url_background))
|
AppCompatResources.getDrawable(context, R.drawable.search_url_background))
|
||||||
|
|
||||||
private = isPrivate
|
private = isPrivate
|
||||||
|
|
||||||
|
@ -163,7 +144,7 @@ class ToolbarView(
|
||||||
isInitialized = true
|
isInitialized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
val iconSize = container.resources.getDimensionPixelSize(R.dimen.preference_icon_drawable_size)
|
val iconSize = context.resources.getDimensionPixelSize(R.dimen.preference_icon_drawable_size)
|
||||||
|
|
||||||
val scaledIcon = Bitmap.createScaledBitmap(
|
val scaledIcon = Bitmap.createScaledBitmap(
|
||||||
searchState.searchEngineSource.searchEngine.icon,
|
searchState.searchEngineSource.searchEngine.icon,
|
||||||
|
@ -171,7 +152,7 @@ class ToolbarView(
|
||||||
iconSize,
|
iconSize,
|
||||||
true)
|
true)
|
||||||
|
|
||||||
val icon = BitmapDrawable(container.resources, scaledIcon)
|
val icon = BitmapDrawable(context.resources, scaledIcon)
|
||||||
|
|
||||||
view.edit.setIcon(icon, searchState.searchEngineSource.searchEngine.name)
|
view.edit.setIcon(icon, searchState.searchEngineSource.searchEngine.name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
||||||
<mozilla.components.browser.awesomebar.BrowserAwesomeBar xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:mozac="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/awesomeBar"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:fadingEdge="horizontal"
|
|
||||||
android:fadingEdgeLength="40dp"
|
|
||||||
android:nestedScrollingEnabled="false"
|
|
||||||
android:requiresFadingEdge="vertical"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/search_with_shortcuts"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
mozac:awesomeBarDescriptionTextColor="?secondaryText"
|
|
||||||
mozac:awesomeBarTitleTextColor="?primaryText" />
|
|
|
@ -21,14 +21,26 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<FrameLayout
|
<mozilla.components.browser.toolbar.BrowserToolbar
|
||||||
android:id="@+id/toolbar_component_wrapper"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="@dimen/browser_toolbar_height"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:background="@drawable/toolbar_background_top"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways|snap|exitUntilCollapsed"
|
||||||
|
app:browserToolbarClearColor="?primaryText"
|
||||||
|
app:browserToolbarInsecureColor="?primaryText"
|
||||||
|
app:browserToolbarMenuColor="?primaryText"
|
||||||
|
app:browserToolbarProgressBarGravity="bottom"
|
||||||
|
app:browserToolbarSecureColor="?primaryText"
|
||||||
|
app:browserToolbarTrackingProtectionAndSecurityIndicatorSeparatorColor="?toolbarDivider"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
@ -45,7 +57,20 @@
|
||||||
android:id="@+id/scrollable_area"
|
android:id="@+id/scrollable_area"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
<mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
||||||
|
xmlns:mozac="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/awesomeBar"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fadingEdge="horizontal"
|
||||||
|
android:fadingEdgeLength="40dp"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
android:requiresFadingEdge="vertical"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/search_with_shortcuts"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
mozac:awesomeBarDescriptionTextColor="?secondaryText"
|
||||||
|
mozac:awesomeBarTitleTextColor="?primaryText" />
|
||||||
<ViewStub
|
<ViewStub
|
||||||
android:id="@+id/search_suggestions_onboarding"
|
android:id="@+id/search_suggestions_onboarding"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue