Add new activity to list actual marker for future edit in a form
This commit is contained in:
@@ -60,6 +60,7 @@ dependencies {
|
|||||||
implementation(libs.androidx.ui.tooling.preview)
|
implementation(libs.androidx.ui.tooling.preview)
|
||||||
implementation(libs.androidx.material3)
|
implementation(libs.androidx.material3)
|
||||||
implementation(libs.play.services.location)
|
implementation(libs.play.services.location)
|
||||||
|
implementation(libs.androidx.appcompat)
|
||||||
testImplementation(libs.junit)
|
testImplementation(libs.junit)
|
||||||
androidTestImplementation(libs.androidx.junit)
|
androidTestImplementation(libs.androidx.junit)
|
||||||
androidTestImplementation(libs.androidx.espresso.core)
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
|||||||
@@ -23,10 +23,13 @@
|
|||||||
android:theme="@style/Theme.BusRoute">
|
android:theme="@style/Theme.BusRoute">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ValidateMarker"
|
||||||
|
android:parentActivityName=".MainActivity"
|
||||||
|
android:theme="@style/Theme.AppCompat"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.example.busroute
|
package com.example.busroute
|
||||||
|
|
||||||
import org.osmdroid.views.overlay.Marker
|
import org.osmdroid.views.overlay.Marker
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
data class BusStop(val marker: Marker){
|
data class BusStop(val marker: Marker){
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
val dbHelper = DbHelper(this)
|
val dbHelper = DbHelper(this)
|
||||||
|
isLocationPermissionGranted()
|
||||||
|
|
||||||
|
|
||||||
val geocoder = Geocoder(this, Locale.getDefault())
|
val geocoder = Geocoder(this, Locale.getDefault())
|
||||||
|
|
||||||
|
|
||||||
@@ -99,14 +102,20 @@ class MainActivity : ComponentActivity() {
|
|||||||
val saveMarkButton = findViewById<Button>(R.id.saveMark)
|
val saveMarkButton = findViewById<Button>(R.id.saveMark)
|
||||||
saveMarkButton.setOnClickListener{
|
saveMarkButton.setOnClickListener{
|
||||||
val db = dbHelper.writableDatabase
|
val db = dbHelper.writableDatabase
|
||||||
|
var stringList: ArrayList<String> = ArrayList<String>()
|
||||||
busStopList.forEach {
|
busStopList.forEach {
|
||||||
val values = ContentValues().apply {
|
val values = ContentValues().apply {
|
||||||
put(StopContract.StopEntry.LATITUDE, it.marker.position.latitude)
|
put(StopContract.StopEntry.LATITUDE, it.marker.position.latitude)
|
||||||
put(StopContract.StopEntry.LONGITUDE, it.marker.position.longitude)
|
put(StopContract.StopEntry.LONGITUDE, it.marker.position.longitude)
|
||||||
put(StopContract.StopEntry.ORDER, busStopList.indexOf(it))
|
put(StopContract.StopEntry.ORDER, busStopList.indexOf(it))
|
||||||
}
|
}
|
||||||
val newRowId = db?.insert(StopContract.StopEntry.TABLE_NAME, null, values)
|
stringList.add(it.toString())
|
||||||
|
//val newRowId = db?.insert(StopContract.StopEntry.TABLE_NAME, null, values)
|
||||||
}
|
}
|
||||||
|
val intent = Intent(saveMarkButton.context, ValidateMarker::class.java)
|
||||||
|
intent.putExtra(ValidateMarker.MARKERS, stringList)
|
||||||
|
startActivity(intent)
|
||||||
|
|
||||||
val dbread = dbHelper.readableDatabase
|
val dbread = dbHelper.readableDatabase
|
||||||
val projection = arrayOf(BaseColumns._ID, StopContract.StopEntry.LATITUDE, StopContract.StopEntry.LONGITUDE, StopContract.StopEntry.ORDER)
|
val projection = arrayOf(BaseColumns._ID, StopContract.StopEntry.LATITUDE, StopContract.StopEntry.LONGITUDE, StopContract.StopEntry.ORDER)
|
||||||
val selection = ""
|
val selection = ""
|
||||||
@@ -181,7 +190,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
locationOverlay.enableFollowLocation()
|
locationOverlay.enableFollowLocation()
|
||||||
map.overlays.add(locationOverlay)
|
map.overlays.add(locationOverlay)
|
||||||
|
|
||||||
isLocationPermissionGranted()
|
|
||||||
// val locationClient = LocationServices.getFusedLocationProviderClient(this)
|
// val locationClient = LocationServices.getFusedLocationProviderClient(this)
|
||||||
//
|
//
|
||||||
// locationRequest = LocationRequest.Builder(Priority.PRIORITY_BALANCED_POWER_ACCURACY,60)
|
// locationRequest = LocationRequest.Builder(Priority.PRIORITY_BALANCED_POWER_ACCURACY,60)
|
||||||
|
|||||||
31
app/src/main/java/com/example/busroute/ValidateMarker.kt
Normal file
31
app/src/main/java/com/example/busroute/ValidateMarker.kt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.example.busroute
|
||||||
|
|
||||||
|
import android.content.ContentValues
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.PersistableBundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.TableLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.children
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
class ValidateMarker: AppCompatActivity() {
|
||||||
|
|
||||||
|
companion object{
|
||||||
|
const val MARKERS = "MARKERS"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.marker_form)
|
||||||
|
val table = findViewById<TableLayout>(R.id.table)
|
||||||
|
val markers: ArrayList<String>? = intent.extras?.getStringArrayList(MARKERS)
|
||||||
|
markers!!.forEach{
|
||||||
|
val text = TextView(this)
|
||||||
|
text.text = it
|
||||||
|
table.addView(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/src/main/res/layout/marker_form.xml
Normal file
11
app/src/main/res/layout/marker_form.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<TableLayout
|
||||||
|
android:id="@+id/table"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:padding="16dp" />
|
||||||
|
</GridLayout>
|
||||||
@@ -9,6 +9,7 @@ lifecycleRuntimeKtx = "2.8.2"
|
|||||||
activityCompose = "1.9.0"
|
activityCompose = "1.9.0"
|
||||||
composeBom = "2024.06.00"
|
composeBom = "2024.06.00"
|
||||||
playServicesLocation = "21.3.0"
|
playServicesLocation = "21.3.0"
|
||||||
|
appcompat = "1.7.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
@@ -26,6 +27,7 @@ androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-man
|
|||||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
play-services-location = { group = "com.google.android.gms", name = "play-services-location", version.ref = "playServicesLocation" }
|
play-services-location = { group = "com.google.android.gms", name = "play-services-location", version.ref = "playServicesLocation" }
|
||||||
|
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
Reference in New Issue
Block a user