Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Closes #1397: Add custom tab toolbar color support.. #1654

Merged
merged 2 commits into from
Jan 7, 2019

Conversation

jonalmeida
Copy link
Contributor

I ended up finishing most of the requirements for a custom tabs toolbar in mozilla-mobile/reference-browser#209 all at once. This PR only contains the minimum required for setting up the feature and toolbar background color, the rest will come through in a follow up PR when I'm done writing tests for them.

@jonalmeida jonalmeida requested a review from a team as a code owner January 7, 2019 07:32
/**
* Initializes and resets the Toolbar for a Custom Tab based on the CustomTabConfig.
*/
class CustomTabToolbarFeature(
Copy link
Contributor Author

@jonalmeida jonalmeida Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be CustomTabs.

Will fill in the follow up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why hold back? :D

Copy link
Contributor Author

@jonalmeida jonalmeida Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can only do one rain dance a day to get a green build. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know what, I'm going to do this now because I want to add it to the changelog as well. I'd rather not change class names after.

@jonalmeida jonalmeida changed the title Closes #1397: Add custom tab toolbar color support Closes #1397: Add custom tab toolbar color support. Jan 7, 2019
@codecov
Copy link

codecov bot commented Jan 7, 2019

Codecov Report

Merging #1654 into master will increase coverage by 0.05%.
The diff coverage is 94.11%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1654      +/-   ##
============================================
+ Coverage     82.41%   82.46%   +0.05%     
- Complexity     1792     1802      +10     
============================================
  Files           219      220       +1     
  Lines          7095     7113      +18     
  Branches       1223     1224       +1     
============================================
+ Hits           5847     5866      +19     
  Misses          662      662              
+ Partials        586      585       -1
Impacted Files Coverage Δ Complexity Δ
...lla/components/feature/toolbar/ToolbarPresenter.kt 61.11% <ø> (+6.11%) 9 <0> (ø) ⬇️
...nts/feature/customtabs/CustomTabsToolbarFeature.kt 94.11% <94.11%> (ø) 8 <8> (?)
...illa/components/service/glean/CounterMetricType.kt 94.11% <0%> (+1.26%) 10% <0%> (+2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c2a47e...d8aaadc. Read the comment docs.

Copy link
Contributor

@pocmo pocmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

class CustomTabToolbarFeature(
private val sessionManager: SessionManager,
private val toolbar: BrowserToolbar,
private val sessionId: String? = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory a custom tab should always have a session id. But I guess it's easier to implement that way? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should! Although we tend to get the sessionId from the Bundle which makes the ID optional. So yeah, it's easier this way. :)

// Magic weighting taken from a stackoverflow post, supposedly related to how
// humans perceive color.
return (0.299 * red + 0.587 * green + 0.114 * blue).toInt()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what a good pattern is.. I usually move those helpers outside the class as private methods inside the file (since they are somewhat unrelated to the class).

/**
* Initializes and resets the Toolbar for a Custom Tab based on the CustomTabConfig.
*/
class CustomTabToolbarFeature(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why hold back? :D

@jonalmeida jonalmeida changed the title Closes #1397: Add custom tab toolbar color support. Closes #1397: Add custom tab toolbar color support.. Jan 7, 2019
@jonalmeida jonalmeida merged commit f120306 into mozilla-mobile:master Jan 7, 2019
@jonalmeida jonalmeida deleted the issue-1397 branch January 7, 2019 21:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants