Add to form a field to put a name of route and list all markers with coordinate and address
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ValidateMarker"
|
||||
android:label="Ajouter une ligne"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:theme="@style/Theme.AppCompat"/>
|
||||
</application>
|
||||
|
||||
@@ -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<Address>? = geocoder.getFromLocation(latitude, longitude, 1)
|
||||
Log.i("Location", geoResults.toString())
|
||||
}
|
||||
}
|
||||
locationOverlay.enableMyLocation()
|
||||
|
||||
@@ -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<TableLayout>(R.id.table)
|
||||
val markers: ArrayList<String>? = intent.extras?.getStringArrayList(MARKERS)
|
||||
markers!!.forEach{
|
||||
val latitude = it.split(" | ")[0].toDouble()
|
||||
val longitude = it.split(" | ")[1].toDouble()
|
||||
val geoResults: MutableList<Address>? = 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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TableLayout
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20dp"
|
||||
android:textStyle="bold"
|
||||
android:text="Merci de vérifier les informations"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="Entrez un nom pour la ligne (80 caractères max)"
|
||||
android:layout_height="wrap_content"/>
|
||||
<EditText
|
||||
android:id="@+id/route_name"
|
||||
android:maxLength="80"/>
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/validate_form"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Valider"/>
|
||||
|
||||
</TableLayout>
|
||||
<ScrollView>
|
||||
<TableLayout
|
||||
android:id="@+id/table"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:padding="16dp" />
|
||||
</GridLayout>
|
||||
</ScrollView>
|
||||
</TableLayout>
|
||||
Reference in New Issue
Block a user