1
0
Fork 0

For #12461: Add tab count to tab tray

master
Sawyer Blatz 2020-07-10 11:07:20 -07:00 committed by Emily Kager
parent c94bdc4267
commit 284ec7b58f
3 changed files with 50 additions and 12 deletions

View File

@ -18,6 +18,7 @@ import com.google.android.material.tabs.TabLayout
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.component_tabstray.view.*
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
import kotlinx.android.synthetic.main.tabs_tray_tab_counter.*
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@ -245,6 +246,8 @@ class TabTrayView(
View.VISIBLE
}
view.tab_tray_overflow.isVisible = !hasNoTabs
counter_text.text = "${state.normalTabs.size}"
}
}

View File

@ -46,27 +46,28 @@
android:layout_width="0dp"
android:layout_height="80dp"
android:background="@color/foundation_normal_theme"
app:tabIndicatorColor="@color/accent_normal_theme"
app:tabIconTint="@color/tab_icon"
app:tabRippleColor="@android:color/transparent"
app:tabGravity="fill"
app:layout_constraintWidth_percent="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/handle"
app:layout_constraintStart_toStartOf="parent">
app:layout_constraintWidth_percent="0.5"
app:tabGravity="fill"
app:tabIconTint="@color/tab_icon"
app:tabIndicatorColor="@color/accent_normal_theme"
app:tabRippleColor="@android:color/transparent">
<com.google.android.material.tabs.TabItem
android:id="@+id/default_tab_item"
android:layout_height="match_parent"
android:layout_width="0dp"
android:icon="@drawable/ic_tabs"
android:contentDescription="@string/tab_header_label" />
android:layout_height="match_parent"
android:contentDescription="@string/tab_header_label"
android:layout="@layout/tabs_tray_tab_counter"
app:tabIconTint="@color/tab_icon" />
<com.google.android.material.tabs.TabItem
android:id="@+id/private_tab_item"
android:layout_height="match_parent"
android:layout_width="0dp"
android:icon="@drawable/ic_private_browsing"
android:contentDescription="@string/tabs_header_private_tabs_title" />
android:layout_height="match_parent"
android:contentDescription="@string/tabs_header_private_tabs_title"
android:icon="@drawable/ic_private_browsing" />
</com.google.android.material.tabs.TabLayout>

View File

@ -0,0 +1,34 @@
<?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:tools="http://schemas.android.com/tools"
xmlns:app="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">
<ImageView
android:id="@+id/counter_box"
android:layout_width="@dimen/tab_counter_box_width_height"
android:layout_height="@dimen/tab_counter_box_width_height"
android:importantForAccessibility="no"
app:tint="@color/tab_icon"
app:srcCompat="@drawable/ic_tabs"/>
<!-- This text size auto adjusts based on num digits in `TabCounter` -->
<TextView
android:id="@+id/counter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:textColor="@color/tab_icon"
android:textSize="12sp"
android:textStyle="bold"
tools:text="16" />
</FrameLayout>