Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #11291 - Provide New Tab button when accessibility enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Jun 12, 2020
1 parent d16c70d commit a3dc565
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
27 changes: 21 additions & 6 deletions app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
}
}
}

Expand Down Expand Up @@ -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)
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/layout/component_tabstray.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a3dc565

Please sign in to comment.