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();
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
optionsMenuHelper.item(R.string.where_am_i).
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
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)
@ -595,7 +595,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) {

View file

@ -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;
}
}

View file

@ -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,21 +413,8 @@ 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);
}
}
private void startTourImpl(TourInformation tour) {
StageInformation stage;