1
0
Fork 0

Closes #487 - Replace home toolbar icon with tabs icon

master
Emily Kager 2019-02-13 15:19:03 -08:00 committed by Jeff Boek
parent a4a9222a94
commit 06890d0837
5 changed files with 41 additions and 31 deletions

View File

@ -5,6 +5,8 @@
package org.mozilla.fenix.components.toolbar package org.mozilla.fenix.components.toolbar
import android.content.Context import android.content.Context
import android.graphics.PorterDuff
import androidx.core.content.ContextCompat
import androidx.navigation.Navigation import androidx.navigation.Navigation
import mozilla.components.browser.domains.autocomplete.DomainAutocompleteProvider import mozilla.components.browser.domains.autocomplete.DomainAutocompleteProvider
import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.SessionManager
@ -13,11 +15,10 @@ import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.concept.storage.HistoryStorage import mozilla.components.concept.storage.HistoryStorage
import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature
import mozilla.components.feature.toolbar.ToolbarFeature import mozilla.components.feature.toolbar.ToolbarFeature
import org.mozilla.fenix.DefaultThemeManager
import mozilla.components.support.base.feature.LifecycleAwareFeature import mozilla.components.support.base.feature.LifecycleAwareFeature
import org.mozilla.fenix.DefaultThemeManager
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.browser.BrowserFragmentDirections import org.mozilla.fenix.browser.BrowserFragmentDirections
import org.mozilla.fenix.ext.application
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
class ToolbarIntegration( class ToolbarIntegration(
@ -32,19 +33,30 @@ class ToolbarIntegration(
init { init {
toolbar.setMenuBuilder(toolbarMenu.menuBuilder) toolbar.setMenuBuilder(toolbarMenu.menuBuilder)
val home = BrowserToolbar.Button( val tabsIcon = context.getDrawable(R.drawable.ic_tabs)
context.resources tabsIcon?.setColorFilter(
.getDrawable(DefaultThemeManager.resolveAttribute(R.attr.browserToolbarHomeIcon, context), ContextCompat.getColor(
context.application.theme), context,
context.getString(R.string.browser_home_button), DefaultThemeManager.resolveAttribute(R.attr.browserToolbarIcons, context)
visible = { sessionId == null || ), PorterDuff.Mode.SRC_IN
sessionManager.runWithSession(sessionId) { it.isCustomTabSession().not() } } )
) { tabsIcon?.let {
Navigation.findNavController(toolbar) val home = BrowserToolbar.Button(
.navigate(BrowserFragmentDirections.actionBrowserFragmentToHomeFragment()) it,
} context.getString(R.string.browser_home_button),
visible = {
sessionId == null ||
sessionManager.runWithSession(sessionId) {
it.isCustomTabSession().not()
}
}
) {
Navigation.findNavController(toolbar)
.navigate(BrowserFragmentDirections.actionBrowserFragmentToHomeFragment())
}
toolbar.addBrowserAction(home) toolbar.addBrowserAction(home)
}
ToolbarAutocompleteFeature(toolbar).apply { ToolbarAutocompleteFeature(toolbar).apply {
addDomainProvider(domainAutocompleteProvider) addDomainProvider(domainAutocompleteProvider)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,6 +34,5 @@
<attr name="browserToolbarBackground" format="reference"/> <attr name="browserToolbarBackground" format="reference"/>
<attr name="browserToolbarIcons" format="reference"/> <attr name="browserToolbarIcons" format="reference"/>
<attr name="browserToolbarMenuIcons" format="reference"/> <attr name="browserToolbarMenuIcons" format="reference"/>
<attr name="browserToolbarHomeIcon" format="reference"/>
<attr name="navigationBarColorBrowser" format="reference"/> <attr name="navigationBarColorBrowser" format="reference"/>
</resources> </resources>

View File

@ -2,7 +2,7 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public <!-- 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 - 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/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources xmlns:tools="http://schemas.android.com/tools"> <resources>
<style name="LightThemeBase" parent="Theme.AppCompat.Light.NoActionBar"> <style name="LightThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/black</item> <item name="android:statusBarColor">@android:color/black</item>
@ -37,7 +37,6 @@
<item name="browserToolbarBackground">@color/off_white</item> <item name="browserToolbarBackground">@color/off_white</item>
<item name="browserToolbarIcons">@color/icons</item> <item name="browserToolbarIcons">@color/icons</item>
<item name="browserToolbarMenuIcons">@color/icons</item> <item name="browserToolbarMenuIcons">@color/icons</item>
<item name="browserToolbarHomeIcon">@drawable/ic_home</item>
</style> </style>
<style name="LightTheme" parent="LightThemeBase"> <style name="LightTheme" parent="LightThemeBase">
@ -78,7 +77,6 @@
<item name="browserToolbarBackground">@color/private_browsing_top_gradient</item> <item name="browserToolbarBackground">@color/private_browsing_top_gradient</item>
<item name="browserToolbarIcons">@color/off_white</item> <item name="browserToolbarIcons">@color/off_white</item>
<item name="browserToolbarMenuIcons">@color/icons</item> <item name="browserToolbarMenuIcons">@color/icons</item>
<item name="browserToolbarHomeIcon">@drawable/ic_home_white</item>
</style> </style>
<style name="PrivateTheme" parent="PrivateThemeBase"> <style name="PrivateTheme" parent="PrivateThemeBase">