Commit 7831ea9b authored by m-spi's avatar m-spi

Merge branch 'master' into matis

# Conflicts:
#	app/src/main/res/layout/activity_main.xml
parents 946609c5 091f7a15
......@@ -2,9 +2,25 @@
<project version="4">
<component name="deploymentTargetDropDown">
<value>
<entry key="app">
<entry key="Basic">
<State />
</entry>
<entry key="app">
<State>
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Medium_Phone_API_34.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-02-20T19:11:44.730496602Z" />
</State>
</entry>
</value>
</component>
</project>
\ No newline at end of file
......@@ -12,6 +12,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.ElBuenoPeso"
tools:targetApi="31">
<activity
android:name=".AboutActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true"
......
package com.example.elbuenopeso
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class AboutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_about)
}
}
\ No newline at end of file
package com.example.elbuenopeso
import android.content.Intent
import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.example.elbuenopeso.databinding.ActivityMainBinding
import com.google.android.material.bottomnavigation.BottomNavigationView
class MainActivity : AppCompatActivity() {
......@@ -22,6 +26,7 @@ class MainActivity : AppCompatActivity() {
val navView: BottomNavigationView = binding.navView
val navController = findNavController(R.id.nav_host_fragment_activity_main)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
val appBarConfiguration = AppBarConfiguration(
......@@ -29,7 +34,32 @@ class MainActivity : AppCompatActivity() {
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_add
)
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.about -> {
// Start AboutActivity when "About" menu item is selected
startActivity(Intent(this, AboutActivity::class.java))
return true
}
R.id.settings -> {
Toast.makeText(this, "Settings Selected", Toast.LENGTH_SHORT).show()
return true
}
R.id.exit -> {
Toast.makeText(this, "Exit Selected", Toast.LENGTH_SHORT).show()
return true
}
else -> return super.onOptionsItemSelected(item)
}
}
}
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.TextView
import com.example.elbuenopeso.R
import com.example.elbuenopeso.models.AdModel
class AdAdapter(private val context: Context, private val adModelArrayList: List<AdModel>) : BaseAdapter() {
private val inflater: LayoutInflater = LayoutInflater.from(context)
override fun getCount(): Int = adModelArrayList.size
override fun getItem(i: Int): Any = adModelArrayList[i]
override fun getItemId(i: Int): Long = i.toLong()
fun usingJavaStringFormat(input: Double, scale: Int) = String.format("%.${scale}f", input)
override fun getView(i: Int, view: View?, viewGroup: ViewGroup): View {
var convertView = view
val ad = adModelArrayList[i]
convertView = inflater.inflate(R.layout.item_listview_ad, viewGroup, false)
val imageIV: ImageView = convertView.findViewById(R.id.itemListViewImageView)
val titleTV: TextView = convertView.findViewById(R.id.itemListViewTitleView)
val addressTV: TextView = convertView.findViewById(R.id.itemListViewTextView)
val prixTV: TextView = convertView.findViewById(R.id.itemListViewPrixView)
imageIV.setImageResource(ad.image)
titleTV.text = ad.title
addressTV.text = ad.address
prixTV.text = "${usingJavaStringFormat(ad.prix, 2)} €"
return convertView
}
}
\ No newline at end of file
package com.example.elbuenopeso.models
public class AdModel(var title: String, var address: String, var image: Int, var prix: Double) {
}
\ No newline at end of file
package com.example.elbuenopeso.ui.dashboard
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import com.example.elbuenopeso.databinding.FragmentDashboardBinding
class DashboardFragment : Fragment() {
private var _binding: FragmentDashboardBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val dashboardViewModel =
ViewModelProvider(this).get(DashboardViewModel::class.java)
_binding = FragmentDashboardBinding.inflate(inflater, container, false)
val root: View = binding.root
val textView: TextView = binding.textDashboard
dashboardViewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}
binding.button6.setOnClickListener {
// TODO
}
return root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
\ No newline at end of file
package com.example.elbuenopeso.ui.market
import AdAdapter
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ListView
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.example.elbuenopeso.databinding.FragmentMarketBinding
import com.example.elbuenopeso.models.AdModel
import com.example.elbuenopeso.R
class MarketFragment : Fragment() {
private var _binding: FragmentMarketBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val marketViewModel =
ViewModelProvider(this)[MarketViewModel::class.java]
_binding = FragmentMarketBinding.inflate(inflater, container, false)
val root: View = binding.root
val listView: ListView = binding.listView
// seed market items
var annonces: List<AdModel> = listOf<AdModel>(
AdModel("Poutre", "1 rue Jean-Pierre", R.drawable.pichu, 25.0),
AdModel("Briques", "2 rue Jean-Michel", R.drawable.pichu, 16.0),
AdModel("Mur en bois", "4 rue Alain-Juju", R.drawable.pichu, 7.2),
AdModel("Maison de pierre", "7 rue Joris Belhomme", R.drawable.pichu, 3.99),
AdModel("Téléphone de Timothé", "8 rue de Timothé", R.drawable.pichu, 0.85),
AdModel("Oridnateur", "10 rue Jean-Charles", R.drawable.pichu, 104.98),
AdModel("Charnières", "22 rue Jeanne-Marie", R.drawable.pichu, 2648.97),
AdModel("Porte en marbre", "1 rue Jean-Pierre", R.drawable.pichu, 480.0),
AdModel("Cheminée", "33 rue du Gouvernement", R.drawable.pichu, 800.0),
)
var adAdapter: AdAdapter = AdAdapter(requireContext(), annonces)
listView.adapter = adAdapter
/*marketViewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}*/
return root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
\ No newline at end of file
package com.example.elbuenopeso.ui.dashboard
package com.example.elbuenopeso.ui.market
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
class DashboardViewModel : ViewModel() {
class MarketViewModel : ViewModel() {
private val _text = MutableLiveData<String>().apply {
value = "This is dashboard Fragment"
value = "This is market Fragment"
}
val text: LiveData<String> = _text
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromXDelta="-100%p"
android:toXDelta="100%p"
android:repeatCount="infinite"
android:duration="5000" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Appbar with Toolbar -->
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:title="About"
app:navigationIcon="@drawable/ic_launcher_foreground"
app:navigationContentDescription="Back"
app:layout_scrollFlags="scroll|enterAlways" />
</com.google.android.material.appbar.AppBarLayout>
<!-- Scrollable content -->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- Main content -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- Project Description -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This project is a replica of Leboncoin."
android:textSize="18sp"
android:layout_marginBottom="8dp"/>
<!-- Developers -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Developed by:"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Arthur Mata"
android:textSize="16sp"
android:layout_marginBottom="4dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Matis Spineli"
android:textSize="16sp"
android:layout_marginBottom="4dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timothé Kobak"
android:textSize="16sp"
android:layout_marginBottom="16dp"/>
<!-- Technology -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Technology:"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kotlin and Android Studio"
android:textSize="16sp"
android:layout_marginBottom="16dp"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<?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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -14,9 +13,11 @@
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@+id/nav_view"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:navGraph="@navigation/mobile_navigation"
tools:ignore="FragmentTagUsage" />
......
......@@ -10,25 +10,27 @@
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="354dp"
android:layout_marginTop="4dp"
android:src="@drawable/marketplace"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/text_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_width="359dp"
android:layout_height="44dp"
android:shadowColor="#F5A623"
android:shadowDx="12"
android:shadowDy="12"
android:shadowRadius="8"
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/imageView"
app:layout_constraintVertical_bias="0.051" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.042" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -4,6 +4,14 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".test">
tools:context=".ui.market.MarketFragment">
<ListView
android:id="@+id/listView"
android:layout_width="409dp"
android:layout_height="681dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -3,30 +3,40 @@
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.dashboard.DashboardFragment">
android:layout_height="match_parent">
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:id="@+id/itemListViewTitleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:text="TextView"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@+id/itemListViewImageView"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button6"
<ImageView
android:id="@+id/itemListViewImageView"
android:layout_width="117dp"
android:layout_height="94dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@drawable/pichu" />
<TextView
android:id="@+id/itemListViewTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBottom_toTopOf="@+id/text_dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:text="TextView"
app:layout_constraintBottom_toBottomOf="@+id/itemListViewImageView"
app:layout_constraintStart_toEndOf="@+id/itemListViewImageView" />
<TextView
android:id="@+id/itemListViewPrixView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toTopOf="@+id/itemListViewTextView"
app:layout_constraintStart_toEndOf="@+id/itemListViewImageView"
app:layout_constraintTop_toBottomOf="@+id/itemListViewTitleView" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -16,4 +16,6 @@
android:icon="@drawable/baseline_add_24"
android:title="Add" />
</menu>
\ No newline at end of file
<?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/overflowMenu"
android:icon="@android:drawable/ic_menu_preferences"
android:title=""
app:showAsAction="always">
<menu>
<item
android:id="@+id/settings"
android:icon="@android:drawable/ic_menu_manage"
android:title="SETTINGS"
app:showAsAction="never" />
<item
android:id="@+id/about"
android:icon="@android:drawable/ic_menu_info_details"
android:title="ABOUT"
app:showAsAction="never" />
<item
android:id="@+id/exit"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:title="EXIT"
app:showAsAction="never" />
</menu>
</item>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>
\ No newline at end of file
......@@ -13,9 +13,9 @@
<fragment
android:id="@+id/navigation_dashboard"
android:name="com.example.elbuenopeso.ui.dashboard.DashboardFragment"
android:name="com.example.elbuenopeso.ui.market.MarketFragment"
android:label="@string/title_dashboard"
tools:layout="@layout/fragment_dashboard" />
tools:layout="@layout/fragment_market" />
<fragment
android:id="@+id/navigation_add"
......
<resources>
<string name="app_name">ElBuenoPeso</string>
<string name="title_home">Home</string>
<string name="title_dashboard">Dashboard</string>
<string name="title_notifications">Notifications</string>
<string name="title_dashboard">Market</string>
<string name="title_notifications">Publication</string>
<string name="todo">TODO</string>
<string name="address">Address</string>
<string name="send">Send</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment