Skip to content

Commit

Permalink
Closes mozilla-mobile#463 - Add attr for home divider color for priva…
Browse files Browse the repository at this point in the history
…te mode theming
  • Loading branch information
ekager committed Feb 13, 2019
1 parent 7531bc5 commit 7782035
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/res/drawable/ic_home_white.xml

This file was deleted.

14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_tabs.xml
Original file line number Diff line number Diff line change
@@ -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>
1 change: 0 additions & 1 deletion app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
4 changes: 1 addition & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 7782035

Please sign in to comment.