Implement Navigation, Add Search Fragment, Add Browser Fragment
parent
178723795e
commit
4421adecbb
|
@ -71,11 +71,12 @@ dependencies {
|
|||
implementation Deps.mozilla_browser_awesomebar
|
||||
implementation Deps.mozilla_browser_toolbar
|
||||
|
||||
|
||||
testImplementation Deps.junit
|
||||
androidTestImplementation Deps.tools_test_runner
|
||||
androidTestImplementation Deps.tools_espresso_core
|
||||
|
||||
armImplementation Deps.geckoview_nightly_arm
|
||||
x86Implementation Deps.geckoview_nightly_x86
|
||||
implementation Deps.androidx_legacy
|
||||
implementation Deps.android_arch_navigation
|
||||
}
|
||||
|
|
|
@ -6,16 +6,10 @@ package org.mozilla.fenix
|
|||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.mozilla.fenix.home.HomeFragment
|
||||
|
||||
class HomeActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_home)
|
||||
|
||||
supportFragmentManager?.beginTransaction()?.apply {
|
||||
replace(R.id.container, HomeFragment.create())
|
||||
commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/* 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.browser
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class BrowserFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_browser, container, false)
|
||||
}
|
||||
}
|
|
@ -5,23 +5,24 @@
|
|||
package org.mozilla.fenix.home
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.transition.TransitionInflater
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.Navigation
|
||||
import androidx.navigation.fragment.FragmentNavigator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
|
||||
import org.mozilla.fenix.R
|
||||
import android.widget.RelativeLayout
|
||||
import android.graphics.Color
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
||||
|
||||
class HomeFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
|
@ -39,11 +40,11 @@ class HomeFragment : Fragment() {
|
|||
sessionsAdapter = SessionsAdapter(requireContext())
|
||||
|
||||
toolbar_wrapper.clipToOutline = false
|
||||
toolbar.apply {
|
||||
textColor = ContextCompat.getColor(context, R.color.searchText)
|
||||
textSize = 14f
|
||||
hint = context.getString(R.string.search_hint)
|
||||
hintColor = ContextCompat.getColor(context, R.color.searchText)
|
||||
toolbar.setOnClickListener { it ->
|
||||
val extras = FragmentNavigator.Extras.Builder().addSharedElement(
|
||||
toolbar_wrapper, ViewCompat.getTransitionName(toolbar_wrapper)!!
|
||||
).build()
|
||||
Navigation.findNavController(it).navigate(R.id.action_homeFragment_to_searchFragment, null, null, extras)
|
||||
}
|
||||
|
||||
session_list.apply {
|
||||
|
@ -53,9 +54,10 @@ class HomeFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
fun create() = HomeFragment()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.fade)
|
||||
exitTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.fade)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* 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.search
|
||||
|
||||
import android.os.Bundle
|
||||
import android.transition.TransitionInflater
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import kotlinx.android.synthetic.main.fragment_search.*
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class SearchFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_search, container, false)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
toolbar.editMode()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
toolbar_wrapper.clipToOutline = false
|
||||
toolbar.apply {
|
||||
textColor = ContextCompat.getColor(context, R.color.searchText)
|
||||
textSize = 14f
|
||||
hint = context.getString(R.string.search_hint)
|
||||
hintColor = ContextCompat.getColor(context, R.color.searchText)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,20 @@
|
|||
<!-- 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"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:ignore="MergeRootFrame" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".HomeActivity">
|
||||
|
||||
<fragment
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:navGraph="@navigation/nav_graph"
|
||||
app:defaultNavHost="true"
|
||||
android:id="@+id/container"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?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/. -->
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".browser.BrowserFragment">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbar_wrapper"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@drawable/home_search_background"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="5dp"
|
||||
android:outlineProvider="paddedBounds"
|
||||
android:transitionName="firstTransitionName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<mozilla.components.browser.toolbar.BrowserToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/white"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
</FrameLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -2,79 +2,84 @@
|
|||
<!-- 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/. -->
|
||||
<androidx.constraintlayout.motion.widget.MotionLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/homeLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutDescription="@xml/home_scene"
|
||||
tools:context=".home.HomeFragment"
|
||||
android:clipToPadding="false">
|
||||
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/homeLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
app:layoutDescription="@xml/home_scene"
|
||||
tools:context=".home.HomeFragment">
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/menuButton"
|
||||
android:src="@drawable/ic_menu"
|
||||
android:layout_width="@dimen/glyph_button_height"
|
||||
android:layout_height="@dimen/glyph_button_height"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:id="@+id/menuButton"
|
||||
android:layout_width="@dimen/glyph_button_height"
|
||||
android:layout_height="@dimen/glyph_button_height"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_menu"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/privateBrowsingButton"
|
||||
android:src="@drawable/ic_private_browsing"
|
||||
android:layout_width="@dimen/glyph_button_height"
|
||||
android:layout_height="@dimen/glyph_button_height"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintEnd_toStartOf="@id/menuButton"
|
||||
app:layout_constraintTop_toTopOf="@id/menuButton" />
|
||||
android:id="@+id/privateBrowsingButton"
|
||||
android:layout_width="@dimen/glyph_button_height"
|
||||
android:layout_height="@dimen/glyph_button_height"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_private_browsing"
|
||||
app:layout_constraintEnd_toStartOf="@id/menuButton"
|
||||
app:layout_constraintTop_toTopOf="@id/menuButton" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/wordmark"
|
||||
android:src="@drawable/ic_logo_wordmark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="42dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/menuButton" />
|
||||
android:id="@+id/wordmark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:src="@drawable/ic_logo_wordmark"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/menuButton" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbar_wrapper"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@drawable/home_search_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/wordmark"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:outlineProvider="paddedBounds"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="5dp">
|
||||
|
||||
<mozilla.components.browser.toolbar.BrowserToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/white" />
|
||||
android:id="@+id/toolbar_wrapper"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@drawable/home_search_background"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="5dp"
|
||||
android:outlineProvider="paddedBounds"
|
||||
android:transitionName="firstTransitionName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/wordmark">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/white"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/search_hint"
|
||||
android:textColor="@color/searchText"
|
||||
android:textSize="14sp" />
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/session_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
android:id="@+id/session_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper" />
|
||||
|
||||
</androidx.constraintlayout.motion.widget.MotionLayout>
|
|
@ -0,0 +1,43 @@
|
|||
<?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/. -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".search.SearchFragment">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbar_wrapper"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@drawable/home_search_background"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="5dp"
|
||||
android:outlineProvider="paddedBounds"
|
||||
android:transitionName="firstTransitionName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<mozilla.components.browser.toolbar.BrowserToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/white"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
</FrameLayout>
|
||||
|
||||
<mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation 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/nav_graph"
|
||||
app:startDestination="@id/homeFragment">
|
||||
|
||||
<fragment android:id="@+id/homeFragment" android:name="org.mozilla.fenix.home.HomeFragment"
|
||||
android:label="fragment_home" tools:layout="@layout/fragment_home">
|
||||
<action android:id="@+id/action_homeFragment_to_searchFragment" app:destination="@id/searchFragment"
|
||||
/>
|
||||
<action android:id="@+id/action_homeFragment_to_browserFragment" app:destination="@id/browserFragment"/>
|
||||
</fragment>
|
||||
<fragment android:id="@+id/searchFragment" android:name="org.mozilla.fenix.search.SearchFragment"
|
||||
android:label="fragment_search" tools:layout="@layout/fragment_search">
|
||||
<action android:id="@+id/action_searchFragment_to_browserFragment" app:destination="@id/browserFragment"/>
|
||||
</fragment>
|
||||
<fragment android:id="@+id/browserFragment" android:name="org.mozilla.fenix.browser.BrowserFragment"
|
||||
android:label="fragment_browser" tools:layout="@layout/fragment_browser"/>
|
||||
</navigation>
|
|
@ -15,6 +15,9 @@ private object Versions {
|
|||
const val junit = "4.12"
|
||||
const val test_tools = "1.0.2"
|
||||
const val espresso_core = "2.2.2"
|
||||
|
||||
const val androidx_legacy = "1.0.0"
|
||||
const val android_arch_navigation = "1.0.0-alpha09"
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
|
@ -35,4 +38,7 @@ object Deps {
|
|||
const val junit = "junit:junit:${Versions.junit}"
|
||||
const val tools_test_runner = "com.android.support.test:runner:${Versions.test_tools}"
|
||||
const val tools_espresso_core = "com.android.support.test.espresso:espresso-core:${Versions.espresso_core}"
|
||||
|
||||
const val androidx_legacy = "androidx.legacy:legacy-support-v4:${Versions.androidx_legacy}"
|
||||
const val android_arch_navigation = "android.arch.navigation:navigation-fragment:${Versions.android_arch_navigation}"
|
||||
}
|
Loading…
Reference in New Issue