Skip to content

Commit 5ef80fb

Browse files
authored
Custom tabs: Ship review feedback changes (#7244)
Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1212210662052777 ### Description This PR makes the following changes to the new custom tab UI: - In the Find In Page input box, it uses the "address bar" color - Makes a small adjustment to the dark version of the custom color address bar - Adds pixels to track the "address bar" clicks on the custom tab ### Steps to test this PR _Find In Page_ - [x] Open the new custom tab from the developer settings (Pick some color using the color picker) - [x] Tap on the menu and select Find in page - [x] Verify the search box uses the same color as the custom tab "address bar" _Address bar clicks_ - [x] Open the new custom tab from the developer settings - [x] Tap on the "address bar" part (not the shield) - [x] Verify the `m_custom_tabs_address_bar_clicked` pixel is fired - [x] Verify the `m_custom_tabs_address_bar_clicked_daily` pixel is fired once
1 parent fb4b680 commit 5ef80fb

File tree

4 files changed

+78
-22
lines changed

4 files changed

+78
-22
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// See https://app.asana.com/1/137249556945/project/488551667048375/task/1212210662052777?focus=true
2+
{
3+
"m_custom_tabs_address_bar_clicked": {
4+
"description": "When a user clicks the 'address bar' part of the custom tab, the pixel is fired.",
5+
"owners": ["0nko"],
6+
"triggers": ["other"],
7+
"suffixes": ["first_daily_count", "form_factor"],
8+
"parameters": ["appVersion", "atb"],
9+
"expires": "2026-01-05"
10+
}
11+
}

app/src/main/java/com/duckduckgo/app/browser/customtabs/CustomTabPixelNames.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ enum class CustomTabPixelNames(override val pixelName: String) : Pixel.PixelName
2626
CUSTOM_TABS_OPEN_IN_DDG("m_custom_tabs_open_in_ddg"),
2727
CUSTOM_TABS_MENU_DISABLE_PROTECTIONS_ALLOW_LIST_ADD("m_custom_tabs_menu_disable_protections_allow_list_add"),
2828
CUSTOM_TABS_MENU_DISABLE_PROTECTIONS_ALLOW_LIST_REMOVE("m_custom_tabs_menu_disable_protections_allow_list_remove"),
29+
CUSTOM_TABS_ADDRESS_BAR_CLICKED("m_custom_tabs_address_bar_clicked"),
30+
CUSTOM_TABS_ADDRESS_BAR_CLICKED_DAILY("m_custom_tabs_address_bar_clicked_daily"),
2931
}

