commit
2a528a922c
4 changed files with 45 additions and 36 deletions
|
@ -760,7 +760,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
||||
|
||||
|
||||
// 1. Where am I
|
||||
optionsMenuHelper.item(R.string.where_am_i).
|
||||
icons(R.drawable.ic_action_gloc_dark, R.drawable.ic_action_gloc_light)
|
||||
|
@ -958,6 +958,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}).reg();
|
||||
}
|
||||
}
|
||||
|
||||
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
optionsMenuHelper.item(R.string.exit_Button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
|
||||
.listen(new OnContextMenuClick() {
|
||||
|
@ -972,6 +973,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
// app.closeApplication(mapActivity);
|
||||
}
|
||||
}).reg();
|
||||
|
||||
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
return optionsMenuHelper;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import android.widget.Toast;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
|
@ -33,6 +34,7 @@ import net.osmand.plus.activities.DownloadIndexActivity;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.activities.SelectedGPXFragment;
|
||||
import net.osmand.plus.activities.actions.ShareLocation;
|
||||
import net.osmand.plus.api.FileSettingsAPIImpl;
|
||||
import net.osmand.plus.api.SettingsAPI;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
|
@ -519,13 +521,13 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
|
||||
@Override
|
||||
public void prepareOptionsMenu(final MapActivity mapActivity, ContextMenuAdapter adapter) {
|
||||
filter(adapter, R.string.exit_Button, R.string.menu_layers,
|
||||
filter(adapter, R.string.menu_layers,
|
||||
R.string.pause_navigation, R.string.continue_navigation,
|
||||
R.string.cancel_navigation, R.string.cancel_route, R.string.clear_destination,
|
||||
R.string.target_points,
|
||||
R.string.get_directions,
|
||||
R.string.menu_mute_on, R.string.menu_mute_off,
|
||||
R.string.where_am_i);
|
||||
R.string.where_am_i, R.string.context_menu_item_share_location);
|
||||
final StageInformation stage = getSelectedStage();
|
||||
if (stage != null && !isStageVisited(stage.order)) {
|
||||
adapter.item(R.string.complete_stage)
|
||||
|
@ -538,7 +540,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
}
|
||||
}).reg();
|
||||
}
|
||||
adapter.item(R.string.sherpafy_tour_info_txt).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light ).position(adapter.length() - 1)
|
||||
adapter.item(R.string.sherpafy_tour_info_txt).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).position(adapter.length() - 1)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
|
@ -546,7 +548,21 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(newIntent);
|
||||
}
|
||||
}).reg();
|
||||
}).reg();
|
||||
|
||||
//share my location
|
||||
adapter.item(R.string.context_menu_item_share_location).icons(
|
||||
R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_light).listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (app.getLocationProvider().getLastKnownLocation() != null) {
|
||||
new ShareLocation(mapActivity).run();
|
||||
} else {
|
||||
Toast.makeText(app, R.string.unknown_location, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}).reg();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -595,7 +611,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
|
||||
@Override
|
||||
public void createLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
mapView.addLayer(new StageFavoritesLayer(this), 4.1f);
|
||||
mapView.addLayer(new StageFavoritesLayer(app), 4.1f);
|
||||
}
|
||||
|
||||
public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import android.graphics.PointF;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
|
||||
import net.osmand.plus.views.FavoritesLayer;
|
||||
|
||||
public class StageFavoritesLayer extends FavoritesLayer {
|
||||
|
||||
private SherpafyCustomization customization;
|
||||
private OsmandApplication app;
|
||||
|
||||
public StageFavoritesLayer(SherpafyCustomization customization){
|
||||
this.customization = customization;
|
||||
public StageFavoritesLayer(OsmandApplication app){
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
protected Class<? extends LocationPoint> getFavoriteClass() {
|
||||
|
@ -26,10 +29,22 @@ public class StageFavoritesLayer extends FavoritesLayer {
|
|||
}
|
||||
|
||||
protected List<? extends LocationPoint> getPoints() {
|
||||
List<StageFavorite> fs = customization.getWaypoints();
|
||||
List<StageFavorite> fs = ((SherpafyCustomization)app.getAppCustomization()).getWaypoints();
|
||||
if(fs == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return fs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
List<LocationPoint> favs = new ArrayList<LocationPoint>();
|
||||
getFavoriteFromPoint(tileBox, point, favs);
|
||||
if (favs.size() > 0){
|
||||
SherpafyCustomization customization = (SherpafyCustomization) app.getAppCustomization();
|
||||
customization.showFavoriteDialog(app.getMapActivity(), customization.getSelectedStage(), (StageFavorite)favs.get(0) );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,17 +406,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
public void startStage(final StageInformation stage) {
|
||||
if(customization.isStageVisited(stage.getOrder()) /*&& stage.getTour() == customization.getSelectedTour()*/) {
|
||||
customization.showCompleteStageFragment(this, stage, true);
|
||||
} else if (stage != customization.getSelectedStage() && customization.getSelectedStage() != null) {
|
||||
Builder bld = new AlertDialog.Builder(this);
|
||||
bld.setMessage(R.string.start_new_stage);
|
||||
bld.setPositiveButton(R.string.default_buttons_yes, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
customization.runStage(TourViewActivity.this, stage.getTour(), stage, customization.getSelectedStage() != stage);
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.default_buttons_no, null);
|
||||
bld.show();
|
||||
} else {
|
||||
customization.runStage(TourViewActivity.this, stage.getTour(), stage, customization.getSelectedStage() != stage);
|
||||
}
|
||||
|
@ -424,20 +413,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
|
||||
|
||||
public void startTour(final TourInformation tour) {
|
||||
if (tour != customization.getSelectedTour() && customization.getSelectedTour() != null) {
|
||||
Builder bld = new AlertDialog.Builder(this);
|
||||
bld.setMessage(R.string.start_new_stage);
|
||||
bld.setPositiveButton(R.string.default_buttons_yes, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startTourImpl(tour);
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.default_buttons_no, null);
|
||||
bld.show();
|
||||
} else {
|
||||
startTourImpl(tour);
|
||||
}
|
||||
startTourImpl(tour);
|
||||
}
|
||||
|
||||
private void startTourImpl(TourInformation tour) {
|
||||
|
|
Loading…
Reference in a new issue