For #139 - Adds session placeholder with motionlayout
parent
da939bba50
commit
a800d33620
|
@ -4,15 +4,24 @@
|
|||
|
||||
package org.mozilla.fenix.home
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat
|
||||
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(
|
||||
|
@ -22,15 +31,26 @@ class HomeFragment : Fragment() {
|
|||
return inflater.inflate(R.layout.fragment_home, container, false)
|
||||
}
|
||||
|
||||
private lateinit var sessionsAdapter: SessionsAdapter
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
sessionsAdapter = SessionsAdapter(requireContext())
|
||||
|
||||
toolbar_wrapper.clipToOutline = false
|
||||
toolbar.apply {
|
||||
textColor = ContextCompat.getColor(context, R.color.searchText)
|
||||
textSize = 14f
|
||||
hint = "Search the Web or enter address"
|
||||
hint = context.getString(R.string.search_hint)
|
||||
hintColor = ContextCompat.getColor(context, R.color.searchText)
|
||||
}
|
||||
|
||||
session_list.apply {
|
||||
adapter = sessionsAdapter
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
setHasFixedSize(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,3 +58,28 @@ class HomeFragment : Fragment() {
|
|||
fun create() = HomeFragment()
|
||||
}
|
||||
}
|
||||
|
||||
// Temporary adapter
|
||||
private class SessionsAdapter(val context: Context) : RecyclerView.Adapter<SessionsAdapter.ViewHolder>() {
|
||||
class ViewHolder(val textView: TextView) : RecyclerView.ViewHolder(textView) {}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val textView = TextView(context).apply {
|
||||
val lp = RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT, // Width of TextView
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
setLayoutParams(lp)
|
||||
setText("This is a sample TextView...")
|
||||
setTextColor(Color.parseColor("#ff0000"))
|
||||
}
|
||||
return ViewHolder(textView)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = 0
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
holder.textView.text = "Cell: ${position}"
|
||||
}
|
||||
}
|
|
@ -2,12 +2,14 @@
|
|||
<!-- 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
|
||||
<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">
|
||||
|
||||
|
@ -17,6 +19,7 @@
|
|||
android:src="@drawable/ic_menu"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
@ -64,4 +67,14 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<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_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.motion.widget.MotionLayout>
|
|
@ -3,4 +3,5 @@
|
|||
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
<string name="search_hint">Search the Web or enter address</string>
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MotionScene
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:motion="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Transition
|
||||
motion:constraintSetStart="@+id/start"
|
||||
motion:constraintSetEnd="@+id/end">
|
||||
<OnSwipe
|
||||
motion:dragDirection="dragUp"
|
||||
motion:touchAnchorId="@id/session_list"
|
||||
motion:touchAnchorSide="top" />
|
||||
|
||||
</Transition>
|
||||
|
||||
<ConstraintSet android:id="@+id/start">
|
||||
|
||||
</ConstraintSet>
|
||||
|
||||
<ConstraintSet android:id="@+id/end">
|
||||
<Constraint
|
||||
android:id="@+id/wordmark"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
motion:layout_constraintLeft_toLeftOf="parent"
|
||||
motion:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/toolbar_wrapper"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
motion:layout_constraintTop_toBottomOf="@id/wordmark"
|
||||
motion:layout_constraintLeft_toLeftOf="parent"
|
||||
motion:layout_constraintRight_toRightOf="parent"
|
||||
android:elevation="0dp"/>
|
||||
</ConstraintSet>
|
||||
|
||||
</MotionScene>
|
|
@ -8,7 +8,7 @@ private object Versions {
|
|||
const val geckoNightly = "66.0.20181217093726"
|
||||
|
||||
const val androidx_appcompat = "1.0.2"
|
||||
const val androidx_constraint_layout = "1.1.3"
|
||||
const val androidx_constraint_layout = "2.0.0-alpha3"
|
||||
|
||||
const val mozilla_android_components = "0.37.0"
|
||||
|
||||
|
|
Loading…
Reference in New Issue