mirror of
https://github.com/Aviortheking/CA_Contest.git
synced 2025-04-22 02:42:10 +00:00
Actions sur page d'accueil
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
f02b529405
commit
7e30aa80b4
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Membres sur le projet:
|
||||||
|
- Florian BOUILLON
|
||||||
|
- Camille NAULET
|
||||||
|
|
||||||
|
GROUPE 4
|
@ -11,13 +11,14 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.CA_Contest"
|
android:theme="@style/Theme.CA_Contest"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
<activity android:name=".CalendarActivity"></activity>
|
<activity android:name=".CalendarActivity"
|
||||||
|
android:theme="@style/Theme.CA_Contest.NoActionBar"
|
||||||
|
/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".CountrySelectorActivity"
|
android:name=".CountrySelectorActivity"
|
||||||
android:label="@string/title_activity_country_selector"
|
android:label="@string/title_activity_country_selector"
|
||||||
android:theme="@style/Theme.CA_Contest.NoActionBar" />
|
android:theme="@style/Theme.CA_Contest.NoActionBar" />
|
||||||
<activity android:name=".CountrySelectorActivity"></activity>
|
<activity android:name=".MainActivity" android:theme="@style/Theme.CA_Contest.NoActionBar">
|
||||||
<activity android:name=".MainActivity">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package com.example.ca_contest
|
package com.example.ca_contest
|
||||||
|
|
||||||
import android.app.DatePickerDialog
|
import android.app.DatePickerDialog
|
||||||
|
import android.content.Intent
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.Button
|
||||||
import android.widget.DatePicker
|
import android.widget.DatePicker
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.example.ca_contest.api.Country
|
import com.example.ca_contest.dao.AppDatabaseHelper
|
||||||
|
import com.example.ca_contest.dao.Country
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -19,23 +22,34 @@ class CalendarActivity : AppCompatActivity() {
|
|||||||
val name=intent.getStringExtra("name")
|
val name=intent.getStringExtra("name")
|
||||||
val capital=intent.getStringExtra("capital")
|
val capital=intent.getStringExtra("capital")
|
||||||
val region=intent.getStringExtra("region")
|
val region=intent.getStringExtra("region")
|
||||||
|
val code = intent.getStringExtra("code")
|
||||||
|
var date = Date(0)
|
||||||
|
|
||||||
val datePicker = findViewById<DatePicker>(R.id.date)
|
val datePicker = findViewById<DatePicker>(R.id.date)
|
||||||
|
|
||||||
val today = Calendar.getInstance()
|
val today = Calendar.getInstance()
|
||||||
datePicker.init(today.get(Calendar.YEAR), today.get(Calendar.MONTH),
|
datePicker.init(
|
||||||
|
today.get(Calendar.YEAR),
|
||||||
|
today.get(Calendar.MONTH),
|
||||||
today.get(Calendar.DAY_OF_MONTH)
|
today.get(Calendar.DAY_OF_MONTH)
|
||||||
|
) { _, year, month, day ->
|
||||||
) { view, year, month, day ->
|
date = Date(year, month, day)
|
||||||
val month = month + 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addDate(view: View) {
|
val validateur = findViewById<Button>(R.id.add_date)
|
||||||
// val listCountry: List<Country> = AppDatabaseHelper
|
validateur.setOnClickListener {
|
||||||
// .getDatabase(this)
|
AppDatabaseHelper
|
||||||
// .countryDAO()
|
.getDatabase(this)
|
||||||
// .insert()
|
.countryDAO()
|
||||||
|
.insert(Country(
|
||||||
|
country = name,
|
||||||
|
capitalCity = capital,
|
||||||
|
continent = region,
|
||||||
|
code = code,
|
||||||
|
date = date
|
||||||
|
))
|
||||||
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,4 +40,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
this.finishAffinity()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ class CountryAdapter(list: ArrayList<Country>) : RecyclerView.Adapter<CountryAda
|
|||||||
.putExtra("name", list[adapterPosition].name)
|
.putExtra("name", list[adapterPosition].name)
|
||||||
.putExtra("capital", list[adapterPosition].capital)
|
.putExtra("capital", list[adapterPosition].capital)
|
||||||
.putExtra("region", list[adapterPosition].region)
|
.putExtra("region", list[adapterPosition].region)
|
||||||
|
.putExtra("code", list[adapterPosition].alpha2Code)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
package com.example.ca_contest.adapters
|
package com.example.ca_contest.adapters
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import com.example.ca_contest.R
|
import com.example.ca_contest.R
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.example.ca_contest.dao.AppDatabaseHelper
|
||||||
import com.example.ca_contest.dao.Country
|
import com.example.ca_contest.dao.Country
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
|
import java.text.DateFormat
|
||||||
|
|
||||||
// Adapter for the homepage
|
// Adapter for the homepage
|
||||||
class HomepageCountryAdapter(list: List<Country>) : RecyclerView.Adapter<HomepageCountryAdapter.CountryViewHolder>() {
|
class HomepageCountryAdapter(list: List<Country>) : RecyclerView.Adapter<HomepageCountryAdapter.CountryViewHolder>() {
|
||||||
@ -30,12 +32,22 @@ class HomepageCountryAdapter(list: List<Country>) : RecyclerView.Adapter<Homepag
|
|||||||
// Bind each items
|
// Bind each items
|
||||||
override fun onBindViewHolder(holder: CountryViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: CountryViewHolder, position: Int) {
|
||||||
holder.name?.text = list[position].country
|
holder.name?.text = list[position].country
|
||||||
holder.capital?.text = "Capital : " + list[position].capitalCity
|
holder.capital?.text = "Capital : " + list[position].capitalCity
|
||||||
holder.date?.text = list[position].date.toString()
|
holder.date?.text = DateFormat.getDateInstance(DateFormat.MEDIUM).format(list[position].date)
|
||||||
holder.region?.text = "Continent : " + list[position].continent
|
holder.region?.text = "Continent : " + list[position].continent
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.load("http://www.geognos.com/api/en/countries/flag/" + list[position].code + ".png")
|
.load("http://www.geognos.com/api/en/countries/flag/" + list[position].code + ".png")
|
||||||
.into(holder.image!!)
|
.into(holder.image!!)
|
||||||
|
holder.button.setOnClickListener {
|
||||||
|
AppDatabaseHelper
|
||||||
|
.getDatabase(holder.context)
|
||||||
|
.countryDAO()
|
||||||
|
.delete(list[position].countryId)
|
||||||
|
val newList = ArrayList(list)
|
||||||
|
newList.removeAt(position)
|
||||||
|
list = newList
|
||||||
|
this.notifyItemRemoved(position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the list
|
// Update the list
|
||||||
@ -53,6 +65,8 @@ class HomepageCountryAdapter(list: List<Country>) : RecyclerView.Adapter<Homepag
|
|||||||
var region: TextView? = null
|
var region: TextView? = null
|
||||||
var date: TextView? = null
|
var date: TextView? = null
|
||||||
var image: ImageView? = null
|
var image: ImageView? = null
|
||||||
|
var button: ImageView
|
||||||
|
var context: Context
|
||||||
|
|
||||||
init {
|
init {
|
||||||
name = itemView.findViewById(R.id.country)
|
name = itemView.findViewById(R.id.country)
|
||||||
@ -60,6 +74,8 @@ class HomepageCountryAdapter(list: List<Country>) : RecyclerView.Adapter<Homepag
|
|||||||
capital = itemView.findViewById(R.id.capital)
|
capital = itemView.findViewById(R.id.capital)
|
||||||
region = itemView.findViewById(R.id.continent)
|
region = itemView.findViewById(R.id.continent)
|
||||||
image = itemView.findViewById(R.id.image)
|
image = itemView.findViewById(R.id.image)
|
||||||
|
button = itemView.findViewById(R.id.delete)
|
||||||
|
context = itemView.context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ abstract class CountryDAO {
|
|||||||
abstract fun insert(vararg country: Country)
|
abstract fun insert(vararg country: Country)
|
||||||
@Update
|
@Update
|
||||||
abstract fun update(vararg country: Country)
|
abstract fun update(vararg country: Country)
|
||||||
@Delete
|
@Query("DELETE FROM country WHERE countryId = :id")
|
||||||
abstract fun delete(vararg country: Country)
|
abstract fun delete(id: Long)
|
||||||
}
|
}
|
@ -8,31 +8,32 @@
|
|||||||
android:gravity = "center"
|
android:gravity = "center"
|
||||||
tools:context=".CalendarActivity">
|
tools:context=".CalendarActivity">
|
||||||
|
|
||||||
<include layout="@layout/toolbar"/>
|
<include
|
||||||
|
android:id="@+id/include2"
|
||||||
|
layout="@layout/toolbar" />
|
||||||
|
|
||||||
|
|
||||||
<DatePicker
|
<DatePicker
|
||||||
android:id="@+id/date"
|
android:id="@+id/date"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:calendarTextColor="@color/purple_200"
|
||||||
android:datePickerMode="calendar"
|
android:datePickerMode="calendar"
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
android:calendarTextColor="@color/purple_200">
|
app:layout_constraintTop_toBottomOf="@+id/include2"></DatePicker>
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/add_date"
|
android:id="@+id/add_date"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:background="@color/purple_200"
|
android:background="@color/validation"
|
||||||
android:onClick="addDate"
|
|
||||||
android:text="Valider"
|
android:text="Valider"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
|
app:backgroundTint="@color/validation"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"/>
|
app:layout_constraintRight_toRightOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -6,19 +6,23 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".CountrySelectorActivity">
|
tools:context=".CountrySelectorActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/include"
|
||||||
|
layout="@layout/toolbar" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/text"
|
android:id="@+id/text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="70dp"
|
android:layout_height="70dp"
|
||||||
android:background="#eee"
|
android:background="#eee"
|
||||||
android:hint="Nom du pays"
|
android:hint="Nom du pays"
|
||||||
android:paddingLeft="16px"
|
|
||||||
android:inputType="textCapSentences"
|
android:inputType="textCapSentences"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
|
android:paddingLeft="16px"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/validate"
|
app:layout_constraintEnd_toStartOf="@+id/validate"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toBottomOf="@+id/include" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/validate"
|
android:id="@+id/validate"
|
||||||
@ -30,7 +34,7 @@
|
|||||||
app:backgroundTint="@color/button"
|
app:backgroundTint="@color/button"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/list"
|
app:layout_constraintBottom_toTopOf="@+id/list"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toBottomOf="@+id/include" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/include"
|
||||||
|
layout="@layout/toolbar" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/list_country"
|
android:id="@+id/list_country"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -15,7 +19,7 @@
|
|||||||
app:layout_constraintBottom_toTopOf="@+id/bouton_retour"
|
app:layout_constraintBottom_toTopOf="@+id/bouton_retour"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toBottomOf="@+id/include" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bouton_retour"
|
android:id="@+id/bouton_retour"
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#123459"
|
android:background="@color/colorPrimary">
|
||||||
android:id="@+id/toolbar">
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="World Visit"
|
android:text="World Visit"
|
||||||
android:textSize="23sp"
|
android:textColor="@color/white"
|
||||||
android:textColor="@color/white">
|
android:textSize="23sp"></TextView>
|
||||||
</TextView>
|
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
@ -7,6 +7,7 @@
|
|||||||
<color name="teal_700">#FF018786</color>
|
<color name="teal_700">#FF018786</color>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="colorPrimary">#123459</color>
|
||||||
<color name="button">#CD4E61</color>
|
<color name="button">#CD4E61</color>
|
||||||
<color name="validation">#2ECB60</color>
|
<color name="validation">#2ECB60</color>
|
||||||
</resources>
|
</resources>
|
@ -2,15 +2,15 @@
|
|||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.CA_Contest" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="Theme.CA_Contest" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
<item name="colorPrimary">@color/purple_500</item>
|
<item name="colorPrimary">@color/button</item>
|
||||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
<item name="colorPrimaryVariant">@color/button</item>
|
||||||
<item name="colorOnPrimary">@color/white</item>
|
<item name="colorOnPrimary">@color/white</item>
|
||||||
<!-- Secondary brand color. -->
|
<!-- Secondary brand color. -->
|
||||||
<item name="colorSecondary">@color/teal_200</item>
|
<item name="colorSecondary">@color/button</item>
|
||||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
<item name="colorSecondaryVariant">@color/button</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/white</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor" tools:targetApi="l">#0d253c</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user