1
0
Fork 0

For #11291 - Provide New Tab button when accessibility enabled (#11441)

master
David Walsh 2020-06-12 17:52:06 -05:00 committed by GitHub
parent 35fa445165
commit 063cf457ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 6 deletions

View File

@ -25,6 +25,7 @@ import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.tabstray.BrowserTabsTray
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
interface TabTrayInteractor {
fun onNewTabTapped(private: Boolean)
@ -61,14 +62,18 @@ class TabTrayView(
get() = container
init {
val hasAccessibilityEnabled = view.context.settings().accessibilityServicesEnabled
toggleFabText(isPrivate)
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, slideOffset: Float) {
if (slideOffset >= SLIDE_OFFSET) {
fabView.new_tab_button.show()
} else {
fabView.new_tab_button.hide()
if (!hasAccessibilityEnabled) {
if (slideOffset >= SLIDE_OFFSET) {
fabView.new_tab_button.show()
} else {
fabView.new_tab_button.hide()
}
}
}
@ -142,8 +147,18 @@ class TabTrayView(
}
}
fabView.new_tab_button.setOnClickListener {
interactor.onNewTabTapped(isPrivateModeSelected)
view.tab_tray_new_tab.apply {
isVisible = hasAccessibilityEnabled
setOnClickListener {
interactor.onNewTabTapped(isPrivateModeSelected)
}
}
fabView.new_tab_button.apply {
isVisible = !hasAccessibilityEnabled
setOnClickListener {
interactor.onNewTabTapped(isPrivateModeSelected)
}
}
}

View File

@ -70,6 +70,18 @@
</com.google.android.material.tabs.TabLayout>
<ImageButton
android:id="@+id/tab_tray_new_tab"
android:layout_width="48dp"
android:layout_height="48dp"
android:visibility="gone"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/add_tab"
app:srcCompat="@drawable/ic_new"
app:layout_constraintTop_toTopOf="@id/tab_layout"
app:layout_constraintEnd_toStartOf="@id/tab_tray_overflow"
app:layout_constraintBottom_toBottomOf="@id/tab_layout" />
<ImageButton
android:id="@+id/tab_tray_overflow"
android:layout_width="48dp"