@@ -46,6 +46,7 @@ import androidx.core.transition.doOnEnd
4646import androidx.core.view.doOnLayout
4747import androidx.core.view.isGone
4848import androidx.core.view.isInvisible
49+ import androidx.core.view.isNotEmpty
4950import androidx.core.view.isVisible
5051import androidx.core.view.updateLayoutParams
5152import androidx.lifecycle.LifecycleOwner
@@ -63,6 +64,7 @@ import com.duckduckgo.app.browser.R
6364import com.duckduckgo.app.browser.SmoothProgressAnimator
6465import com.duckduckgo.app.browser.animations.AddressBarTrackersAnimationFeatureToggle
6566import com.duckduckgo.app.browser.api.OmnibarRepository
67+ import com.duckduckgo.app.browser.customtabs.CustomTabPixelNames
6668import com.duckduckgo.app.browser.databinding.IncludeCustomTabToolbarBinding
6769import com.duckduckgo.app.browser.databinding.IncludeFindInPageBinding
6870import com.duckduckgo.app.browser.databinding.IncludeNewCustomTabToolbarBinding
@@ -98,6 +100,7 @@ import com.duckduckgo.app.global.view.renderIfChanged
98100import com.duckduckgo.app.onboardingdesignexperiment.OnboardingDesignExperimentManager
99101import com.duckduckgo.app.settings.db.SettingsDataStore
100102import com.duckduckgo.app.statistics.pixels.Pixel
103+ import com.duckduckgo.app.statistics.pixels.Pixel.PixelType
101104import com.duckduckgo.app.trackerdetection.model.Entity
102105import com.duckduckgo.browser.ui.tabs.TabSwitcherButton
103106import 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 }
0 commit comments