Skip to content

Tab manager update: Add a bottom toolbar position support #6373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: feature/ondrej/tab-manager-redesign-flag
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand All @@ -41,6 +43,7 @@ import com.duckduckgo.app.browser.R
import com.duckduckgo.app.browser.databinding.ActivityTabSwitcherBinding
import com.duckduckgo.app.browser.databinding.PopupTabsMenuBinding
import com.duckduckgo.app.browser.favicon.FaviconManager
import com.duckduckgo.app.browser.omnibar.model.OmnibarPosition
import com.duckduckgo.app.browser.tabpreview.WebViewPreviewPersister
import com.duckduckgo.app.di.AppCoroutineScope
import com.duckduckgo.app.downloads.DownloadsActivity
Expand Down Expand Up @@ -89,6 +92,7 @@ import com.duckduckgo.common.ui.view.gone
import com.duckduckgo.common.ui.view.hide
import com.duckduckgo.common.ui.view.show
import com.duckduckgo.common.ui.view.toDp
import com.duckduckgo.common.ui.view.toPx
import com.duckduckgo.common.ui.viewbinding.viewBinding
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.di.scopes.ActivityScope
Expand Down Expand Up @@ -268,6 +272,13 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine

private fun configureViewReferences() {
tabsRecycler = findViewById(R.id.tabsRecycler)

if (settingsDataStore.omnibarPosition == OmnibarPosition.BOTTOM && viewModel.isNewDesignEnabled) {
binding.root.removeView(binding.tabSwitcherToolbarTop.root)
} else {
binding.root.removeView(binding.tabSwitcherToolbarBottom.root)
}

toolbar = findViewById(R.id.toolbar)
}

Expand Down Expand Up @@ -298,6 +309,19 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine
handleFabStateUpdates()
handleSelectionModeCancellation()
}

if (viewModel.isNewDesignEnabled) {
// Set the layout params for the tabs recycler view based on omnibar position
tabsRecycler.updateLayoutParams {
this as CoordinatorLayout.LayoutParams
this.behavior = null
if (settingsDataStore.omnibarPosition == OmnibarPosition.TOP) {
this.topMargin = 56.toPx()
} else {
this.bottomMargin = 56.toPx()
}
}
}
}

private fun handleSelectionModeCancellation() {
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/res/layout/activity_tab_switcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:layout_height="match_parent">

<include
android:id="@+id/toolbarInclude"
android:id="@+id/tabSwitcherToolbarTop"
layout="@layout/include_default_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Expand All @@ -32,9 +32,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingHorizontal="@dimen/keyline_2"
android:paddingTop="@dimen/keyline_2"
android:paddingBottom="@dimen/keyline_2"
android:padding="@dimen/keyline_2"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:itemCount="3"
Expand Down Expand Up @@ -72,4 +70,11 @@
android:visibility="gone"
app:icon="@drawable/ic_add_24_solid_color" />

<include
android:id="@+id/tabSwitcherToolbarBottom"
layout="@layout/include_default_toolbar"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading