Clean 3 dots context menu

This commit is contained in:
Victor Shcherb 2015-09-23 12:04:12 +02:00
parent f0fe1c66df
commit 6807052b6a

View file

@ -42,6 +42,9 @@ import net.osmand.plus.views.BaseMapLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@ -61,8 +64,6 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.commons.logging.Log;
public class MapActivityActions implements DialogProvider {
private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class);
public static final String KEY_LONGITUDE = "longitude";
@ -329,29 +330,7 @@ public class MapActivityActions implements DialogProvider {
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter;
if(!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
adapter.item(R.string.context_menu_item_directions_to).iconColor(
R.drawable.ic_action_gdirections_dark).reg();
adapter.item(R.string.context_menu_item_directions_from).iconColor(
R.drawable.ic_action_gdirections_dark).reg();
}
final TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
if(targets.getPointToNavigate() != null) {
adapter.item(R.string.context_menu_item_destination_point).iconColor(R.drawable.ic_action_flag_dark).reg();
adapter.item(R.string.context_menu_item_intermediate_point).iconColor(R.drawable.ic_action_flage_dark).reg();
// For button-less search UI
} else {
adapter.item(R.string.context_menu_item_destination_point).iconColor(R.drawable.ic_action_flag_dark).reg();
}
adapter.item(R.string.context_menu_item_search).iconColor(R.drawable.ic_action_search_dark).reg();
adapter.item(R.string.context_menu_item_share_location).iconColor(
R.drawable.ic_action_gshare_dark).reg();
adapter.item(R.string.shared_string_add_to_favorites).iconColor(
R.drawable.ic_action_fav_dark).reg();
LOG.debug("contextMenuPoint()");
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
getMyApplication().getAppCustomization().prepareLocationMenu(mapActivity, adapter);
@ -373,26 +352,6 @@ public class MapActivityActions implements DialogProvider {
intent.putExtra(SearchActivity.SEARCH_LON, longitude);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(intent);
} else if (standardId == R.string.context_menu_item_directions_to) {
targets.navigateToPoint(new LatLon(latitude, longitude), true, -1, null);
enterRoutePlanningMode(null, null, false);
} else if (standardId == R.string.context_menu_item_directions_from) {
List<PointDescription> nms = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectNames();
enterRoutePlanningMode(new LatLon(latitude, longitude), nms.isEmpty() ? null : nms.get(0), false);
} else if (standardId == R.string.context_menu_item_intermediate_point ||
standardId == R.string.context_menu_item_destination_point) {
boolean dest = standardId == R.string.context_menu_item_destination_point;
List<PointDescription> nms = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectNames();
targets.navigateToPoint(new LatLon(latitude, longitude), true,
dest ? -1 : targets.getIntermediatePoints().size(), nms.size() == 0?null :
nms.get(0));
if(targets.getIntermediatePoints().size() > 0) {
openIntermediatePointsDialog();
}
} else if (standardId == R.string.context_menu_item_share_location) {
shareLocation(latitude, longitude);
} else if (standardId == R.string.shared_string_add_to_favorites) {
addFavouritePoint(latitude, longitude);
}
}
});