diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 36e148a..5b277da 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -28,6 +28,7 @@
diff --git a/app/src/main/java/com/example/busroute/MainActivity.kt b/app/src/main/java/com/example/busroute/MainActivity.kt
index 8c7e278..5652f13 100644
--- a/app/src/main/java/com/example/busroute/MainActivity.kt
+++ b/app/src/main/java/com/example/busroute/MainActivity.kt
@@ -1,6 +1,7 @@
package com.example.busroute
import android.annotation.SuppressLint
+import android.app.AlertDialog
import android.content.ContentValues
import android.content.Context
import android.content.Intent
@@ -65,7 +66,7 @@ class MainActivity : ComponentActivity() {
isLocationPermissionGranted()
- val geocoder = Geocoder(this, Locale.getDefault())
+
locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
@@ -112,6 +113,11 @@ class MainActivity : ComponentActivity() {
stringList.add(it.toString())
//val newRowId = db?.insert(StopContract.StopEntry.TABLE_NAME, null, values)
}
+ if(busStopList.size < 1){
+ val alert = AlertDialog.Builder(this).setTitle("Aucun point !").setMessage("Il faut au moins 1 point pour continuer !")
+ alert.show()
+ return@setOnClickListener
+ }
val intent = Intent(saveMarkButton.context, ValidateMarker::class.java)
intent.putExtra(ValidateMarker.MARKERS, stringList)
startActivity(intent)
@@ -182,8 +188,6 @@ class MainActivity : ComponentActivity() {
Log.i("Position", "$latitude $longitude")
Log.i("Accuracy Chosen", "${location.provider}")
- var geoResults: MutableList
? = geocoder.getFromLocation(latitude, longitude, 1)
- Log.i("Location", geoResults.toString())
}
}
locationOverlay.enableMyLocation()
diff --git a/app/src/main/java/com/example/busroute/ValidateMarker.kt b/app/src/main/java/com/example/busroute/ValidateMarker.kt
index ef8e470..3cd8ff2 100644
--- a/app/src/main/java/com/example/busroute/ValidateMarker.kt
+++ b/app/src/main/java/com/example/busroute/ValidateMarker.kt
@@ -1,15 +1,22 @@
package com.example.busroute
import android.content.ContentValues
+import android.location.Address
+import android.location.Geocoder
import android.os.Bundle
import android.os.PersistableBundle
import android.util.Log
+import android.widget.ScrollView
import android.widget.TableLayout
import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.children
+import java.math.BigDecimal
+import java.math.RoundingMode
import java.util.ArrayList
+import java.util.Locale
+import kotlin.math.roundToLong
class ValidateMarker: AppCompatActivity() {
@@ -19,12 +26,26 @@ class ValidateMarker: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ val geocoder = Geocoder(this, Locale.getDefault())
setContentView(R.layout.marker_form)
val table = findViewById(R.id.table)
val markers: ArrayList? = intent.extras?.getStringArrayList(MARKERS)
markers!!.forEach{
+ val latitude = it.split(" | ")[0].toDouble()
+ val longitude = it.split(" | ")[1].toDouble()
+ val geoResults: MutableList? = geocoder.getFromLocation(latitude, longitude, 1)
+ lateinit var address:String
+ if (geoResults != null) {
+ if(geoResults.size > 0){
+ address = geoResults[0].getAddressLine(0)
+ }
+ }
val text = TextView(this)
- text.text = it
+ var newText = it
+ if(!address.isNullOrEmpty()){
+ newText += "\r${address}\n"
+ }
+ text.text = newText
table.addView(text)
}
}
diff --git a/app/src/main/res/layout/marker_form.xml b/app/src/main/res/layout/marker_form.xml
index 3592f8f..b8650ae 100644
--- a/app/src/main/res/layout/marker_form.xml
+++ b/app/src/main/res/layout/marker_form.xml
@@ -1,11 +1,37 @@
-
-
\ No newline at end of file
+ android:layout_width="200dp"
+ android:layout_height="wrap_content">
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file