Use in-app prompt for track name before going to save intent.
This allows you to put a custom name on your track without having to navigate your text cursor between the .gpx file extension. This also puts the name inside the gpx file's metadata, so that's a distinct advantage over just titling the filename itself.
This commit is contained in:
parent
32d71457dc
commit
55bde3b812
2 changed files with 48 additions and 31 deletions
|
@ -22,6 +22,7 @@ package net.voussoir.trkpt
|
||||||
|
|
||||||
import YesNoDialog
|
import YesNoDialog
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.app.Dialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
|
@ -33,10 +34,7 @@ import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.DatePicker
|
import android.widget.*
|
||||||
import android.widget.ImageButton
|
|
||||||
import android.widget.TimePicker
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.result.ActivityResult
|
import androidx.activity.result.ActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
|
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
|
||||||
import androidx.constraintlayout.widget.Group
|
import androidx.constraintlayout.widget.Group
|
||||||
|
@ -45,6 +43,7 @@ import androidx.fragment.app.Fragment
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import com.google.android.material.textview.MaterialTextView
|
import com.google.android.material.textview.MaterialTextView
|
||||||
|
import net.voussoir.trkpt.helpers.*
|
||||||
import org.osmdroid.api.IGeoPoint
|
import org.osmdroid.api.IGeoPoint
|
||||||
import org.osmdroid.api.IMapController
|
import org.osmdroid.api.IMapController
|
||||||
import org.osmdroid.events.MapListener
|
import org.osmdroid.events.MapListener
|
||||||
|
@ -58,13 +57,6 @@ import org.osmdroid.views.overlay.TilesOverlay
|
||||||
import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlay
|
import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlay
|
||||||
import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlayOptions
|
import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlayOptions
|
||||||
import org.osmdroid.views.overlay.simplefastpoint.SimplePointTheme
|
import org.osmdroid.views.overlay.simplefastpoint.SimplePointTheme
|
||||||
import net.voussoir.trkpt.helpers.AppThemeHelper
|
|
||||||
import net.voussoir.trkpt.helpers.DateTimeHelper
|
|
||||||
import net.voussoir.trkpt.helpers.LengthUnitHelper
|
|
||||||
import net.voussoir.trkpt.helpers.PreferencesHelper
|
|
||||||
import net.voussoir.trkpt.helpers.UiHelper
|
|
||||||
import net.voussoir.trkpt.helpers.create_start_end_markers
|
|
||||||
import net.voussoir.trkpt.helpers.iso8601_local
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -305,7 +297,26 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
|
||||||
}
|
}
|
||||||
|
|
||||||
save_track_button.setOnClickListener {
|
save_track_button.setOnClickListener {
|
||||||
openSaveGpxDialog()
|
val dialog = Dialog(activity as Context)
|
||||||
|
dialog.setContentView(R.layout.dialog_rename_track)
|
||||||
|
dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
dialog.setTitle("Track name")
|
||||||
|
|
||||||
|
val input = dialog.findViewById(R.id.dialog_rename_track_input_edit_text) as EditText
|
||||||
|
input.setText(track.name)
|
||||||
|
|
||||||
|
val save_button = dialog.findViewById(R.id.name_track_save_button) as Button
|
||||||
|
save_button.setOnClickListener {
|
||||||
|
track.name = input.text.toString()
|
||||||
|
openSaveGpxDialog()
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
val cancel_button = dialog.findViewById(R.id.name_track_cancel_button) as Button
|
||||||
|
cancel_button.setOnClickListener {
|
||||||
|
dialog.cancel()
|
||||||
|
}
|
||||||
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteButton.setOnClickListener {
|
deleteButton.setOnClickListener {
|
||||||
|
|
|
@ -1,32 +1,38 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<EditText
|
||||||
android:id="@+id/dialog_rename_track_input_layout"
|
android:id="@+id/dialog_rename_track_input_edit_text"
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="24dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_marginEnd="24dp"
|
|
||||||
android:layout_marginBottom="24dp"
|
|
||||||
android:hint="@string/dialog_rename_track_input_hint"
|
android:hint="@string/dialog_rename_track_input_hint"
|
||||||
android:maxLines="1"
|
|
||||||
app:endIconMode="clear_text"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/dialog_rename_track_input_edit_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
<Button
|
||||||
|
android:id="@+id/name_track_save_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="Save"
|
||||||
|
app:cornerRadius="8dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/dialog_rename_track_input_edit_text"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/dialog_rename_track_input_edit_text" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/name_track_cancel_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="Cancel"
|
||||||
|
app:cornerRadius="8dp"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/dialog_rename_track_input_edit_text"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/dialog_rename_track_input_edit_text" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in a new issue