Closes #487 - Replace home toolbar icon with tabs icon

nightly-build-test
Emily Kager 5 years ago committed by Jeff Boek
parent a4a9222a94
commit 06890d0837

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

@ -1,13 +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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m21.457,11.1228 l-8.75,-8.0208c-0.3905,-0.3579 -1.0235,-0.3579 -1.414,0l-8.75,8.0208c-0.379,0.3597 -0.3736,0.9314 0.0122,1.285 0.3857,0.3536 1.0094,0.3586 1.4018,0.0112l1.043,-0.9561v6.9538c0,1.5188 1.3431,2.75 3,2.75h8c1.6569,0 3,-1.2312 3,-2.75v-6.9538l1.043,0.9561c0.3924,0.3474 1.0161,0.3424 1.4018,-0.0112 0.3857,-0.3536 0.3912,-0.9253 0.0122,-1.285zM17,18.4167c0,0.5063 -0.4477,0.9167 -1,0.9167 0.6667,0 0.1667,0 -1.5,0s-3.3333,0 -5,0h-1.5c-0.5523,0 -1,-0.4104 -1,-0.9167v-8.7872l5,-4.5833 5,4.5833z"
android:fillColor="@color/off_white"/>
</vector>

@ -0,0 +1,14 @@
<?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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#202340"
android:fillType="evenOdd"
android:pathData="M15.2222,22L5.7778,22C3.6914,22 2,20.3086 2,18.2222L2,8.7778C2,6.6914 3.6914,5 5.7778,5L15.2222,5C17.3086,5 19,6.6914 19,8.7778L19,18.2222C19,20.3086 17.3086,22 15.2222,22ZM5.8571,7C4.8315,7 4,7.8315 4,8.8571L4,18.1429C4,19.1685 4.8315,20 5.8571,20L15.1429,20C16.1685,20 17,19.1685 17,18.1429L17,8.8571C17,7.8315 16.1685,7 15.1429,7L5.8571,7ZM6,4C6,2.8954 6.8954,2 8,2L15.9866,2C19.3004,2 21.9866,4.6863 21.9866,8C21.9866,8.008 21.9866,8.008 21.9866,8.016L21.9632,16.0027C21.96,17.1073 21.062,18.0003 19.9573,17.9973L19.9866,8.0107L19.9866,8C19.9866,5.7909 18.1958,4 15.9866,4L6,4Z" />
</vector>

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

@ -2,7 +2,7 @@
<!-- 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/. -->
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<style name="LightThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/black</item>
@ -37,7 +37,6 @@
<item name="browserToolbarBackground">@color/off_white</item>
<item name="browserToolbarIcons">@color/icons</item>
<item name="browserToolbarMenuIcons">@color/icons</item>
<item name="browserToolbarHomeIcon">@drawable/ic_home</item>
</style>
<style name="LightTheme" parent="LightThemeBase">
@ -78,7 +77,6 @@
<item name="browserToolbarBackground">@color/private_browsing_top_gradient</item>
<item name="browserToolbarIcons">@color/off_white</item>
<item name="browserToolbarMenuIcons">@color/icons</item>
<item name="browserToolbarHomeIcon">@drawable/ic_home_white</item>
</style>
<style name="PrivateTheme" parent="PrivateThemeBase">

Loading…
Cancel
Save