main
parent
36817f89c2
commit
5097f11c59
@ -1,4 +1,71 @@
|
|||||||
package fr.uca.iut.myouafff.ui.activity
|
package fr.uca.iut.myouafff.ui.activity
|
||||||
|
|
||||||
class DogListActivity {
|
import android.os.Bundle
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import fr.uca.iut.myouafff.R
|
||||||
|
import fr.uca.iut.myouafff.data.NEW_DOG_ID
|
||||||
|
import fr.uca.iut.myouafff.ui.fragment.DogFragment
|
||||||
|
import fr.uca.iut.myouafff.ui.fragment.DogListFragment
|
||||||
|
|
||||||
|
class DogListActivity : SimpleFragmentActivity(),
|
||||||
|
DogListFragment.OnInteractionListener, DogFragment.OnInteractionListener {
|
||||||
|
|
||||||
|
private var isTwoPane: Boolean = false
|
||||||
|
private lateinit var masterFragment: DogListFragment
|
||||||
|
|
||||||
|
override fun createFragment() = DogListFragment().also { masterFragment = it }
|
||||||
|
override fun getLayoutResId() = R.layout.toolbar_md_activity
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
supportActionBar?.setIcon(R.mipmap.ic_launcher)
|
||||||
|
isTwoPane = findViewById<FrameLayout>(R.id.container_fragment_detail) != null
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
masterFragment =
|
||||||
|
supportFragmentManager.findFragmentById(R.id.container_fragment) as DogListFragment
|
||||||
|
|
||||||
|
if (!isTwoPane) {
|
||||||
|
removeDisplayedFragment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDogSelected(dogId: Long) {
|
||||||
|
if (isTwoPane) {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container_fragment_detail, DogFragment.newInstance(dogId))
|
||||||
|
.commit()
|
||||||
|
} else {
|
||||||
|
startActivity(DogPagerActivity.getIntent(this, dogId))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAddNewDog() = startActivity(DogActivity.getIntent(this, NEW_DOG_ID))
|
||||||
|
|
||||||
|
override fun onDogSaved() {
|
||||||
|
if (isTwoPane) {
|
||||||
|
masterFragment.updateList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun removeDisplayedFragment() {
|
||||||
|
supportFragmentManager.findFragmentById(R.id.container_fragment_detail)?.let {
|
||||||
|
supportFragmentManager.beginTransaction().remove(it).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDogDeleted() {
|
||||||
|
if (isTwoPane) {
|
||||||
|
removeDisplayedFragment()
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDogSwiped() {
|
||||||
|
if (isTwoPane) {
|
||||||
|
removeDisplayedFragment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,52 @@
|
|||||||
package fr.uca.iut.myouafff.ui.activity
|
package fr.uca.iut.myouafff.ui.activity
|
||||||
|
|
||||||
class DogPagerActivity {
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
|
import fr.uca.iut.myouafff.R
|
||||||
|
import fr.uca.iut.myouafff.ui.fragment.DogFragment
|
||||||
|
import fr.uca.iut.myouafff.ui.utils.DogPagerAdapter
|
||||||
|
|
||||||
|
class DogPagerActivity : AppCompatActivity(), DogFragment.OnInteractionListener {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val EXTRA_DOG_ID = "fr.uca.iut.myouafff.extra_dog_id"
|
||||||
|
|
||||||
|
fun getIntent(context: Context, dogId: Long) =
|
||||||
|
Intent(context, DogPagerActivity::class.java).apply {
|
||||||
|
putExtra(EXTRA_DOG_ID, dogId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private lateinit var viewPager: ViewPager2
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_pager)
|
||||||
|
|
||||||
|
setSupportActionBar(findViewById(R.id.toolbar_activity))
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
|
||||||
|
viewPager = ViewPager2(this)
|
||||||
|
viewPager.id = R.id.view_pager
|
||||||
|
findViewById<LinearLayout>(R.id.pager_layout).addView(viewPager)
|
||||||
|
|
||||||
|
val adapter = DogPagerAdapter(this)
|
||||||
|
viewPager.adapter = adapter
|
||||||
|
val initialPosition = adapter.positionFromId(intent.getLongExtra(EXTRA_DOG_ID, 1))
|
||||||
|
viewPager.currentItem = initialPosition
|
||||||
|
supportActionBar?.subtitle = getString(R.string.dogs_subtitle_format, initialPosition + 1)
|
||||||
|
|
||||||
|
viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||||
|
override fun onPageSelected(position: Int) {
|
||||||
|
supportActionBar?.subtitle = getString(R.string.dogs_subtitle_format, position + 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDogSaved() = finish()
|
||||||
|
override fun onDogDeleted() = finish()
|
||||||
}
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
package fr.uca.iut.myouafff.ui.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.*
|
||||||
|
import androidx.constraintlayout.widget.Group
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
import fr.uca.iut.myouafff.R
|
||||||
|
import fr.uca.iut.myouafff.data.Dog
|
||||||
|
import fr.uca.iut.myouafff.data.persistence.DogDatabase
|
||||||
|
import fr.uca.iut.myouafff.ui.utils.DogRecyclerViewAdapter
|
||||||
|
|
||||||
|
class DogListFragment : Fragment(), DogRecyclerViewAdapter.Callbacks {
|
||||||
|
private var dogList = DogDatabase.getInstance().dogDAO().getAll()
|
||||||
|
private var dogListAdapter = DogRecyclerViewAdapter(dogList, this)
|
||||||
|
|
||||||
|
private lateinit var groupEmptyView: Group
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
val view = inflater.inflate(R.layout.fragment_list_dog, container, false)
|
||||||
|
groupEmptyView = view.findViewById(R.id.group_empty_view)
|
||||||
|
groupEmptyView.visibility = if (dogList.isEmpty()) View.VISIBLE else View.GONE
|
||||||
|
val recyclerView = view.findViewById<RecyclerView>(R.id.recycler_view)
|
||||||
|
recyclerView.adapter = dogListAdapter
|
||||||
|
ItemTouchHelper(DogListItemTouchHelper()).attachToRecyclerView(recyclerView)
|
||||||
|
view.findViewById<FloatingActionButton>(R.id.fab_add_dog).setOnClickListener { addNewDog() }
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
setupMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupMenu() {
|
||||||
|
requireActivity().addMenuProvider(object : MenuProvider {
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.fragment_list_dog, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
|
return when (menuItem.itemId) {
|
||||||
|
R.id.menu_item_new_dog -> {
|
||||||
|
addNewDog()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
updateList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateList() {
|
||||||
|
dogList = DogDatabase.getInstance().dogDAO().getAll()
|
||||||
|
dogListAdapter.updateList(dogList)
|
||||||
|
groupEmptyView.visibility = if (dogList.isEmpty()) View.VISIBLE else View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private var listener: OnInteractionListener? = null
|
||||||
|
|
||||||
|
private fun addNewDog() {
|
||||||
|
listener?.onAddNewDog()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDogSelected(dogId: Long) {
|
||||||
|
listener?.onDogSelected(dogId)
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class DogListItemTouchHelper : ItemTouchHelper.Callback() {
|
||||||
|
override fun getMovementFlags(
|
||||||
|
recyclerView: RecyclerView,
|
||||||
|
viewHolder: RecyclerView.ViewHolder
|
||||||
|
) =
|
||||||
|
makeMovementFlags(
|
||||||
|
ItemTouchHelper.UP or ItemTouchHelper.DOWN,
|
||||||
|
ItemTouchHelper.START or ItemTouchHelper.END
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun onMove(
|
||||||
|
recyclerView: RecyclerView,
|
||||||
|
viewHolder: RecyclerView.ViewHolder,
|
||||||
|
target: RecyclerView.ViewHolder
|
||||||
|
) = false
|
||||||
|
|
||||||
|
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
|
||||||
|
(viewHolder as DogRecyclerViewAdapter.DogViewHolder).dog?.also {
|
||||||
|
removeDog(it)
|
||||||
|
listener?.onDogSwiped()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun removeDog(dog: Dog) {
|
||||||
|
val dao = DogDatabase.getInstance().dogDAO()
|
||||||
|
dao.delete(dog)
|
||||||
|
updateList()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnInteractionListener {
|
||||||
|
fun onDogSelected(dogId: Long)
|
||||||
|
fun onAddNewDog()
|
||||||
|
fun onDogSwiped()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
super.onAttach(context)
|
||||||
|
if (context is OnInteractionListener) {
|
||||||
|
listener = context
|
||||||
|
} else {
|
||||||
|
throw RuntimeException("$context must implement OnInteractionListener")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetach() {
|
||||||
|
super.onDetach()
|
||||||
|
listener = null
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package fr.uca.iut.myouafff.ui.utils
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
|
import fr.uca.iut.myouafff.data.persistence.DogDatabase
|
||||||
|
import fr.uca.iut.myouafff.ui.fragment.DogFragment
|
||||||
|
|
||||||
|
class DogPagerAdapter(fragmentActivity: FragmentActivity) : FragmentStateAdapter(fragmentActivity) {
|
||||||
|
private var dogList = DogDatabase.getInstance().dogDAO().getAll()
|
||||||
|
|
||||||
|
override fun getItemCount() = dogList.size
|
||||||
|
|
||||||
|
override fun createFragment(position: Int) = DogFragment.newInstance(dogList[position].id)
|
||||||
|
|
||||||
|
fun positionFromId(dogId: Long) = dogList.indexOfFirst { it.id == dogId }
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package fr.uca.iut.myouafff.ui.utils
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.cardview.widget.CardView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import fr.uca.iut.myouafff.R
|
||||||
|
import fr.uca.iut.myouafff.data.Dog
|
||||||
|
|
||||||
|
class DogRecyclerViewAdapter(private var dogList: List<Dog>, private val listener: Callbacks) :
|
||||||
|
RecyclerView.Adapter<DogRecyclerViewAdapter.DogViewHolder>() {
|
||||||
|
override fun getItemCount() = dogList.size
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
|
||||||
|
DogViewHolder(
|
||||||
|
LayoutInflater.from(parent.context).inflate(
|
||||||
|
R.layout.item_list_dog,
|
||||||
|
parent,
|
||||||
|
false
|
||||||
|
), listener
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: DogViewHolder, position: Int) =
|
||||||
|
holder.bind(dogList[position])
|
||||||
|
|
||||||
|
class DogViewHolder(itemView: View, listener: Callbacks) :
|
||||||
|
RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
|
private val viewName = itemView.findViewById<TextView>(R.id.view_name)
|
||||||
|
private val viewBreed = itemView.findViewById<TextView>(R.id.view_breed)
|
||||||
|
private val dogCardview = itemView.findViewById<CardView>(R.id.dog_cardview)
|
||||||
|
|
||||||
|
var dog: Dog? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
init {
|
||||||
|
itemView.setOnClickListener { dog?.let { listener.onDogSelected(it.id) } }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bind(dog: Dog) {
|
||||||
|
this.dog = dog
|
||||||
|
viewName.text = dog.name
|
||||||
|
val context = itemView.context
|
||||||
|
val breed = dog.breed
|
||||||
|
viewBreed.text = breed.ifEmpty { context.getString(R.string.unknown_breed) }
|
||||||
|
val color =
|
||||||
|
context.resources.getIntArray(R.array.aggressiveness_color)[dog.aggressiveness]
|
||||||
|
dogCardview.setCardBackgroundColor(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateList(dogList: List<Dog>) {
|
||||||
|
this.dogList = dogList
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Callbacks {
|
||||||
|
fun onDogSelected(dogId: Long)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:showDividers="middle"
|
||||||
|
android:divider="?android:attr/dividerVertical">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container_fragment"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="3" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container_fragment_detail"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="7" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/pager_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:theme="@style/Theme.MyOuafff.AppBarOverlay"
|
||||||
|
app:elevation="@dimen/toolbar_elevation"
|
||||||
|
app:popupTheme="@style/Theme.MyOuafff.PopupOverlay"
|
||||||
|
app:titleMargin="@dimen/icon_title_space" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,149 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView 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">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="@dimen/activity_margin"
|
||||||
|
tools:context=".ui.activity.DogActivity">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Barrier
|
||||||
|
android:id="@+id/barrier"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:barrierDirection="right"
|
||||||
|
app:constraint_referenced_ids="text_overview,gender_text,measurement_text,aggressiveness_text,misc_text" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_overview"
|
||||||
|
style="@style/CategoryStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/category_overview"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/dog_name_editor"
|
||||||
|
style="@style/EditorFieldStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:hint="@string/hint_dog_name"
|
||||||
|
android:importantForAutofill="no"
|
||||||
|
android:inputType="textCapWords"
|
||||||
|
app:layout_constraintBaseline_toBaselineOf="@+id/text_overview"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/barrier" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/dog_breed_editor"
|
||||||
|
style="@style/EditorFieldStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:hint="@string/hint_dog_breed"
|
||||||
|
android:importantForAutofill="no"
|
||||||
|
android:inputType="textCapWords"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/barrier"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/dog_name_editor"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gender_text"
|
||||||
|
style="@style/CategoryStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/category_gender"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/dog_breed_editor" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/gender_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/large_space"
|
||||||
|
android:entries="@array/array_gender_options"
|
||||||
|
android:spinnerMode="dropdown"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/barrier"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/gender_text" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/measurement_text"
|
||||||
|
style="@style/CategoryStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/category_measurement"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/gender_spinner" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/dog_weight_editor"
|
||||||
|
style="@style/EditorFieldStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:hint="@string/hint_dog_weight"
|
||||||
|
android:importantForAutofill="no"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
app:layout_constraintBaseline_toBaselineOf="@+id/measurement_text"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/weight_unit_label"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/barrier" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/weight_unit_label"
|
||||||
|
style="@style/EditorUnitsStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/unit_dog_weight"
|
||||||
|
app:layout_constraintBaseline_toBaselineOf="@+id/measurement_text"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/dog_weight_editor" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/aggressiveness_text"
|
||||||
|
style="@style/CategoryStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/category_aggressiveness"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/dog_weight_editor" />
|
||||||
|
|
||||||
|
<RatingBar
|
||||||
|
android:id="@+id/aggressiveness_rating_bar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:numStars="3"
|
||||||
|
android:stepSize="1"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/barrier"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/aggressiveness_text" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/misc_text"
|
||||||
|
style="@style/CategoryStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/large_space"
|
||||||
|
android:text="@string/category_misc"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/aggressiveness_rating_bar" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dog_owner_text"
|
||||||
|
style="@style/EditorTextStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:hint="@string/hint_dog_owner"
|
||||||
|
app:drawableEndCompat="@drawable/ic_person"
|
||||||
|
app:drawableRightCompat="@drawable/ic_person"
|
||||||
|
app:layout_constraintBaseline_toBaselineOf="@+id/misc_text"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/barrier" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dog_admission_date_text"
|
||||||
|
style="@style/EditorTextStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:hint="@string/hint_dog_admission_date"
|
||||||
|
android:paddingTop="@dimen/medium_space"
|
||||||
|
app:drawableEndCompat="@drawable/ic_time"
|
||||||
|
app:drawableRightCompat="@drawable/ic_time"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/barrier"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/dog_owner_text" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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=".ui.activity.DogListActivity">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
|
app:spanCount="2"
|
||||||
|
tools:listitem="@layout/item_list_dog" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Group
|
||||||
|
android:id="@+id/group_empty_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:constraint_referenced_ids="shelter_icon,empty_view_title,empty_view_subtitle" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/shelter_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/empty_view_subtitle_text"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/empty_view_title"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
android:src="@drawable/ic_empty_shelter" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_view_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
android:paddingTop="@dimen/medium_space"
|
||||||
|
android:text="@string/empty_view_title_text"
|
||||||
|
android:textAppearance="?android:textAppearanceMedium"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_view_subtitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:paddingTop="@dimen/small_space"
|
||||||
|
android:text="@string/empty_view_subtitle_text"
|
||||||
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/empty_view_title" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab_add_dog"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/activity_margin"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
android:src="@drawable/ic_add_pet"
|
||||||
|
android:contentDescription="@string/new_dog_accessibility_text" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/dog_cardview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="2dp"
|
||||||
|
card_view:cardUseCompatPadding="true">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_cardview_dog"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/view_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
android:textAppearance="?android:textAppearanceMedium"
|
||||||
|
android:textColor="@color/text_black"
|
||||||
|
tools:text="Dog's Name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/view_breed"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
|
android:textColor="@color/text_black_lighter"
|
||||||
|
tools:text="Breed" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout 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"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".ui.activity.DogActivity">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:elevation="@dimen/toolbar_elevation"
|
||||||
|
android:theme="@style/Theme.MyOuafff.AppBarOverlay"
|
||||||
|
app:popupTheme="@style/Theme.MyOuafff.PopupOverlay"
|
||||||
|
app:titleMarginStart="@dimen/icon_title_space" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout 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"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".ui.activity.DogListActivity">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:elevation="@dimen/toolbar_elevation"
|
||||||
|
android:theme="@style/Theme.MyOuafff.AppBarOverlay"
|
||||||
|
app:popupTheme="@style/Theme.MyOuafff.PopupOverlay"
|
||||||
|
app:titleMarginStart="@dimen/icon_title_space" />
|
||||||
|
|
||||||
|
<include layout="@layout/toolbar_md_activity_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,4 @@
|
|||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/container_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_save"
|
||||||
|
android:icon="@drawable/ic_done"
|
||||||
|
android:title="@string/action_save"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_delete"
|
||||||
|
android:icon="@drawable/ic_delete"
|
||||||
|
android:title="@string/action_delete"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
</menu>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_item_new_dog"
|
||||||
|
android:icon="@drawable/ic_add"
|
||||||
|
android:title="@string/new_dog"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
</menu>
|
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">MyOuafff</string>
|
||||||
|
<string name="title_dog_detail">Détail du chien</string>
|
||||||
|
<string name="new_dog">Nouveau chien</string>
|
||||||
|
<string name="dogs_subtitle_format">Chien %d</string>
|
||||||
|
<string name="dialog_date_title">Date d\'admission</string>
|
||||||
|
<string name="dog_deleted">Chien supprimé</string>
|
||||||
|
<string name="delete_dog_failed">Impossible de supprimer le chien</string>
|
||||||
|
<string name="action_save">Sauvegarder</string>
|
||||||
|
<string name="action_delete">Supprimer</string>
|
||||||
|
<string name="unknown_uri_error">"URL inconnue : "</string>
|
||||||
|
<string name="insertion_uri_error">"Insertion non autorisée dans : "</string>
|
||||||
|
<string name="update_uri_error">"Mise à jour non autorisée dans : "</string>
|
||||||
|
<string name="delete_uri_error">"Suppression non autorisée dans : "</string>
|
||||||
|
<string name="title_add_dog">Ajouter un chien</string>
|
||||||
|
|
||||||
|
<string name="category_gender">Genre</string>
|
||||||
|
<string name="category_overview">Identité</string>
|
||||||
|
<string name="category_measurement">Mesure</string>
|
||||||
|
<string name="category_aggressiveness">Agressivité</string>
|
||||||
|
<string name="category_misc">Divers</string>
|
||||||
|
|
||||||
|
<string name="hint_dog_name">Nom</string>
|
||||||
|
<string name="hint_dog_breed">Race</string>
|
||||||
|
<string name="hint_dog_weight">Poids</string>
|
||||||
|
<string name="unit_dog_weight">kg</string>
|
||||||
|
<string name="hint_dog_owner">Propriétaire</string>
|
||||||
|
<string name="hint_dog_admission_date">Date d\'admission</string>
|
||||||
|
|
||||||
|
<string name="gender_unknown">Inconnu</string>
|
||||||
|
<string name="gender_male">Mâle</string>
|
||||||
|
<string name="gender_female">Femelle</string>
|
||||||
|
|
||||||
|
<string name="unknown_breed">Race inconnue</string>
|
||||||
|
|
||||||
|
<string name="empty_view_title_text">C\'est un peu vide par ici…</string>
|
||||||
|
<string name="empty_view_subtitle_text">Commençons par ajouter un chien</string>
|
||||||
|
<string name="create_dog_error_dialog_title">Impossible de créer le chien</string>
|
||||||
|
<string name="create_dog_error_message">Le nom du chien et son poids ne peuvent pas être vides.</string>
|
||||||
|
<string name="new_dog_accessibility_text">Un bouton de raccourci pour ajouter un nouveau chien</string>
|
||||||
|
</resources>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string-array name="array_gender_options">
|
||||||
|
<item>@string/gender_unknown</item>
|
||||||
|
<item>@string/gender_male</item>
|
||||||
|
<item>@string/gender_female</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<array name="aggressiveness_color">
|
||||||
|
<item>@color/colorNice</item>
|
||||||
|
<item>@color/colorNormal</item>
|
||||||
|
<item>@color/colorBad</item>
|
||||||
|
<item>@color/colorDevil</item>
|
||||||
|
</array>
|
||||||
|
</resources>
|
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<item type="id" name="view_pager" />
|
||||||
|
</resources>
|
@ -1,6 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">MyOuafff</string>
|
<string name="app_name">MyOuafff</string>
|
||||||
|
<string name="title_dog_detail">Dog detail</string>
|
||||||
|
<string name="new_dog">New dog</string>
|
||||||
|
<string name="dogs_subtitle_format">Dog %d</string>
|
||||||
|
<string name="dialog_date_title">Admission date of the dog:</string>
|
||||||
|
<string name="dog_deleted">Dog deleted</string>
|
||||||
|
<string name="delete_dog_failed">Failed to delete dog</string>
|
||||||
|
<string name="action_save">Save</string>
|
||||||
|
<string name="action_delete">Delete</string>
|
||||||
|
<string name="unknown_uri_error">"Unknown URL: "</string>
|
||||||
|
<string name="insertion_uri_error">"Insertion not allowed: "</string>
|
||||||
|
<string name="update_uri_error">"Update not allowed: "</string>
|
||||||
|
<string name="delete_uri_error">"Delete not allowed: "</string>
|
||||||
<string name="title_add_dog">Add a dog</string>
|
<string name="title_add_dog">Add a dog</string>
|
||||||
|
|
||||||
|
<string name="category_overview">Overview</string>
|
||||||
|
<string name="category_gender">Gender</string>
|
||||||
|
<string name="category_measurement">Measurement</string>
|
||||||
|
<string name="category_aggressiveness">Aggressiveness</string>
|
||||||
|
<string name="category_misc">Miscellaneous</string>
|
||||||
|
|
||||||
|
<string name="hint_dog_name">Name</string>
|
||||||
|
<string name="hint_dog_breed">Breed</string>
|
||||||
|
<string name="hint_dog_weight">Weight</string>
|
||||||
|
<string name="unit_dog_weight">kg</string>
|
||||||
|
<string name="hint_dog_owner">Owner</string>
|
||||||
|
<string name="hint_dog_admission_date">Admission date</string>
|
||||||
|
|
||||||
|
<string name="gender_unknown">Unknown</string>
|
||||||
|
<string name="gender_male">Male</string>
|
||||||
|
<string name="gender_female">Female</string>
|
||||||
|
|
||||||
|
<string name="unknown_breed">Unknown breed</string>
|
||||||
|
|
||||||
|
<string name="empty_view_title_text">It\'s a bit lonely here…</string>
|
||||||
|
<string name="empty_view_subtitle_text">Get started by adding a pet</string>
|
||||||
<string name="create_dog_error_dialog_title">Cannot create the dog</string>
|
<string name="create_dog_error_dialog_title">Cannot create the dog</string>
|
||||||
<string name="create_dog_error_message">Dog\'s name or weight cannot be empty</string>
|
<string name="create_dog_error_message">Dog\'s name and weight cannot be empty.</string>
|
||||||
</resources>
|
<string name="new_dog_accessibility_text">A shortcut button to add a new dog</string>
|
||||||
|
</resources>
|
||||||
|
Loading…
Reference in new issue