From a0fb77808e660e3eea74b2394f1f3bb1ec7efc4e Mon Sep 17 00:00:00 2001 From: Julien Debray <julien.debray@etu.hesge.ch> Date: Tue, 31 Jan 2023 05:40:53 +0100 Subject: [PATCH] done --- .DS_Store | Bin 6148 -> 6148 bytes MushroomsTracker/app/build.gradle | 6 +-- .../app/src/main/AndroidManifest.xml | 9 ++-- .../mushroomstracker/DatabaseHelper.kt | 25 ---------- .../example/mushroomstracker/MainActivity.kt | 28 ----------- .../example/mushroomstracker/MapsActivity.kt | 46 +----------------- .../com/example/mushroomstracker/MyAdapter.kt | 40 --------------- .../app/src/main/res/layout/activity_main.xml | 28 ----------- .../app/src/main/res/layout/item_layout.xml | 13 ----- .../app/src/main/res/values/strings.xml | 1 - MushroomsTracker/build.gradle | 4 +- 11 files changed, 9 insertions(+), 191 deletions(-) delete mode 100644 MushroomsTracker/app/src/main/java/com/example/mushroomstracker/DatabaseHelper.kt delete mode 100644 MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MainActivity.kt delete mode 100644 MushroomsTracker/app/src/main/java/com/example/mushroomstracker/MyAdapter.kt delete mode 100644 MushroomsTracker/app/src/main/res/layout/activity_main.xml delete mode 100644 MushroomsTracker/app/src/main/res/layout/item_layout.xml diff --git a/.DS_Store b/.DS_Store index 938051f6423de17db660b1124187ac42d0379550..52a72a3ff8768a8f1b86ca731e57d0f3c78dbc09 100644 GIT binary patch delta 68 zcmZoMXfc=|#>CJ*u~2NHo+2aT!~knX#>s}vDw7SE<Ts}<FJ{?Xz&w>{Gdl-A2NOg4 Z=0xW2%#-;=3>g_F+we$ljuBbG3;=qB5*z>k delta 285 zcmZoMXfc=|#>B)qu~2NHo+2aj!~pA!4;mO5nJ4x*PwZE$Pbx1iNXp4iVqjp{npBXJ zSzKaZaE+0PnT3^&or9f&n<F+jBfmVjB(bEl*eS6n8pI39&(BGMu@jTRGE>Xr1w@?l z^GXsk^HPgIN`f;}Qj-#kV!|`?Qu524@=NnliotrJ5*(Zyobdvp)lSt0Itm80IttZ> zriMm33YI1&wY8iaqRRT#LGjr+xq12R3}C>>2&Nbqc%d|m>X_K0!c!Jpl$VpAm(IYz rz_{_^GM3Hk9Q+(iOq?4perKM{FJdSF(%k@(Wncg?88!!qY+(if9hpq5 diff --git a/MushroomsTracker/app/build.gradle b/MushroomsTracker/app/build.gradle index f786fd9..de35eb3 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 a9d6386..9ac4b6d 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 9d26aa6..0000000 --- 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 ba6a387..0000000 --- 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 7d26d33..09f56a7 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 93440f2..0000000 --- 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 41ab03c..0000000 --- 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 05a58fa..0000000 --- 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 cbd8ac3..68fa3fb 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 120a780..cf11c02 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 -- GitLab