Fixes: go to map from search address/location, start navigation
This commit is contained in:
parent
3f5c338ffc
commit
5d39b36016
6 changed files with 206 additions and 1 deletions
|
@ -55,14 +55,24 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/header_caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="Point info"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_replace"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/color_transparent"
|
||||
android:textColor="@color/color_dialog_buttons"
|
||||
android:text="@string/update_existing"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -493,6 +493,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
ApplicationMode selected = settings.APPLICATION_MODE.get();
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
if (from == null) {
|
||||
Location ll = app.getLocationProvider().getLastKnownLocation();
|
||||
if (ll != null) {
|
||||
from = new LatLon(ll.getLatitude(), ll.getLongitude());
|
||||
}
|
||||
}
|
||||
if( selected != ApplicationMode.DEFAULT) {
|
||||
mode = selected;
|
||||
} else if (mode == ApplicationMode.DEFAULT) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.osmand.plus.mapcontextmenu.details.AmenityMenuController;
|
|||
import net.osmand.plus.mapcontextmenu.details.FavouritePointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.details.HistoryMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.details.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.details.PointDescriptionMenuController;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
|
@ -205,6 +206,8 @@ public class MapContextMenu {
|
|||
} else if (object instanceof HistoryEntry) {
|
||||
menuController = new HistoryMenuController(app, mapActivity, (HistoryEntry) object);
|
||||
}
|
||||
} else {
|
||||
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription, latLon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,6 +361,8 @@ public class MapContextMenu {
|
|||
|
||||
public void fabPressed() {
|
||||
mapActivity.getMapActions().directionTo(latLon.getLatitude(), latLon.getLongitude());
|
||||
hide();
|
||||
// open navigation menu
|
||||
}
|
||||
|
||||
public void buttonWaypointPressed() {
|
||||
|
|
|
@ -639,6 +639,7 @@ public class MapContextMenuFragment extends Fragment {
|
|||
|
||||
public void refreshTitle() {
|
||||
setAddressLocation();
|
||||
runLayoutListener();
|
||||
}
|
||||
|
||||
public void setFragmentVisibility(boolean visible) {
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class PointDescriptionMenuBuilder extends MenuBuilder {
|
||||
private final PointDescription pointDescription;
|
||||
|
||||
public PointDescriptionMenuBuilder(OsmandApplication app, final PointDescription pointDescription) {
|
||||
super(app);
|
||||
this.pointDescription = pointDescription;
|
||||
}
|
||||
|
||||
private void buildRow(View view, int iconId, String text, int textColor) {
|
||||
buildRow(view, getRowIcon(iconId), text, textColor);
|
||||
}
|
||||
|
||||
private void buildRow(final View view, Drawable icon, String text, int textColor) {
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
ll.setLayoutParams(llParams);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
|
||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIcon);
|
||||
|
||||
ImageView iconView = new ImageView(view.getContext());
|
||||
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
|
||||
llIconParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconView.setLayoutParams(llIconParams);
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
iconView.setImageDrawable(icon);
|
||||
llIcon.addView(iconView);
|
||||
|
||||
// Text
|
||||
LinearLayout llText = new LinearLayout(view.getContext());
|
||||
llText.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(llText);
|
||||
|
||||
TextView textView = new TextView(view.getContext());
|
||||
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
|
||||
textView.setLayoutParams(llTextParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
|
||||
textView.setAutoLinkMask(Linkify.ALL);
|
||||
textView.setLinksClickable(true);
|
||||
textView.setText(text);
|
||||
if (textColor > 0) {
|
||||
textView.setTextColor(view.getResources().getColor(textColor));
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
|
||||
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
|
||||
View horizontalLine = new View(view.getContext());
|
||||
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
|
||||
llHorLineParams.gravity = Gravity.BOTTOM;
|
||||
horizontalLine.setLayoutParams(llHorLineParams);
|
||||
|
||||
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
|
||||
|
||||
((LinearLayout) view).addView(horizontalLine);
|
||||
|
||||
rowBuilt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(View view) {
|
||||
super.build(view);
|
||||
|
||||
for (MenuBuilder.PlainMenuItem item : plainMenuItems) {
|
||||
buildRow(view, item.getIconId(), item.getText(), 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package net.osmand.plus.mapcontextmenu.details;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.search.SearchHistoryFragment;
|
||||
|
||||
public class PointDescriptionMenuController extends MenuController {
|
||||
|
||||
private PointDescription pointDescription;
|
||||
private LatLon latLon;
|
||||
|
||||
public PointDescriptionMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription, LatLon latLon) {
|
||||
super(new PointDescriptionMenuBuilder(app, pointDescription), mapActivity);
|
||||
this.pointDescription = pointDescription;
|
||||
this.latLon = latLon;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInitialMenuStatePortrait() {
|
||||
return MenuState.HEADER_ONLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
String typeName = pointDescription.getTypeName();
|
||||
return (typeName != null && !typeName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
return getIcon(SearchHistoryFragment.getItemIcon(pointDescription));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getSecondLineIcon() {
|
||||
if (needTypeStr()) {
|
||||
return getIcon(R.drawable.ic_small_group);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameStr() {
|
||||
return pointDescription.getSimpleName(getMapActivity(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
if (needTypeStr()) {
|
||||
return pointDescription.getTypeName();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needStreetName() {
|
||||
return !pointDescription.isAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription) {
|
||||
if (pointDescription != null) {
|
||||
addPlainMenuItem(R.drawable.map_my_location, PointDescription.getLocationName(getMapActivity(),
|
||||
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveEntityState(Bundle bundle, String key) {
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue