Fix appearance screen with disabled track
This commit is contained in:
parent
c4707e415b
commit
9c9b4ea6de
6 changed files with 62 additions and 80 deletions
|
@ -67,8 +67,7 @@ import net.osmand.plus.AppInitializer;
|
|||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||
import net.osmand.plus.AppInitializer.InitEvents;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.mapmarkers.MapMarker;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OnDismissDialogFragmentListener;
|
||||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmAndLocationSimulation;
|
||||
|
@ -80,7 +79,6 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
|||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.base.ContextMenuFragment;
|
||||
import net.osmand.plus.base.FailSafeFuntions;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.chooseplan.OsmLiveGoneDialog;
|
||||
|
@ -108,10 +106,11 @@ import net.osmand.plus.helpers.ScrollHelper.OnScrollEventListener;
|
|||
import net.osmand.plus.importfiles.ImportHelper;
|
||||
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment;
|
||||
import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||
import net.osmand.plus.mapmarkers.MapMarker;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
|
||||
import net.osmand.plus.mapmarkers.PlanRouteFragment;
|
||||
import net.osmand.plus.measurementtool.GpxApproximationFragment;
|
||||
import net.osmand.plus.measurementtool.GpxData;
|
||||
|
@ -125,8 +124,8 @@ import net.osmand.plus.routepreparationmenu.ChooseRouteFragment;
|
|||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment;
|
||||
import net.osmand.plus.routing.IRouteInformationListener;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RouteCalculationProgressCallback;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.TransportRoutingHelper.TransportRouteCalculationProgressCallback;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
|
||||
|
@ -169,8 +168,6 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
|
||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
|
||||
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
||||
import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME;
|
||||
|
||||
public class MapActivity extends OsmandActionBarActivity implements DownloadEvents,
|
||||
OnRequestPermissionsResultCallback, IRouteInformationListener, AMapPointUpdateListener,
|
||||
|
@ -1177,15 +1174,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
MapRouteInfoMenu.showLocationOnMap(this, latLonToShow.getLatitude(), latLonToShow.getLongitude());
|
||||
} else if (toShow instanceof GPXFile) {
|
||||
hideContextAndRouteInfoMenues();
|
||||
GPXFile gpxFile = (GPXFile) toShow;
|
||||
SelectedGpxFile selectedGpxFile;
|
||||
if (gpxFile.showCurrentTrack) {
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
} else {
|
||||
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path);
|
||||
}
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString(TRACK_FILE_NAME, ((GPXFile) toShow).path);
|
||||
args.putBoolean(CURRENT_RECORDING, ((GPXFile) toShow).showCurrentTrack);
|
||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuController.MenuState.HALF_SCREEN);
|
||||
|
||||
TrackAppearanceFragment fragment = new TrackAppearanceFragment();
|
||||
fragment.setArguments(args);
|
||||
TrackAppearanceFragment.showInstance(this, fragment);
|
||||
TrackAppearanceFragment.showInstance(this, selectedGpxFile);
|
||||
} else if (toShow instanceof QuadRect) {
|
||||
QuadRect qr = (QuadRect) toShow;
|
||||
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
|
||||
|
|
|
@ -99,6 +99,7 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
|||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||
import net.osmand.plus.helpers.enums.SpeedConstants;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.myplaces.SaveCurrentTrackTask;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
|
@ -2192,6 +2193,23 @@ public class GpxUiHelper {
|
|||
new SaveGpxAsyncTask(file, gpxFile, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public static void saveAndShareCurrentGpx(@NonNull final OsmandApplication app, @NonNull final GPXFile gpxFile) {
|
||||
SaveGpxListener saveGpxListener = new SaveGpxListener() {
|
||||
@Override
|
||||
public void gpxSavingStarted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gpxSavingFinished(Exception errorMessage) {
|
||||
if (errorMessage == null) {
|
||||
GpxUiHelper.shareGpx(app, new File(gpxFile.path));
|
||||
}
|
||||
}
|
||||
};
|
||||
new SaveCurrentTrackTask(app, gpxFile, saveGpxListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public static void saveAndShareGpxWithAppearance(@NonNull final Context context, @NonNull final GPXFile gpxFile) {
|
||||
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
|
||||
GpxDataItem dataItem = getDataItem(app, gpxFile);
|
||||
|
|
|
@ -23,9 +23,7 @@ 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;
|
||||
import net.osmand.plus.myplaces.SaveCurrentTrackTask;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
||||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -217,7 +215,7 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
if (gpxFile != null) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
if (Algorithms.isEmpty(gpxFile.path)) {
|
||||
saveAndShareCurrentGpx(app, gpxFile);
|
||||
GpxUiHelper.saveAndShareCurrentGpx(app, gpxFile);
|
||||
} else {
|
||||
GpxUiHelper.saveAndShareGpxWithAppearance(app, gpxFile);
|
||||
}
|
||||
|
@ -227,23 +225,6 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
public void saveAndShareCurrentGpx(@NonNull final OsmandApplication app, @NonNull final GPXFile gpxFile) {
|
||||
SaveGpxListener saveGpxListener = new SaveGpxListener() {
|
||||
@Override
|
||||
public void gpxSavingStarted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gpxSavingFinished(Exception errorMessage) {
|
||||
if (errorMessage == null) {
|
||||
GpxUiHelper.shareGpx(app, new File(gpxFile.path));
|
||||
}
|
||||
}
|
||||
};
|
||||
new SaveCurrentTrackTask(app, gpxFile, saveGpxListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public static class SelectedGpxPoint {
|
||||
|
||||
private final WptPt selectedPoint;
|
||||
|
|
|
@ -67,10 +67,12 @@ public class OptionsCard extends BaseCard {
|
|||
itemsContainer.removeAllViews();
|
||||
items.clear();
|
||||
|
||||
boolean fileAvailable = gpxFile.path != null && !gpxFile.showCurrentTrack;
|
||||
items.add(createShowOnMapItem());
|
||||
items.add(createAppearanceItem());
|
||||
if (fileAvailable) {
|
||||
items.add(createDirectionsItem());
|
||||
|
||||
}
|
||||
items.add(createDividerItem());
|
||||
items.add(createJoinGapsItem());
|
||||
items.add(createAnalyzeOnMapItem());
|
||||
|
@ -78,18 +80,15 @@ public class OptionsCard extends BaseCard {
|
|||
|
||||
items.add(createDividerItem());
|
||||
items.add(createShareItem());
|
||||
items.add(createUploadOsmItem());
|
||||
|
||||
if (fileAvailable) {
|
||||
items.add(createUploadOsmItem());
|
||||
items.add(createDividerItem());
|
||||
items.add(createEditItem());
|
||||
items.add(createRenameItem());
|
||||
items.add(createChangeFolderItem());
|
||||
|
||||
items.add(createDividerItem());
|
||||
items.add(createDeleteItem());
|
||||
|
||||
if (gpxFile.path != null && !gpxFile.showCurrentTrack) {
|
||||
|
||||
}
|
||||
items.add(new DividerSpaceItem(mapActivity, AndroidUtils.dpToPx(app, 6)));
|
||||
|
||||
|
|
|
@ -56,8 +56,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
||||
import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME;
|
||||
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD;
|
||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM;
|
||||
|
@ -121,6 +119,10 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
return trackDrawInfo;
|
||||
}
|
||||
|
||||
public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) {
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
|
@ -132,40 +134,25 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
app = requireMyApplication();
|
||||
gpxDbHelper = app.getGpxDbHelper();
|
||||
|
||||
Bundle arguments = getArguments();
|
||||
if (savedInstanceState != null) {
|
||||
trackDrawInfo = new TrackDrawInfo(savedInstanceState);
|
||||
if (trackDrawInfo.isCurrentRecording()) {
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
} else {
|
||||
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(trackDrawInfo.getFilePath());
|
||||
}
|
||||
if (!selectedGpxFile.isShowCurrentTrack()) {
|
||||
gpxDataItem = gpxDbHelper.getItem(new File(trackDrawInfo.getFilePath()));
|
||||
}
|
||||
showStartFinishIconsInitialValue = savedInstanceState.getBoolean(SHOW_START_FINISH_ICONS_INITIAL_VALUE_KEY,
|
||||
app.getSettings().SHOW_START_FINISH_ICONS.get());
|
||||
} else if (arguments != null) {
|
||||
String gpxFilePath = arguments.getString(TRACK_FILE_NAME);
|
||||
boolean currentRecording = arguments.getBoolean(CURRENT_RECORDING, false);
|
||||
} else {
|
||||
showStartFinishIconsInitialValue = app.getSettings().SHOW_START_FINISH_ICONS.get();
|
||||
|
||||
if (gpxFilePath == null && !currentRecording) {
|
||||
log.error("Required extra '" + TRACK_FILE_NAME + "' is missing");
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
if (currentRecording) {
|
||||
if (selectedGpxFile.isShowCurrentTrack()) {
|
||||
trackDrawInfo = new TrackDrawInfo(true);
|
||||
trackDrawInfo.setColor(app.getSettings().CURRENT_TRACK_COLOR.get());
|
||||
trackDrawInfo.setWidth(app.getSettings().CURRENT_TRACK_WIDTH.get());
|
||||
trackDrawInfo.setShowArrows(app.getSettings().CURRENT_TRACK_SHOW_ARROWS.get());
|
||||
trackDrawInfo.setShowStartFinish(app.getSettings().CURRENT_TRACK_SHOW_START_FINISH.get());
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
} else {
|
||||
gpxDataItem = gpxDbHelper.getItem(new File(gpxFilePath));
|
||||
gpxDataItem = gpxDbHelper.getItem(new File(selectedGpxFile.getGpxFile().path));
|
||||
trackDrawInfo = new TrackDrawInfo(app, gpxDataItem, false);
|
||||
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath);
|
||||
}
|
||||
updateTrackColor();
|
||||
}
|
||||
|
@ -726,8 +713,12 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
return totalScreenHeight - frameTotalHeight;
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull MapActivity mapActivity, TrackAppearanceFragment fragment) {
|
||||
public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile) {
|
||||
try {
|
||||
TrackAppearanceFragment fragment = new TrackAppearanceFragment();
|
||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||
fragment.setRetainInstance(true);
|
||||
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment, fragment.getFragmentTag())
|
||||
|
|
|
@ -420,16 +420,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
app.getSelectedGpxHelper().selectGpxFile(gpxFile, gpxFileSelected, false);
|
||||
mapActivity.refreshMap();
|
||||
} else if (buttonIndex == APPEARANCE_BUTTON_INDEX) {
|
||||
app.getSelectedGpxHelper().selectGpxFile(gpxFile, true, false);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString(TRACK_FILE_NAME, gpxFile.path);
|
||||
args.putBoolean(CURRENT_RECORDING, gpxFile.showCurrentTrack);
|
||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HALF_SCREEN);
|
||||
|
||||
TrackAppearanceFragment fragment = new TrackAppearanceFragment();
|
||||
fragment.setArguments(args);
|
||||
TrackAppearanceFragment.showInstance(mapActivity, fragment);
|
||||
TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile);
|
||||
} else if (buttonIndex == DIRECTIONS_BUTTON_INDEX) {
|
||||
MapActivityActions mapActions = mapActivity.getMapActions();
|
||||
if (app.getRoutingHelper().isFollowingMode()) {
|
||||
|
@ -469,7 +460,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
SplitSegmentDialogFragment.showInstance(fragmentManager, displayHelper, items.get(0), segment);
|
||||
}
|
||||
} else if (buttonIndex == SHARE_BUTTON_INDEX) {
|
||||
GpxUiHelper.shareGpx(mapActivity, new File(gpxFile.path));
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
if (gpxFile.showCurrentTrack) {
|
||||
GpxUiHelper.saveAndShareCurrentGpx(app, gpxFile);
|
||||
} else if (!Algorithms.isEmpty(gpxFile.path)) {
|
||||
GpxUiHelper.saveAndShareGpxWithAppearance(app, gpxFile);
|
||||
}
|
||||
} else if (buttonIndex == UPLOAD_OSM_BUTTON_INDEX) {
|
||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
||||
if (osmEditingPlugin != null) {
|
||||
|
|
Loading…
Reference in a new issue