Closes #18514: Re-add tab counter in tabs tray (#18659)

upstream-sync
Roger Yang 3 years ago committed by GitHub
parent 89088aa595
commit caf8ac8207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,6 +16,10 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import kotlinx.android.synthetic.main.component_tabstray2.*
import kotlinx.android.synthetic.main.component_tabstray2.view.*
import org.mozilla.fenix.HomeActivity
import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.components.browser.state.selector.normalTabs
import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.ui.tabcounter.TabCounter
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor
@ -63,6 +67,7 @@ class TabsTrayFragment : AppCompatDialogFragment(), TabsTrayInteractor {
return containerView
}
@ExperimentalCoroutinesApi
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -85,6 +90,12 @@ class TabsTrayFragment : AppCompatDialogFragment(), TabsTrayInteractor {
interactor = this,
store = requireComponents.core.store
).attach()
consumeFrom(requireComponents.core.store) {
view.findViewById<TabCounter>(R.id.tab_counter)?.apply {
setCount(requireComponents.core.store.state.normalTabs.size)
}
}
}
override fun setCurrentTrayPosition(position: Int) {

@ -109,8 +109,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:contentDescription="@string/tab_header_label"
android:layout="@layout/tabs_tray_tab_counter"
app:tabIconTint="@color/tab_icon" />
android:layout="@layout/tabs_tray_tab_counter2" />
<com.google.android.material.tabs.TabItem
android:id="@+id/private_tab_item"

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mozac="http://schemas.android.com/apk/res-auto"
android:id="@+id/counter_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<mozilla.components.ui.tabcounter.TabCounter
android:id="@+id/tab_counter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
mozac:tabCounterTintColor="@color/tab_icon" />
</FrameLayout>
Loading…
Cancel
Save