Merge branch 'sherpafy'

This commit is contained in:
Denis 2014-09-02 17:03:28 +03:00
commit 1b6fd21427
4 changed files with 41 additions and 34 deletions

View file

@ -761,6 +761,22 @@ public class MapActivityActions implements DialogProvider {
final OsmandApplication app = mapActivity.getMyApplication(); final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app); ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
if (Version.isSherpafy(app)) {
//share my location
optionsMenuHelper.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 (getMyApplication().getLocationProvider().getLastKnownLocation() != null) {
new ShareLocation(mapActivity).run();
} else {
Toast.makeText(getMyApplication(), "Location unknown", Toast.LENGTH_LONG).show();
}
}
}).reg();
}
// 1. Where am I // 1. Where am I
optionsMenuHelper.item(R.string.where_am_i). optionsMenuHelper.item(R.string.where_am_i).
icons(R.drawable.ic_action_gloc_dark, R.drawable.ic_action_gloc_light) icons(R.drawable.ic_action_gloc_dark, R.drawable.ic_action_gloc_light)

View file

@ -519,13 +519,13 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
@Override @Override
public void prepareOptionsMenu(final MapActivity mapActivity, ContextMenuAdapter adapter) { 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.pause_navigation, R.string.continue_navigation,
R.string.cancel_navigation, R.string.cancel_route, R.string.clear_destination, R.string.cancel_navigation, R.string.cancel_route, R.string.clear_destination,
R.string.target_points, R.string.target_points,
R.string.get_directions, R.string.get_directions,
R.string.menu_mute_on, R.string.menu_mute_off, 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(); final StageInformation stage = getSelectedStage();
if (stage != null && !isStageVisited(stage.order)) { if (stage != null && !isStageVisited(stage.order)) {
adapter.item(R.string.complete_stage) adapter.item(R.string.complete_stage)
@ -595,7 +595,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
@Override @Override
public void createLayers(OsmandMapTileView mapView, MapActivity activity) { 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) { public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {

View file

@ -1,20 +1,23 @@
package net.osmand.plus.sherpafy; package net.osmand.plus.sherpafy;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.osmand.data.FavouritePoint; import android.graphics.PointF;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.sherpafy.TourInformation.StageFavorite; import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
import net.osmand.plus.views.FavoritesLayer; import net.osmand.plus.views.FavoritesLayer;
public class StageFavoritesLayer extends FavoritesLayer { public class StageFavoritesLayer extends FavoritesLayer {
private SherpafyCustomization customization; private OsmandApplication app;
public StageFavoritesLayer(SherpafyCustomization customization){ public StageFavoritesLayer(OsmandApplication app){
this.customization = customization; this.app = app;
} }
protected Class<? extends LocationPoint> getFavoriteClass() { protected Class<? extends LocationPoint> getFavoriteClass() {
@ -26,10 +29,22 @@ public class StageFavoritesLayer extends FavoritesLayer {
} }
protected List<? extends LocationPoint> getPoints() { protected List<? extends LocationPoint> getPoints() {
List<StageFavorite> fs = customization.getWaypoints(); List<StageFavorite> fs = ((SherpafyCustomization)app.getAppCustomization()).getWaypoints();
if(fs == null) { if(fs == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
return fs; 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;
}
} }

View file

@ -406,17 +406,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
public void startStage(final StageInformation stage) { public void startStage(final StageInformation stage) {
if(customization.isStageVisited(stage.getOrder()) /*&& stage.getTour() == customization.getSelectedTour()*/) { if(customization.isStageVisited(stage.getOrder()) /*&& stage.getTour() == customization.getSelectedTour()*/) {
customization.showCompleteStageFragment(this, stage, true); 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 { } else {
customization.runStage(TourViewActivity.this, stage.getTour(), stage, customization.getSelectedStage() != stage); 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) { public void startTour(final TourInformation tour) {
if (tour != customization.getSelectedTour() && customization.getSelectedTour() != null) { startTourImpl(tour);
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);
}
} }
private void startTourImpl(TourInformation tour) { private void startTourImpl(TourInformation tour) {