Open track menu fragment initial commit
This commit is contained in:
parent
40638958a3
commit
34ecacb9fc
13 changed files with 42 additions and 78 deletions
|
@ -27,6 +27,7 @@ import net.osmand.plus.settings.backend.ApplicationMode;
|
|||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
||||
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
|
||||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -37,6 +38,8 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
||||
import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME;
|
||||
import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
|
||||
|
||||
public class IntentHelper {
|
||||
|
@ -250,6 +253,12 @@ public class IntentHelper {
|
|||
}
|
||||
mapActivity.setIntent(null);
|
||||
}
|
||||
if (intent.hasExtra(TrackMenuFragment.OPEN_TRACK_MENU)) {
|
||||
String path = intent.getStringExtra(TRACK_FILE_NAME);
|
||||
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, currentRecording);
|
||||
mapActivity.setIntent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ import static net.osmand.IndexConstants.SQLITE_CHART_FILE_EXT;
|
|||
import static net.osmand.IndexConstants.SQLITE_EXT;
|
||||
import static net.osmand.IndexConstants.WPT_CHART_FILE_EXT;
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
import static net.osmand.plus.settings.backend.backup.SettingsHelper.REPLACE_KEY;
|
||||
|
@ -596,10 +597,7 @@ public class ImportHelper {
|
|||
|
||||
private void showGpxInDetailsActivity(String gpxFilePath) {
|
||||
if (!Algorithms.isEmpty(gpxFilePath)) {
|
||||
Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity());
|
||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFilePath);
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
activity.startActivity(newIntent);
|
||||
openTrack(activity, new File(gpxFilePath));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.mapcontextmenu.builders;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
|
@ -16,13 +15,11 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.views.layers.POIMapLayer;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -32,6 +29,8 @@ import java.text.DateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
|
||||
public class WptPtMenuBuilder extends MenuBuilder {
|
||||
|
||||
private final WptPt wpt;
|
||||
|
@ -181,12 +180,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||
final Intent intent = new Intent(context, appCustomization.getTrackActivity());
|
||||
intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
|
||||
intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
context.startActivity(intent);
|
||||
openTrack(mapActivity, new File(gpxFile.path));
|
||||
}
|
||||
});
|
||||
view.addView(button);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
|
@ -17,9 +16,7 @@ import net.osmand.plus.GpxSelectionHelper;
|
|||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.builders.SelectedGpxMenuBuilder;
|
||||
|
@ -45,21 +42,9 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
|
||||
if (Version.isDeveloperVersion(app)) {
|
||||
mapActivity.getContextMenu().hide(false);
|
||||
TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack());
|
||||
} else {
|
||||
Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
||||
if (selectedGpxFile.isShowCurrentTrack()) {
|
||||
intent.putExtra(TrackActivity.CURRENT_RECORDING, true);
|
||||
} else {
|
||||
intent.putExtra(TrackActivity.TRACK_FILE_NAME, selectedGpxFile.getGpxFile().path);
|
||||
}
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(intent);
|
||||
}
|
||||
mapActivity.getContextMenu().hide(false);
|
||||
TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack());
|
||||
}
|
||||
};
|
||||
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
||||
|
|
|
@ -92,6 +92,7 @@ import java.util.Locale;
|
|||
|
||||
import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
|
||||
public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
|
||||
|
||||
|
@ -1097,11 +1098,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
.setAction(R.string.shared_string_show, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(app, app.getAppCustomization().getTrackActivity());
|
||||
intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||
intent.putExtra(TrackActivity.TRACK_FILE_NAME, getGpx().path);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
openTrack(app, new File(getGpx().path));
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSnackbar(snackbar, !lightTheme);
|
||||
|
|
|
@ -42,12 +42,14 @@ import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptions
|
|||
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.GROUPS_MARKERS_MENU;
|
||||
import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.HISTORY_MARKERS_MENU;
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
|
||||
public class MapMarkersDialogFragment extends DialogFragment implements OnGroupSyncedListener {
|
||||
|
||||
|
@ -486,11 +488,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS
|
|||
.setAction(R.string.shared_string_show, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mapActivity, getMyApplication().getAppCustomization().getTrackActivity());
|
||||
intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxPath);
|
||||
intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
openTrack(mapActivity, new File(gpxPath));
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSnackbar(snackbar, !lightTheme);
|
||||
|
|
|
@ -104,6 +104,7 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo
|
|||
import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.AFTER;
|
||||
import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.ALL;
|
||||
import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.BEFORE;
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
|
||||
public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener,
|
||||
OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener,
|
||||
|
@ -1914,11 +1915,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
GpxData gpxData = editingCtx.getGpxData();
|
||||
GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null;
|
||||
if (gpx != null) {
|
||||
Intent newIntent = new Intent(mapActivity, app.getAppCustomization().getTrackActivity());
|
||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpx.path);
|
||||
newIntent.putExtra(TrackActivity.OPEN_TRACKS_LIST, true);
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(newIntent);
|
||||
openTrack(mapActivity, new File(gpx.path));
|
||||
}
|
||||
}
|
||||
editingCtx.resetRouteSettingsListener();
|
||||
|
|
|
@ -24,6 +24,8 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
|
||||
public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName();
|
||||
|
@ -60,11 +62,7 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
|||
public void onClick(View v) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null && !Algorithms.isEmpty(fileName)) {
|
||||
OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
||||
Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity());
|
||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, fileName);
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
activity.startActivity(newIntent);
|
||||
openTrack(activity, new File(fileName));
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
|
|
@ -414,15 +414,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
|||
updateCurrentTrack();
|
||||
}
|
||||
|
||||
public static void openTrack(Activity activity, final File f) {
|
||||
public static void openTrack(Context context, File file) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(OPEN_TRACK_MENU, true);
|
||||
if (f == null) {
|
||||
if (file == null) {
|
||||
bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true);
|
||||
} else {
|
||||
bundle.putString(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath());
|
||||
bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath());
|
||||
}
|
||||
MapActivity.launchMapActivityMoveToTop(activity, null, null, bundle);
|
||||
MapActivity.launchMapActivityMoveToTop(context, null, null, bundle);
|
||||
}
|
||||
|
||||
public void reloadTracks() {
|
||||
|
|
|
@ -178,10 +178,6 @@ public class OsmAndAppCustomization {
|
|||
return MapActivity.class;
|
||||
}
|
||||
|
||||
public Class<TrackActivity> getTrackActivity() {
|
||||
return TrackActivity.class;
|
||||
}
|
||||
|
||||
public Class<FavoritesActivity> getFavoritesActivity() {
|
||||
return FavoritesActivity.class;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
SegmentActionsListener, RenameCallback, OnTrackFileMoveListener, OnPointsDeleteListener,
|
||||
OsmAndLocationListener, OsmAndCompassListener {
|
||||
|
||||
public static final String OPEN_TRACK_MENU = "open_track_menu";
|
||||
|
||||
public static final String TAG = TrackMenuFragment.class.getName();
|
||||
private static final Log log = PlatformUtil.getLog(TrackMenuFragment.class);
|
||||
|
||||
|
@ -199,7 +201,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {//
|
||||
super.onCreate(savedInstanceState);
|
||||
app = requireMyApplication();
|
||||
GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.PointF;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
@ -14,7 +13,6 @@ import net.osmand.data.RotatedTileBox;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor;
|
||||
|
@ -22,6 +20,10 @@ import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
|||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.plus.views.layers.ContextMenuLayer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
|
||||
public class AddGpxPointBottomSheetHelper implements OnDismissListener {
|
||||
private final View view;
|
||||
private final TextView title;
|
||||
|
@ -149,18 +151,10 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener {
|
|||
if (fragment != null) {
|
||||
fragment.show();
|
||||
} else {
|
||||
openTrackActivity();
|
||||
openTrack(mapActivity, new File(newGpxPoint.getGpx().path));
|
||||
}
|
||||
}
|
||||
|
||||
private void openTrackActivity() {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, newGpxPoint.getGpx().path);
|
||||
newIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(newIntent);
|
||||
}
|
||||
|
||||
public static class NewGpxPoint {
|
||||
private PointDescription pointDescription;
|
||||
private GPXFile gpx;
|
||||
|
|
|
@ -27,14 +27,12 @@ import androidx.fragment.app.FragmentManager;
|
|||
import androidx.fragment.app.FragmentManager.BackStackEntry;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
|
@ -53,6 +51,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack;
|
||||
import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF;
|
||||
|
||||
|
||||
|
@ -151,11 +150,8 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
|
|||
return;
|
||||
}
|
||||
TravelHelper travelHelper = getMyApplication().getTravelHelper();
|
||||
File path = travelHelper.createGpxFile(article);
|
||||
Intent newIntent = new Intent(activity, getMyApplication().getAppCustomization().getTrackActivity());
|
||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, path.getAbsolutePath());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(newIntent);
|
||||
File file = travelHelper.createGpxFile(article);
|
||||
openTrack(activity, new File(file.getAbsolutePath()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue