diff --git a/.DS_Store b/.DS_Store index 938051f6423de17db660b1124187ac42d0379550..52a72a3ff8768a8f1b86ca731e57d0f3c78dbc09 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/MushroomsTracker/app/build.gradle b/MushroomsTracker/app/build.gradle index f786fd9c6d90de613fe9135617c69894063d7f72..de35eb379292be45426dcd2562e53bf2a626268a 100644 --- a/MushroomsTracker/app/build.gradle +++ b/MushroomsTracker/app/build.gradle @@ -6,12 +6,12 @@ plugins { android { namespace 'com.example.mushroomstracker' - compileSdk 33 + compileSdk 32 defaultConfig { applicationId "com.example.mushroomstracker" minSdk 29 - targetSdk 33 + targetSdk 32 versionCode 1 versionName "1.0" @@ -44,6 +44,6 @@ dependencies { implementation 'com.google.android.gms:play-services-location:18.0.0' implementation 'com.google.maps.android:android-maps-utils:2.2.3' implementation 'com.google.maps.android:maps-utils-ktx:3.2.0' - implementation 'androidx.sqlite:sqlite-ktx:2.3.0' + implementation 'com.google.android.material:material:1.4.0' } \ No newline at end of file diff --git a/MushroomsTracker/app/src/main/AndroidManifest.xml b/MushroomsTracker/app/src/main/AndroidManifest.xml index a9d63864b8e625fb4fdc8f57cfaf2b3455723444..9ac4b6de6edc3f21d540e6f3bdeeda2031b05e46 100644 --- a/MushroomsTracker/app/src/main/AndroidManifest.xml +++ b/MushroomsTracker/app/src/main/AndroidManifest.xml @@ -16,7 +16,9 @@ android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> - <activity android:name=".MainActivity" + <activity + android:name=".MapsActivity" + android:theme="@style/SplashTheme" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -24,11 +26,6 @@ <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> - <activity - android:name=".MapsActivity" - android:theme="@style/SplashTheme" - android:exported="true"> - </activity> <meta-data android:name="com.google.android.geo.API_KEY" diff --git a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/DatabaseHelper.kt b/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/DatabaseHelper.kt deleted file mode 100644 index 9d26aa677dc4b39fd75d6540cddd801265d94889..0000000000000000000000000000000000000000 --- a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/DatabaseHelper.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.mushroomstracker - -import android.content.Context -import android.database.sqlite.SQLiteDatabase -import android.database.sqlite.SQLiteOpenHelper - -class DatabaseHelper(context: Context) : SQLiteOpenHelper(context, "database.db", null, 1) { - override fun onCreate(db: SQLiteDatabase?) { - val cueilletteTable = "CREATE TABLE CUEILLETTE(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, COMMENTAIRE TEXT);" - db?.execSQL(cueilletteTable) - val parcoursTable = "CREATE TABLE PARCOURS(LONGITUDE REAL NOT NULL, LATITUDE REAL NOT NULL, ID_CUEILLETTE INTEGER NOT NULL, FOREIGN KEY (ID_CUEILLETTE) REFERENCES CUEILLETTE(ID));" - db?.execSQL(parcoursTable) - val mushroomTable = "CREATE TABLE CHAMPIGNON(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, DESCRIPTION TEXT, DATE TEXT NOT NULL, QUANTITY INTEGER NOT NULL, IMAGE TEXT, LONGITUDE REAL NOT NULL, LATITUDE REAL NOT NULL, ID_CUEILLETTE INTEGER NOT NULL, FOREIGN KEY (ID_CUEILLETTE) REFERENCES CUEILLETTE(ID));" - db?.execSQL(mushroomTable) - } - - override fun onUpgrade(db: SQLiteDatabase?, p1: Int, p2: Int) { - db?.execSQL("DROP TABLE IF EXISTS CHAMPIGNON") - db?.execSQL("DROP TABLE IF EXISTS PARCOURS") - db?.execSQL("DROP TABLE IF EXISTS CUEILLETTE") - if (db != null) { - onCreate(db) - } - } -} \ No newline at end of file diff --git a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MainActivity.kt b/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MainActivity.kt deleted file mode 100644 index ba6a38795c1522f5d908c0467057f32e3856038d..0000000000000000000000000000000000000000 --- a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MainActivity.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.example.mushroomstracker - -import MyAdapter -import android.content.Intent -import android.os.Bundle -import android.widget.Button -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.floatingactionbutton.FloatingActionButton - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - val button = findViewById<Button>(R.id.button_new_picking) - button.setOnClickListener { - Toast.makeText(this, "je clique", Toast.LENGTH_LONG) - val intent = Intent(this, MapsActivity::class.java) - startActivity(intent) - } - val data = listOf("Item 1", "Item 2", "Item 3") - val recyclerView = findViewById<RecyclerView>(R.id.recycler_view) - recyclerView.layoutManager = LinearLayoutManager(this) - recyclerView.adapter = MyAdapter(data) - } -} \ No newline at end of file diff --git a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MapsActivity.kt b/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MapsActivity.kt index 7d26d337ffe0a4788616c1d55ad90585d299e7bd..09f56a7e2343df98c96f5b6cf93f6782d2bd716f 100644 --- a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MapsActivity.kt +++ b/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MapsActivity.kt @@ -1,19 +1,12 @@ package com.example.mushroomstracker -import android.Manifest import android.annotation.SuppressLint -import android.content.ContentValues -import android.content.Context -import android.content.pm.PackageManager -import android.location.Location -import android.location.LocationManager import android.os.Bundle import android.os.SystemClock import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity -import androidx.core.app.ActivityCompat import com.example.mushroomstracker.databinding.ActivityMapsBinding import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.GoogleMap @@ -23,7 +16,6 @@ import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.Marker import com.google.android.gms.maps.model.MarkerOptions import com.google.android.gms.maps.model.PolylineOptions -import java.time.LocalDate class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarkerClickListener { private lateinit var map: GoogleMap @@ -96,7 +88,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker map.addPolyline(polylineOptions) } - @SuppressLint("InflateParams", "ServiceCast") + @SuppressLint("InflateParams") private fun placeMarkerOnMap(location: LatLng){ Toast.makeText(this, "HELP", Toast.LENGTH_SHORT).show() val builder = AlertDialog.Builder(this) @@ -105,25 +97,6 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker val dialogLayout = inflater.inflate(R.layout.new_marker, null) builder.setView(dialogLayout) - if (ActivityCompat.checkSelfPermission( - this, - Manifest.permission.ACCESS_FINE_LOCATION - ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( - this, - Manifest.permission.ACCESS_COARSE_LOCATION - ) != PackageManager.PERMISSION_GRANTED - ) { - // Demande les autorisations si elles ne sont pas accordées - ActivityCompat.requestPermissions( - this, - arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), - 1 - ) - return - } - - val db = DatabaseHelper(this).writableDatabase - val title = dialogLayout.findViewById<EditText>(R.id.markerTitleEditText) val description = dialogLayout.findViewById<EditText>(R.id.markerDescriptionEditText) val quantity = dialogLayout.findViewById<EditText>(R.id.markerQuantiteEditText) @@ -133,23 +106,6 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker marker.title(title.text.toString()) marker.snippet("Description : " + description.text.toString() + "\n" + "Quantité : " + quantity.text.toString()) map.addMarker(marker) - val content = ContentValues() - content.put("name", title.text.toString()) - content.put("description", description.text.toString()) - content.put("quantity", quantity.text.toString().toInt()) - content.put("date", LocalDate.now().toString()) - - val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager - val location: Location? = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) - println(location?.longitude) - println(location?.latitude) - if (location != null) { - content.put("longitude", location.longitude) - content.put("latitude", location.latitude) - } - content.put("id_cueillette", 1) // id cueillette a gerer !! - db.insert("CHAMPIGNON", null, content) - db.close() } builder.setNegativeButton("Fermer") { _, _ -> } diff --git a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MyAdapter.kt b/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MyAdapter.kt deleted file mode 100644 index 93440f29a460ae2966691b53ada8e7648661763f..0000000000000000000000000000000000000000 --- a/MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MyAdapter.kt +++ /dev/null @@ -1,40 +0,0 @@ -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView -import com.example.mushroomstracker.R - -class MyAdapter(private val mList: List<String>) : RecyclerView.Adapter<MyAdapter.ViewHolder>() { - - // create new views - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - // inflates the card_view_design view - // that is used to hold list item - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.item_layout, parent, false) - - return ViewHolder(view) - } - - // binds the list items to a view - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - - val ItemsViewModel = mList[position] - - // sets the text to the textview from our itemHolder class - holder.textView.text = ItemsViewModel - - } - - // return the number of the items in the list - override fun getItemCount(): Int { - return mList.size - } - - // Holds the views for adding it to image and text - class ViewHolder(ItemView: View) : RecyclerView.ViewHolder(ItemView) { - val textView: TextView = itemView.findViewById(R.id.text_view) - } -} diff --git a/MushroomsTracker/app/src/main/res/layout/activity_main.xml b/MushroomsTracker/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 41ab03c8292b4e511b6421543960a8edadb9dafc..0000000000000000000000000000000000000000 --- a/MushroomsTracker/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto"> - - <Button - android:id="@+id/button_new_picking" - android:layout_width="388dp" - android:layout_height="48dp" - android:text="@string/main_new_picking" - tools:ignore="MissingConstraints" - tools:layout_editor_absoluteX="16dp" - tools:layout_editor_absoluteY="16dp" /> - - <androidx.recyclerview.widget.RecyclerView - android:id="@+id/recycler_view" - android:layout_width="376dp" - android:layout_height="623dp" - tools:ignore="MissingConstraints" - tools:layout_editor_absoluteX="0dp" - tools:layout_editor_absoluteY="147dp" - app:layout_constraintEnd_toEndOf="@id/button_new_picking" - app:layout_constraintStart_toStartOf="@+id/button_new_picking" - app:layout_constraintTop_toTopOf="@id/button_new_picking"/> - -</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/MushroomsTracker/app/src/main/res/layout/item_layout.xml b/MushroomsTracker/app/src/main/res/layout/item_layout.xml deleted file mode 100644 index 05a58fa80ca288c904c6ecb01bcc119fd6cefafe..0000000000000000000000000000000000000000 --- a/MushroomsTracker/app/src/main/res/layout/item_layout.xml +++ /dev/null @@ -1,13 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> - - <TextView - android:id="@+id/text_view" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="TextView" - android:textSize="20sp" /> - -</LinearLayout> diff --git a/MushroomsTracker/app/src/main/res/values/strings.xml b/MushroomsTracker/app/src/main/res/values/strings.xml index cbd8ac3dfd3eb8971ee926eefa4953b0802636af..68fa3fb9586fa95c68a5a01ceb1b025096e25c13 100644 --- a/MushroomsTracker/app/src/main/res/values/strings.xml +++ b/MushroomsTracker/app/src/main/res/values/strings.xml @@ -13,5 +13,4 @@ <string name="display_marker_title">Nom du champignon</string> <string name="display_marker_description">Description</string> <string name="display_marker_quantite">Quantité</string> - <string name="main_new_picking">Nouvelle cueillette</string> </resources> diff --git a/MushroomsTracker/build.gradle b/MushroomsTracker/build.gradle index 120a780192a72995e10c46b4200adfd17c5a69e4..cf11c024464d3e2cddef15af0ce6770aa3e1539e 100644 --- a/MushroomsTracker/build.gradle +++ b/MushroomsTracker/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '7.2.2' apply false - id 'com.android.library' version '7.2.2' apply false + id 'com.android.application' version '7.3.1' apply false + id 'com.android.library' version '7.3.1' apply false id 'org.jetbrains.kotlin.android' version '1.7.20' apply false id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false } \ No newline at end of file