addresses #81 - saves gpx files without a file manager present check

This commit is contained in:
y20k 2020-10-13 16:52:12 +02:00
parent 420c18082c
commit 11610cca87
No known key found for this signature in database
GPG key ID: 824D4259F41FAFF6

View file

@ -25,7 +25,6 @@ import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.Vibrator
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -77,12 +76,12 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
layout.shareButton.setOnClickListener { layout.shareButton.setOnClickListener {
openSaveGpxDialog() openSaveGpxDialog()
} }
layout.shareButton.setOnLongClickListener { // layout.shareButton.setOnLongClickListener {
val v = (activity as Context).getSystemService(Context.VIBRATOR_SERVICE) as Vibrator // val v = (activity as Context).getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
v.vibrate(50) // v.vibrate(50)
shareGpxTrack() // shareGpxTrack()
return@setOnLongClickListener true // return@setOnLongClickListener true
} // }
// set up delete button // set up delete button
layout.deleteButton.setOnClickListener { layout.deleteButton.setOnClickListener {
val dialogMessage: String = "${getString(R.string.dialog_yes_no_message_delete_recording)}\n\n- ${layout.trackNameView.text}" val dialogMessage: String = "${getString(R.string.dialog_yes_no_message_delete_recording)}\n\n- ${layout.trackNameView.text}"
@ -183,12 +182,7 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
putExtra(Intent.EXTRA_TITLE, FileHelper.getGpxFileName(track)) putExtra(Intent.EXTRA_TITLE, FileHelper.getGpxFileName(track))
} }
// file gets saved in onActivityResult // file gets saved in onActivityResult
val packageManager: PackageManager? = activity?.packageManager
if (packageManager != null && intent.resolveActivity(packageManager) != null) {
startActivityForResult(intent, Keys.REQUEST_SAVE_GPX) startActivityForResult(intent, Keys.REQUEST_SAVE_GPX)
} else {
Toast.makeText(activity as Context, R.string.toast_message_install_file_helper, Toast.LENGTH_LONG).show()
}
} }