Skip to content

Commit 7be88be

Browse files
committed
Tab manager update: Add a bottom toolbar position support (#6373)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1207418217763355/task/1210728360131190?focus=true ### Description This PR adds the bottom toolbar support, which displays the tab manager toolbar in a position set in the Appearance settings. ### Steps to test this PR - [x] Go to Settings -> Appearance -> Address bar - [x] Set the position to bottom - [x] Open the tab manager screen - [x] Verify the toolbar is position at the bottom - [x] Change the position again to the top - [x] Verify the toolbar in the tab manager is now at the top
1 parent 09114fc commit 7be88be

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherActivity.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import android.view.View
2727
import androidx.activity.OnBackPressedCallback
2828
import androidx.appcompat.app.AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR
2929
import androidx.appcompat.widget.Toolbar
30+
import androidx.coordinatorlayout.widget.CoordinatorLayout
31+
import androidx.core.view.updateLayoutParams
3032
import androidx.lifecycle.Lifecycle
3133
import androidx.lifecycle.flowWithLifecycle
3234
import androidx.lifecycle.lifecycleScope
@@ -41,6 +43,7 @@ import com.duckduckgo.app.browser.R
4143
import com.duckduckgo.app.browser.databinding.ActivityTabSwitcherBinding
4244
import com.duckduckgo.app.browser.databinding.PopupTabsMenuBinding
4345
import com.duckduckgo.app.browser.favicon.FaviconManager
46+
import com.duckduckgo.app.browser.omnibar.model.OmnibarPosition
4447
import com.duckduckgo.app.browser.tabpreview.WebViewPreviewPersister
4548
import com.duckduckgo.app.di.AppCoroutineScope
4649
import com.duckduckgo.app.downloads.DownloadsActivity
@@ -89,6 +92,7 @@ import com.duckduckgo.common.ui.view.gone
8992
import com.duckduckgo.common.ui.view.hide
9093
import com.duckduckgo.common.ui.view.show
9194
import com.duckduckgo.common.ui.view.toDp
95+
import com.duckduckgo.common.ui.view.toPx
9296
import com.duckduckgo.common.ui.viewbinding.viewBinding
9397
import com.duckduckgo.common.utils.DispatcherProvider
9498
import com.duckduckgo.di.scopes.ActivityScope
@@ -268,6 +272,13 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine
268272

269273
private fun configureViewReferences() {
270274
tabsRecycler = findViewById(R.id.tabsRecycler)
275+
276+
if (settingsDataStore.omnibarPosition == OmnibarPosition.BOTTOM && viewModel.isNewDesignEnabled) {
277+
binding.root.removeView(binding.tabSwitcherToolbarTop.root)
278+
} else {
279+
binding.root.removeView(binding.tabSwitcherToolbarBottom.root)
280+
}
281+
271282
toolbar = findViewById(R.id.toolbar)
272283
}
273284

@@ -298,6 +309,19 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine
298309
handleFabStateUpdates()
299310
handleSelectionModeCancellation()
300311
}
312+
313+
if (viewModel.isNewDesignEnabled) {
314+
// Set the layout params for the tabs recycler view based on omnibar position
315+
tabsRecycler.updateLayoutParams {
316+
this as CoordinatorLayout.LayoutParams
317+
this.behavior = null
318+
if (settingsDataStore.omnibarPosition == OmnibarPosition.TOP) {
319+
this.topMargin = TABS_CONTENT_PADDING_DP.toPx()
320+
} else {
321+
this.bottomMargin = TABS_CONTENT_PADDING_DP.toPx()
322+
}
323+
}
324+
}
301325
}
302326

303327
private fun handleSelectionModeCancellation() {
@@ -1006,5 +1030,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine
10061030
private const val TAB_GRID_MAX_COLUMN_COUNT = 4
10071031
private const val KEY_FIRST_TIME_LOADING = "FIRST_TIME_LOADING"
10081032
private const val FAB_SCROLL_THRESHOLD = 7
1033+
private const val TABS_CONTENT_PADDING_DP = 56
10091034
}
10101035
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:layout_height="match_parent">
2323

2424
<include
25-
android:id="@+id/toolbarInclude"
25+
android:id="@+id/tabSwitcherToolbarTop"
2626
layout="@layout/include_default_toolbar"
2727
android:layout_width="match_parent"
2828
android:layout_height="wrap_content" />
@@ -32,9 +32,7 @@
3232
android:layout_width="match_parent"
3333
android:layout_height="match_parent"
3434
android:clipToPadding="false"
35-
android:paddingHorizontal="@dimen/keyline_2"
36-
android:paddingTop="@dimen/keyline_2"
37-
android:paddingBottom="@dimen/keyline_2"
35+
android:padding="@dimen/keyline_2"
3836
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
3937
app:layout_behavior="@string/appbar_scrolling_view_behavior"
4038
tools:itemCount="3"
@@ -72,4 +70,11 @@
7270
android:visibility="gone"
7371
app:icon="@drawable/ic_add_24_solid_color" />
7472

73+
<include
74+
android:id="@+id/tabSwitcherToolbarBottom"
75+
layout="@layout/include_default_toolbar"
76+
android:layout_gravity="bottom"
77+
android:layout_width="match_parent"
78+
android:layout_height="wrap_content" />
79+
7580
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)