addresses crash described in issue #70 - adds check if file manager is present
This commit is contained in:
parent
1e0bb81a38
commit
4bed93f821
2 changed files with 9 additions and 4 deletions
|
@ -37,13 +37,13 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.y20k.trackbook.Keys.ARG_TRACK_ID
|
|
||||||
import org.y20k.trackbook.core.Track
|
import org.y20k.trackbook.core.Track
|
||||||
import org.y20k.trackbook.dialogs.RenameTrackDialog
|
import org.y20k.trackbook.dialogs.RenameTrackDialog
|
||||||
import org.y20k.trackbook.helpers.FileHelper
|
import org.y20k.trackbook.helpers.FileHelper
|
||||||
import org.y20k.trackbook.helpers.LogHelper
|
import org.y20k.trackbook.helpers.LogHelper
|
||||||
import org.y20k.trackbook.ui.TrackFragmentLayoutHolder
|
import org.y20k.trackbook.ui.TrackFragmentLayoutHolder
|
||||||
|
|
||||||
|
|
||||||
class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDialog.YesNoDialogListener {
|
class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDialog.YesNoDialogListener {
|
||||||
|
|
||||||
/* Define log tag */
|
/* Define log tag */
|
||||||
|
@ -152,7 +152,7 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
|
||||||
// user tapped remove track
|
// user tapped remove track
|
||||||
true -> {
|
true -> {
|
||||||
// switch to TracklistFragment and remove track there
|
// 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)
|
val bundle: Bundle = bundleOf(Keys.ARG_TRACK_ID to trackId)
|
||||||
findNavController().navigate(R.id.tracklist_fragment, bundle)
|
findNavController().navigate(R.id.tracklist_fragment, bundle)
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,12 @@ 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
|
||||||
startActivityForResult(intent, Keys.REQUEST_SAVE_GPX)
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<string name="dialog_yes_no_message_delete_recording">Delete this recording?</string>
|
<string name="dialog_yes_no_message_delete_recording">Delete this recording?</string>
|
||||||
<!-- Toast Messages -->
|
<!-- 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_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>
|
<string name="toast_message_save_gpx">Saving recording as GPX.</string>
|
||||||
<!-- Map Markers -->
|
<!-- Map Markers -->
|
||||||
<string name="marker_description_time">Time</string>
|
<string name="marker_description_time">Time</string>
|
||||||
|
|
Loading…
Reference in a new issue