For #631 - Puts tabs and sessions into a nested scrollview
parent
d62d41b46a
commit
8379c3d2cb
|
@ -7,7 +7,6 @@ package org.mozilla.fenix.home
|
|||
import android.content.res.Resources
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -44,6 +43,8 @@ class HomeFragment : Fragment() {
|
|||
private val bus = ActionBusFactory.get(this)
|
||||
private var sessionObserver: SessionManager.Observer? = null
|
||||
private lateinit var homeMenu: HomeMenu
|
||||
private lateinit var tabsComponent: TabsComponent
|
||||
private lateinit var sessionsComponent: SessionsComponent
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -52,11 +53,10 @@ class HomeFragment : Fragment() {
|
|||
): View? {
|
||||
val view = inflater.inflate(R.layout.fragment_home, container, false)
|
||||
val sessionManager = requireComponents.core.sessionManager
|
||||
TabsComponent(view.homeLayout, bus, (activity as HomeActivity).browsingModeManager.isPrivate,
|
||||
tabsComponent = TabsComponent(view.homeContainer, bus, (activity as HomeActivity).browsingModeManager.isPrivate,
|
||||
TabsState(sessionManager.sessions.map { it.toSessionViewState(it == sessionManager.selectedSession) })
|
||||
)
|
||||
SessionsComponent(view.homeLayout, bus)
|
||||
layoutComponents(view)
|
||||
sessionsComponent = SessionsComponent(view.homeContainer, bus)
|
||||
ActionBusFactory.get(this).logMergedObservables()
|
||||
val activity = activity as HomeActivity
|
||||
DefaultThemeManager.applyStatusBarTheme(activity.window, activity.themeManager, activity)
|
||||
|
@ -68,6 +68,9 @@ class HomeFragment : Fragment() {
|
|||
|
||||
setupHomeMenu()
|
||||
|
||||
tabsComponent.view.isNestedScrollingEnabled = false
|
||||
sessionsComponent.view.isNestedScrollingEnabled = false
|
||||
|
||||
val bundles = requireComponents.core.sessionStorage.bundles(40)
|
||||
|
||||
bundles.observe(this, Observer {sessionBundles ->
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/* 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.home
|
||||
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.PARENT_ID
|
||||
import kotlinx.android.synthetic.main.component_sessions.view.*
|
||||
import kotlinx.android.synthetic.main.component_tabs.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_home.view.*
|
||||
import kotlinx.android.synthetic.main.tab_list_header.view.*
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.BOTTOM
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.END
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.START
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.TOP
|
||||
import org.jetbrains.anko.constraint.layout.applyConstraintSet
|
||||
|
||||
fun HomeFragment.layoutComponents(layout: View) {
|
||||
with(layout) {
|
||||
homeLayout.applyConstraintSet {
|
||||
tabs_header {
|
||||
connect(
|
||||
TOP to BOTTOM of homeDivider,
|
||||
START to START of tabs_list,
|
||||
END to END of PARENT_ID
|
||||
)
|
||||
}
|
||||
tabs_list {
|
||||
connect(
|
||||
TOP to BOTTOM of tabs_header,
|
||||
START to START of PARENT_ID,
|
||||
END to END of PARENT_ID
|
||||
)
|
||||
}
|
||||
session_list {
|
||||
connect(
|
||||
TOP to BOTTOM of tabs_list,
|
||||
START to START of PARENT_ID,
|
||||
END to END of PARENT_ID
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,8 @@ class SessionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
|
||||
return when (viewType) {
|
||||
HeaderViewHolder.LAYOUT_ID -> HeaderViewHolder(view)
|
||||
EmptyListViewHolder.LAYOUT_ID -> EmptyListViewHolder(view)
|
||||
PrivateEmptyListViewHolder.LAYOUT_ID -> PrivateEmptyListViewHolder(view)
|
||||
else -> EmptyListViewHolder(view)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package org.mozilla.fenix.home.sessions
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import mozilla.components.browser.session.Session
|
||||
import org.mozilla.fenix.mvi.Action
|
||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||
|
@ -31,6 +32,8 @@ class SessionsComponent(
|
|||
}
|
||||
|
||||
override fun initView() = SessionsUIView(container, actionEmitter, changesObservable)
|
||||
val view: RecyclerView
|
||||
get() = uiView.view as RecyclerView
|
||||
|
||||
init {
|
||||
render(reducer)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package org.mozilla.fenix.home.tabs
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import mozilla.components.browser.session.Session
|
||||
import org.mozilla.fenix.mvi.Action
|
||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||
|
@ -30,6 +31,8 @@ class TabsComponent(
|
|||
}
|
||||
|
||||
override fun initView() = TabsUIView(container, actionEmitter, isPrivate, changesObservable)
|
||||
val view: RecyclerView
|
||||
get() = uiView.view as RecyclerView
|
||||
|
||||
init {
|
||||
render(reducer)
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
<androidx.recyclerview.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/session_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"/>
|
|
@ -1,13 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/tabs_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper"/>
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tabs_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"/>
|
|
@ -15,7 +15,6 @@
|
|||
android:background="?attr/homeBackgroundGradient"
|
||||
app:layoutDescription="@xml/home_scene"
|
||||
tools:context=".home.HomeFragment">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/menuButton"
|
||||
android:layout_width="@dimen/glyph_button_height"
|
||||
|
@ -90,5 +89,21 @@
|
|||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="40dp"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/homeScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/homeDivider"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/homeContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:descendantFocusability="blocksDescendants"/>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.constraintlayout.motion.widget.MotionLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -7,9 +7,7 @@
|
|||
android:id="@+id/tabs_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
android:layout_margin="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/header_text"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
motion:constraintSetEnd="@+id/end">
|
||||
<OnSwipe
|
||||
motion:dragDirection="dragUp"
|
||||
motion:touchAnchorId="@id/session_list"
|
||||
motion:touchAnchorId="@id/homeScrollView"
|
||||
motion:touchAnchorSide="top" />
|
||||
|
||||
<KeyFrameSet>
|
||||
|
|
Loading…
Reference in New Issue