Skip to content

Commit

Permalink
Address requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshliebe committed Mar 6, 2025
1 parent 0f630b5 commit 04fd893
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 59 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,14 @@ class BrowserTabFragment :
if (swipingTabsFeature.isEnabled) {
disableSwipingOutsideTheOmnibar()
}

binding.includeNewBrowserTab.newTabLayout.apply {
setOnClickListener {
if (omnibar.omnibarTextInput.isFocused) {
binding.focusDummy.requestFocus()
}
}
}
}

@SuppressLint("ClickableViewAccessibility")
Expand Down Expand Up @@ -3302,6 +3310,14 @@ class BrowserTabFragment :
Timber.v("Keyboard now showing")
showKeyboard(omnibar.omnibarTextInput)
omnibar.showOutline(true)
omnibar.textInputRootView.post {
val rootView = omnibar.textInputRootView
val keyboardVisibilityUtil = KeyboardVisibilityUtil(rootView)
keyboardVisibilityUtil.addKeyboardHiddenListener {
binding.focusDummy.requestFocus()
omnibar.showOutline(false)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import com.duckduckgo.app.browser.databinding.IncludeFindInPageBinding
import com.duckduckgo.app.browser.omnibar.Omnibar.OmnibarTextState
import com.duckduckgo.app.browser.omnibar.Omnibar.ViewMode
import com.duckduckgo.app.browser.omnibar.Omnibar.ViewMode.CustomTab
import com.duckduckgo.app.browser.omnibar.Omnibar.ViewMode.NewTab
import com.duckduckgo.app.browser.omnibar.OmnibarLayout.Decoration.CancelAnimations
import com.duckduckgo.app.browser.omnibar.OmnibarLayout.Decoration.ChangeCustomTabTitle
import com.duckduckgo.app.browser.omnibar.OmnibarLayout.Decoration.DisableVoiceSearch
Expand All @@ -67,7 +68,6 @@ import com.duckduckgo.app.browser.omnibar.OmnibarLayout.Decoration.Outline
import com.duckduckgo.app.browser.omnibar.OmnibarLayout.Decoration.PrivacyShieldChanged
import com.duckduckgo.app.browser.omnibar.OmnibarLayoutViewModel.Command.CancelTrackersAnimation
import com.duckduckgo.app.browser.omnibar.OmnibarLayoutViewModel.Command.StartTrackersAnimation
import com.duckduckgo.app.browser.omnibar.OmnibarLayoutViewModel.LeadingIconState
import com.duckduckgo.app.browser.omnibar.OmnibarLayoutViewModel.LeadingIconState.PRIVACY_SHIELD
import com.duckduckgo.app.browser.omnibar.OmnibarLayoutViewModel.ViewState
import com.duckduckgo.app.browser.omnibar.animations.BrowserTrackersAnimatorHelper
Expand Down Expand Up @@ -198,7 +198,7 @@ open class OmnibarLayout @JvmOverloads constructor(
ChangeBounds().apply {
duration = 400
interpolator = OvershootInterpolator(1.3f)
}
},
)
addTransition(
Fade().apply {
Expand All @@ -208,7 +208,7 @@ open class OmnibarLayout @JvmOverloads constructor(
addTarget(fireIconMenu)
addTarget(tabsMenu)
addTarget(browserMenu)
}
},
)
}
}
Expand Down Expand Up @@ -522,7 +522,6 @@ open class OmnibarLayout @JvmOverloads constructor(
val showBrowserMenu: Boolean,
val showBrowserMenuHighlight: Boolean,
val showChatMenu: Boolean,
val experimentalIconsEnabled: Boolean
)

private var previousButtonState: ButtonState? = null
Expand All @@ -536,7 +535,6 @@ open class OmnibarLayout @JvmOverloads constructor(
showBrowserMenu = viewState.showBrowserMenu,
showBrowserMenuHighlight = viewState.showBrowserMenuHighlight,
showChatMenu = viewState.showChatMenu,
experimentalIconsEnabled = viewState.experimentalIconsEnabled
)

