Open imported GPX files in TrackActivity

This commit is contained in:
madwasp79 2019-03-04 12:30:28 +02:00
parent 6e56316c70
commit 3e973f1638

View file

@ -20,9 +20,11 @@ import android.support.v7.app.AppCompatActivity;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.GPXUtilities.GPXTrackAnalysis;
import net.osmand.GPXUtilities.WptPt; import net.osmand.GPXUtilities.WptPt;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
@ -38,6 +40,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
@ -666,9 +669,10 @@ public class ImportHelper {
@Override @Override
protected void onPostExecute(final String warning) { protected void onPostExecute(final String warning) {
final String msg = warning == null ? MessageFormat.format(app.getString(R.string.gpx_saved_sucessfully), result.path) : warning; final String msg = warning == null ? MessageFormat.format(app.getString(R.string.gpx_saved_sucessfully), result.path) : warning;
Toast.makeText(activity, msg, Toast.LENGTH_LONG).show(); //Toast.makeText(activity, msg, Toast.LENGTH_LONG).show();
showGpxOnMap(result); //showGpxOnMap(result);
showGpxDetailsActivity(result);
} }
} }
@ -695,6 +699,15 @@ public class ImportHelper {
} }
} }
private void showGpxDetailsActivity(final GPXFile gpxFile) {
if (gpxFile.path != null) {
Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity());
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(newIntent);
}
}
private void importFavourites(final GPXFile gpxFile, final String fileName, final boolean save, private void importFavourites(final GPXFile gpxFile, final String fileName, final boolean save,
final boolean useImportDir, final boolean forceImportFavourites) { final boolean useImportDir, final boolean forceImportFavourites) {
if (gpxFile == null || gpxFile.isPointsEmpty()) { if (gpxFile == null || gpxFile.isPointsEmpty()) {