app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayout.kt

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import androidx.core.transition.doOnEnd
4646
import androidx.core.view.doOnLayout
4747
import androidx.core.view.isGone
4848
import androidx.core.view.isInvisible
49+
import androidx.core.view.isNotEmpty
4950
import androidx.core.view.isVisible
5051
import androidx.core.view.updateLayoutParams
5152
import androidx.lifecycle.LifecycleOwner
@@ -63,6 +64,7 @@ import com.duckduckgo.app.browser.R
6364
import com.duckduckgo.app.browser.SmoothProgressAnimator
6465
import com.duckduckgo.app.browser.animations.AddressBarTrackersAnimationFeatureToggle
6566
import com.duckduckgo.app.browser.api.OmnibarRepository
67+
import com.duckduckgo.app.browser.customtabs.CustomTabPixelNames
6668
import com.duckduckgo.app.browser.databinding.IncludeCustomTabToolbarBinding
6769
import com.duckduckgo.app.browser.databinding.IncludeFindInPageBinding
6870
import com.duckduckgo.app.browser.databinding.IncludeNewCustomTabToolbarBinding
@@ -98,6 +100,7 @@ import com.duckduckgo.app.global.view.renderIfChanged
98100
import com.duckduckgo.app.onboardingdesignexperiment.OnboardingDesignExperimentManager
99101
import com.duckduckgo.app.settings.db.SettingsDataStore
100102
import com.duckduckgo.app.statistics.pixels.Pixel
103+
import com.duckduckgo.app.statistics.pixels.Pixel.PixelType
101104
import com.duckduckgo.app.trackerdetection.model.Entity
102105
import com.duckduckgo.browser.ui.tabs.TabSwitcherButton
103106
import com.duckduckgo.common.ui.DuckDuckGoActivity
@@ -1150,6 +1153,11 @@ class OmnibarLayout @JvmOverloads constructor(
11501153
customToolbarContainer.setCardBackgroundColor(secondaryToolbarColor)
11511154
browserMenuImageView.setColorFilter(foregroundColor)
11521155

1156+
customToolbarContainer.setOnClickListener {
1157+
pixel.fire(CustomTabPixelNames.CUSTOM_TABS_ADDRESS_BAR_CLICKED)
1158+
pixel.fire(CustomTabPixelNames.CUSTOM_TABS_ADDRESS_BAR_CLICKED_DAILY, type = PixelType.Daily())
1159+
}
1160+
11531161
animationBackgroundColor = calculateAnimationBackgroundColor(customTab.toolbarColor)
11541162
} else {
11551163
animationBackgroundColor = customTab.toolbarColor
@@ -1213,30 +1221,30 @@ class OmnibarLayout @JvmOverloads constructor(
12131221
}
12141222

12151223
private fun calculateAddressBarColor(mainToolbarColor: Int): Int {
1216-
// Create a lighter, muted version of the toolbar color for the address bar
1217-
val targetSaturation = 0.55f // 15% Saturation for muted, pastel tone
1218-
val targetLightness = 0.90f // Target lightness for consistently light appearance
1219-
1220-
// 1. Convert the main color to HSL
1221-
val hsl = floatArrayOf(0f, 0f, 0f)
1222-
ColorUtils.colorToHSL(mainToolbarColor, hsl)
1223-
1224-
// hsl[0] is Hue (H) - keep this the same to maintain color identity
1225-
// hsl[1] is Saturation (S) - reduce for muted appearance
1226-
// hsl[2] is Lightness (L) - increase for lighter shade
1227-
1228-
// If the original color is grayscale (near-zero saturation),
1229-
// keep it grayscale to maintain color identity
1230-
if (hsl[1] < 0.01f) {
1231-
hsl[1] = 0f // Keep saturation at 0
1224+
return if (isColorLight(mainToolbarColor)) {
1225+
val targetSaturation = 0.55f
1226+
val targetLightness = 0.90f
1227+
val hsl = floatArrayOf(0f, 0f, 0f)
1228+
ColorUtils.colorToHSL(mainToolbarColor, hsl)
1229+
1230+
// hsl[0] is Hue (H) - keep this the same to maintain color identity
1231+
// hsl[1] is Saturation (S) - reduce for muted appearance
1232+
// hsl[2] is Lightness (L) - increase for lighter shade
1233+
1234+
// If the original color is grayscale (near-zero saturation),
1235+
// keep it grayscale to maintain color identity
1236+
if (hsl[1] < 0.01f) {
1237+
hsl[1] = 0f // Keep saturation at 0
1238+
} else {
1239+
hsl[1] = targetSaturation
1240+
}
1241+
hsl[2] = targetLightness
1242+
1243+
ColorUtils.HSLToColor(hsl)
12321244
} else {
1233-
hsl[1] = targetSaturation
1245+
// Use a darkened version of the main toolbar color for dark themes
1246+
ColorUtils.blendARGB(mainToolbarColor, Color.WHITE, 0.20f)
12341247
}
1235-
1236-
hsl[2] = targetLightness
1237-
1238-
// 3. Convert the modified HSL back to an Android color Int
1239-
return ColorUtils.HSLToColor(hsl)
12401248
}
12411249

12421250
private fun calculateAnimationBackgroundColor(mainToolbarColor: Int): Int {
@@ -1314,6 +1322,35 @@ class OmnibarLayout @JvmOverloads constructor(
13141322
return luminance > 0.5
13151323
}
13161324

1325+
private fun applyFindInPageTheme(toolbarColor: Int) {
1326+
val backgroundColor = calculateAddressBarColor(toolbarColor)
1327+
val isColorLight = isColorLight(backgroundColor)
1328+
1329+
with(findInPage) {
1330+
findInPageContainer.background = backgroundColor.toDrawable()
1331+
1332+
val foregroundColor = if (isColorLight) Color.BLACK else Color.WHITE
1333+
val hintColor = if (foregroundColor == Color.WHITE) {
1334+
Color.argb(153, 255, 255, 255) // 60% white for dark theme
1335+
} else {
1336+
Color.argb(153, 0, 0, 0) // 60% black for light theme
1337+
}
1338+
1339+
findInPageInput.setTextColor(foregroundColor)
1340+
findInPageInput.setHintTextColor(hintColor)
1341+
findInPageMatches.setTextColor(foregroundColor)
1342+
1343+
listOf(
1344+
findIcon,
1345+
previousSearchTermButton,
1346+
nextSearchTermButton,
1347+
closeFindInPagePanel,
1348+
).forEach { imageView ->
1349+
imageView.setColorFilter(foregroundColor)
1350+
}
1351+
}
1352+
}
1353+
13171354
private fun onLogoClicked(url: String) {
13181355
omnibarLogoClickedListener?.onClick(url)
13191356
}
@@ -1388,6 +1425,11 @@ class OmnibarLayout @JvmOverloads constructor(
13881425
omniBarContentContainer.hide()
13891426
customTabToolbarContainerWrapper.hide()
13901427
if (viewModel.viewState.value.viewMode is ViewMode.CustomTab) {
1428+
val toolbarColor = (viewModel.viewState.value.viewMode as ViewMode.CustomTab).toolbarColor
1429+
1430+
if (!isDefaultToolbarColor(toolbarColor)) {
1431+
applyFindInPageTheme(toolbarColor)
1432+
}
13911433
omniBarContainer.show()
13921434
browserMenu.gone()
13931435
}

app/src/main/res/layout/include_find_in_page.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
because the remaining 4dp are added by the omnibar selection animation -->
3131

3232
<ImageView
33+
android:id="@+id/findIcon"
3334
android:layout_width="@dimen/toolbarIcon"
3435
android:layout_height="@dimen/toolbarIcon"
3536
android:gravity="center"

0 commit comments

Comments
 (0)