Adds swipe to delete tab (#10355)
* No Issue - Increases tap area of close button * For #10331 - Adds swipe to delete to the tab traymaster
parent
3dcd52ef7a
commit
94cd195dc7
|
@ -21,6 +21,7 @@ import org.mozilla.fenix.ext.requireComponents
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
|
import mozilla.components.browser.tabstray.BrowserTabsTray
|
||||||
import mozilla.components.concept.tabstray.Tab
|
import mozilla.components.concept.tabstray.Tab
|
||||||
import mozilla.components.concept.tabstray.TabsTray
|
import mozilla.components.concept.tabstray.TabsTray
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
|
@ -51,6 +52,10 @@ class TabTrayFragment : Fragment(R.layout.fragment_tab_tray), TabsTray.Observer,
|
||||||
showToolbar(getString(R.string.tab_tray_title))
|
showToolbar(getString(R.string.tab_tray_title))
|
||||||
onTabsChanged()
|
onTabsChanged()
|
||||||
|
|
||||||
|
(tabsTray as? BrowserTabsTray)?.also { tray ->
|
||||||
|
TabsTouchHelper(tray.tabsAdapter).attachToRecyclerView(tray)
|
||||||
|
}
|
||||||
|
|
||||||
sessionManager.register(observer = object : SessionManager.Observer {
|
sessionManager.register(observer = object : SessionManager.Observer {
|
||||||
override fun onSessionAdded(session: Session) {
|
override fun onSessionAdded(session: Session) {
|
||||||
onTabsChanged()
|
onTabsChanged()
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix.tabtray
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
|
import mozilla.components.browser.tabstray.TabTouchCallback
|
||||||
|
import mozilla.components.concept.tabstray.TabsTray
|
||||||
|
import mozilla.components.support.base.observer.Observable
|
||||||
|
|
||||||
|
class TabsTouchHelper(observable: Observable<TabsTray.Observer>) :
|
||||||
|
ItemTouchHelper(object : TabTouchCallback(observable) {
|
||||||
|
override fun alphaForItemSwipe(dX: Float, distanceToAlphaMin: Int): Float {
|
||||||
|
return 1f - 2f * Math.abs(dX) / distanceToAlphaMin
|
||||||
|
}
|
||||||
|
})
|
|
@ -44,7 +44,6 @@
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:paddingTop="22dp"
|
android:paddingTop="22dp"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:layout_marginEnd="20dp"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintEnd_toStartOf="@id/mozac_browser_tabstray_close"
|
app:layout_constraintEnd_toStartOf="@id/mozac_browser_tabstray_close"
|
||||||
app:layout_constraintStart_toEndOf="@id/mozac_browser_tabstray_card"
|
app:layout_constraintStart_toEndOf="@id/mozac_browser_tabstray_card"
|
||||||
|
@ -59,7 +58,6 @@
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:layout_marginEnd="20dp"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintEnd_toStartOf="@id/mozac_browser_tabstray_close"
|
app:layout_constraintEnd_toStartOf="@id/mozac_browser_tabstray_close"
|
||||||
app:layout_constraintStart_toEndOf="@id/mozac_browser_tabstray_card"
|
app:layout_constraintStart_toEndOf="@id/mozac_browser_tabstray_card"
|
||||||
|
@ -67,10 +65,8 @@
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:id="@+id/mozac_browser_tabstray_close"
|
android:id="@+id/mozac_browser_tabstray_close"
|
||||||
android:layout_width="24dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="32dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
|
Loading…
Reference in New Issue