if (!isInitialRender && newButtonState != previousButtonState) {
Expand All @@ -550,7 +548,7 @@ open class OmnibarLayout @JvmOverloads constructor(
browserMenu.isVisible = viewState.showBrowserMenu
browserMenuHighlight.isVisible = viewState.showBrowserMenuHighlight
spacer.isVisible = viewState.showVoiceSearch || viewState.showClearButton
aiChatMenu.isVisible = viewState.showChatMenu
aiChatMenu.isVisible = viewState.viewMode is NewTab || viewState.showChatMenu
toolbarContainer.requestLayout()

isInitialRender = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ class OmnibarLayoutViewModel @Inject constructor(
val hasUnreadTabs: Boolean = false,
val shouldUpdateTabsCount: Boolean = false,
val showVoiceSearch: Boolean = false,
val showClearButton: Boolean = true,
val showTabsMenu: Boolean = false,
val showFireIcon: Boolean = false,
val showBrowserMenu: Boolean = false,
val showClearButton: Boolean = false,
val showTabsMenu: Boolean = true,
val showFireIcon: Boolean = true,
val showBrowserMenu: Boolean = true,
val showChatMenu: Boolean = true,
val showBrowserMenuHighlight: Boolean = false,
val scrollingEnabled: Boolean = true,
Expand Down Expand Up @@ -149,41 +149,13 @@ class OmnibarLayoutViewModel @Inject constructor(
logVoiceSearchAvailability()
}

private fun onOmnibarClicked() {
Timber.d("Omnibar: onOmnibarClicked")

viewModelScope.launch {
command.send(Command.CancelTrackersAnimation)
}

_viewState.update {
it.copy(
hasFocus = true,
expanded = true,
leadingIconState = SEARCH,
highlightPrivacyShield = HighlightableButton.Gone,
showClearButton = true,
showTabsMenu = false,
showFireIcon = false,
showBrowserMenu = false,
showChatMenu = true,
showVoiceSearch = shouldShowVoiceSearch(
hasFocus = true,
query = _viewState.value.omnibarText,
hasQueryChanged = false,
urlLoaded = _viewState.value.url,
),
)
}
}

fun onOmnibarFocusChanged(
hasFocus: Boolean,
query: String,
) {
Timber.d("Omnibar: onOmnibarFocusChanged")
val showClearButton = hasFocus
val showControls = !hasFocus
val showClearButton = hasFocus && query.isNotBlank()
val showControls = query.isBlank()

if (hasFocus) {
viewModelScope.launch {
Expand Down Expand Up @@ -398,7 +370,7 @@ class OmnibarLayoutViewModel @Inject constructor(
showBrowserMenu = showControls,
showTabsMenu = showControls,
showFireIcon = showControls,
showChatMenu = !showControls,
showChatMenu = false,
)
}
}
Expand Down Expand Up @@ -568,7 +540,6 @@ class OmnibarLayoutViewModel @Inject constructor(

fun onUserTouchedOmnibarTextInput(touchAction: Int) {
Timber.d("Omnibar: onUserTouchedOmnibarTextInput")
onOmnibarClicked()
if (touchAction == ACTION_UP) {
firePixelBasedOnCurrentUrl(
AppPixelName.ADDRESS_BAR_NEW_TAB_PAGE_CLICKED,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/include_new_browser_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
android:layout_height="match_parent"
android:clipChildren="false"
android:fillViewport="true"
android:clickable="true"
android:focusable="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.duckduckgo.app.browser.BrowserActivity"
tools:showIn="@layout/fragment_browser_tab">
Expand Down
11 changes: 3 additions & 8 deletions app/src/main/res/layout/view_new_omnibar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,17 @@
android:padding="@dimen/keyline_2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/fireIconMenu"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<com.duckduckgo.common.ui.view.text.DaxTextView
<ImageView
android:id="@+id/aiChatIconImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="AI Chat"
android:background="?attr/selectableItemBackgroundBorderless"
android:drawableStart="@drawable/ic_ai_chat_outline_24"
android:drawablePadding="@dimen/keyline_1"
app:typography="body1_bold" />
android:src="@drawable/ic_ai_chat_outline_24" />
</FrameLayout>

<FrameLayout
Expand All @@ -281,7 +279,6 @@
android:layout_height="match_parent"
android:padding="@dimen/keyline_2"
android:layout_marginEnd="6dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/tabsMenu"
app:layout_constraintStart_toEndOf="@id/aiChatIconMenu"
Expand All @@ -305,7 +302,6 @@
android:layout_marginHorizontal="@dimen/keyline_0"
android:padding="@dimen/keyline_2"
android:background="?selectableItemBackgroundBorderless"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/browserMenu"
app:layout_constraintStart_toEndOf="@id/fireIconMenu"
Expand All @@ -317,7 +313,6 @@
android:layout_height="match_parent"
android:padding="@dimen/keyline_2"
android:layout_marginEnd="@dimen/keyline_0"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tabsMenu"
Expand Down
11 changes: 3 additions & 8 deletions app/src/main/res/layout/view_new_omnibar_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,17 @@
android:padding="@dimen/keyline_2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/fireIconMenu"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<com.duckduckgo.common.ui.view.text.DaxTextView
<ImageView
android:id="@+id/aiChatIconImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="AI Chat"
android:background="?attr/selectableItemBackgroundBorderless"
android:drawableStart="@drawable/ic_ai_chat_outline_24"
android:drawablePadding="@dimen/keyline_1"
app:typography="body1_bold" />
android:src="@drawable/ic_ai_chat_outline_24" />
</FrameLayout>

<FrameLayout
Expand All @@ -295,7 +293,6 @@
android:layout_height="match_parent"
android:padding="@dimen/keyline_2"
android:layout_marginEnd="6dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/tabsMenu"
app:layout_constraintStart_toEndOf="@id/aiChatIconMenu"
Expand All @@ -319,7 +316,6 @@
android:layout_marginHorizontal="@dimen/keyline_0"
android:padding="@dimen/keyline_2"
android:background="?selectableItemBackgroundBorderless"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/browserMenu"
app:layout_constraintStart_toEndOf="@id/fireIconMenu"
Expand All @@ -331,7 +327,6 @@
android:layout_height="match_parent"
android:padding="@dimen/keyline_2"
android:layout_marginEnd="@dimen/keyline_0"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tabsMenu"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<string name="back">Back</string>
<string name="forward">Forward</string>

<string name="omnibarInputHint">Search or type URL</string>
<string name="omnibarInputHint">Search</string>
<string name="clearButtonContentDescription">Clear search input</string>
<string name="no_compatible_third_party_app_installed">No compatible app installed</string>
<string name="addBookmarkMenuTitle">Add Bookmark</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ class KeyboardVisibilityUtil(private val rootView: View) {
)
}

fun addKeyboardHiddenListener(onKeyboardHidden: () -> Unit) {
var wasKeyboardVisible = isKeyboardVisible()
rootView.viewTreeObserver.addOnGlobalLayoutListener {
val isVisible = isKeyboardVisible()
if (wasKeyboardVisible && !isVisible) {
onKeyboardHidden()
}
wasKeyboardVisible = isVisible
}
}

private fun isKeyboardVisible(): Boolean {
val rect = Rect()
rootView.getWindowVisibleDisplayFrame(rect)
Expand Down

0 comments on commit 04fd893

Please sign in to comment.