diff --git a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt index 81fe60c9e7a..f8c44eeef54 100644 --- a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt +++ b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt @@ -310,10 +310,17 @@ class BrowserToolbar @JvmOverloads constructor( } /** - * Adds an action to be displayed on the right of the URL in edit mode. + * Adds an action to be displayed at the start of the URL in edit mode. */ - override fun addEditAction(action: Toolbar.Action) { - edit.addEditAction(action) + override fun addEditActionStart(action: Toolbar.Action) { + edit.addEditActionStart(action) + } + + /** + * Adds an action to be displayed at the end of the URL in edit mode. + */ + override fun addEditActionEnd(action: Toolbar.Action) { + edit.addEditActionEnd(action) } /** diff --git a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/edit/EditToolbar.kt b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/edit/EditToolbar.kt index 0a0b33b9777..4fbe60a81dd 100644 --- a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/edit/EditToolbar.kt +++ b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/edit/EditToolbar.kt @@ -40,13 +40,16 @@ private const val AUTOCOMPLETE_QUERY_THREADS = 3 * Sub-component of the browser toolbar responsible for allowing the user to edit the URL ("edit mode"). * * Structure: - * +------+---------------------------+---------+------+ - * | icon | url | actions | exit | - * +------+---------------------------+---------+------+ + * +------+--------------------+---------------------------+------------------+------+ + * | icon | edit actions start | url | edit actions end | exit | + * +------+--------------------+---------------------------+------------------+------+ * * - icon: Optional icon that will be shown in front of the URL. - * - url: Editable URL of the currently displayed website - * - actions: Optional action icons injected by other components (e.g. barcode scanner) + * - edit actions start: Optional action icons injected by other components in front of the URL + * (e.g. search engines). + * - url: Editable URL of the currently displayed website. + * - edit actions end: Optional action icons injected by other components after the URL + * (e.g. barcode scanner). * - exit: Button that switches back to display mode or invoke an app-defined callback. */ @Suppress("LargeClass") @@ -87,9 +90,10 @@ class EditToolbar internal constructor( @VisibleForTesting(otherwise = PRIVATE) internal val views = EditToolbarViews( - background = rootView.findViewById(R.id.mozac_browser_toolbar_background), - icon = rootView.findViewById(R.id.mozac_browser_toolbar_edit_icon), - editActions = rootView.findViewById(R.id.mozac_browser_toolbar_edit_actions), + background = rootView.findViewById(R.id.mozac_browser_toolbar_background), + icon = rootView.findViewById(R.id.mozac_browser_toolbar_edit_icon), + editActionsStart = rootView.findViewById(R.id.mozac_browser_toolbar_edit_actions_start), + editActionsEnd = rootView.findViewById(R.id.mozac_browser_toolbar_edit_actions_end), clear = rootView.findViewById(R.id.mozac_browser_toolbar_clear_view).apply { setOnClickListener { onClear() @@ -232,11 +236,16 @@ class EditToolbar internal constructor( } internal fun invalidateActions() { - views.editActions.invalidateActions() + views.editActionsStart.invalidateActions() + views.editActionsEnd.invalidateActions() } - internal fun addEditAction(action: Toolbar.Action) { - views.editActions.addAction(action) + internal fun addEditActionStart(action: Toolbar.Action) { + views.editActionsStart.addAction(action) + } + + internal fun addEditActionEnd(action: Toolbar.Action) { + views.editActionsEnd.addAction(action) } /** @@ -327,7 +336,8 @@ class EditToolbar internal constructor( internal class EditToolbarViews( val background: ImageView, val icon: ImageView, - val editActions: ActionContainer, + val editActionsStart: ActionContainer, + val editActionsEnd: ActionContainer, val clear: ImageView, val url: InlineAutocompleteEditText ) diff --git a/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_edittoolbar.xml b/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_edittoolbar.xml index 6b269b9820f..dfe586e82ec 100644 --- a/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_edittoolbar.xml +++ b/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_edittoolbar.xml @@ -36,6 +36,16 @@ tools:ignore="ContentDescription" android:layout_marginTop="8dp" /> + +