addresses crash described in issue #70 - adds check if file manager is present

This commit is contained in:
y20k 2020-04-01 17:26:20 +02:00
parent 1e0bb81a38
commit 4bed93f821
No known key found for this signature in database
GPG key ID: 824D4259F41FAFF6
2 changed files with 9 additions and 4 deletions

View file

@ -37,13 +37,13 @@ import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.y20k.trackbook.Keys.ARG_TRACK_ID
import org.y20k.trackbook.core.Track
import org.y20k.trackbook.dialogs.RenameTrackDialog
import org.y20k.trackbook.helpers.FileHelper
import org.y20k.trackbook.helpers.LogHelper
import org.y20k.trackbook.ui.TrackFragmentLayoutHolder
class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDialog.YesNoDialogListener {
/* Define log tag */
@ -152,7 +152,7 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
// user tapped remove track
true -> {
// switch to TracklistFragment and remove track there
val trackId: Long = arguments?.getLong(ARG_TRACK_ID, -1L) ?: -1L
val trackId: Long = arguments?.getLong(Keys.ARG_TRACK_ID, -1L) ?: -1L
val bundle: Bundle = bundleOf(Keys.ARG_TRACK_ID to trackId)
findNavController().navigate(R.id.tracklist_fragment, bundle)
}
@ -170,7 +170,12 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
putExtra(Intent.EXTRA_TITLE, FileHelper.getGpxFileName(track))
}
// file gets saved in onActivityResult
val packageManager: PackageManager? = activity?.packageManager
if (packageManager != null && intent.resolveActivity(packageManager) != null) {
startActivityForResult(intent, Keys.REQUEST_SAVE_GPX)
} else {
Toast.makeText(activity as Context, R.string.toast_message_install_file_helper, Toast.LENGTH_LONG).show()
}
}

View file

@ -40,7 +40,7 @@
<string name="dialog_yes_no_message_delete_recording">Delete this recording?</string>
<!-- Toast Messages -->
<string name="toast_message_elevation_info">Hint: The accuracy of elevation data depends on your device. The uphill and downhill elevation of the whole route is measured.</string>
<string name="toast_message_install_file_helper">Please install a file manager or a GPX track viewer first.</string>
<string name="toast_message_install_file_helper">Unable to save. Please install a file manager first.</string>
<string name="toast_message_save_gpx">Saving recording as GPX.</string>
<!-- Map Markers -->
<string name="marker_description_time">Time</string>