Merge pull request #4709 from osmandapp/fix_marker_menu
Fix marker menu
This commit is contained in:
commit
5654b3c3d7
8 changed files with 72 additions and 81 deletions
|
@ -122,39 +122,4 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/delete_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
tools:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="rename_marker">Rename marker</string>
|
||||
<string name="tap_on_map_to_hide_interface_descr">A tap on the map toggles the control buttons and widgets.</string>
|
||||
<string name="tap_on_map_to_hide_interface">Full screen mode</string>
|
||||
<string name="show_on_top_bar">Show on Top Bar</string>
|
||||
|
|
|
@ -44,6 +44,7 @@ import net.osmand.plus.mapcontextmenu.editors.WptPtEditor;
|
|||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||
import net.osmand.plus.mapmarkers.RenameMarkerBottomSheetDialogFragment;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
|
@ -87,6 +88,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
private boolean autoHide;
|
||||
|
||||
private int favActionIconId;
|
||||
private int waypointActionIconId;
|
||||
|
||||
private MenuAction searchDoneAction;
|
||||
|
||||
|
@ -704,12 +706,27 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
return R.string.shared_string_add_to_favorites;
|
||||
}
|
||||
|
||||
public int getWaypointActionIconId() {
|
||||
return waypointActionIconId;
|
||||
}
|
||||
|
||||
public int getWaypointActionStringId() {
|
||||
if (menuController != null) {
|
||||
return menuController.getWaypointActionStringId();
|
||||
}
|
||||
return settings.USE_MAP_MARKERS.get()
|
||||
? R.string.shared_string_add_to_map_markers : R.string.context_menu_item_destination_point;
|
||||
}
|
||||
|
||||
protected void acquireIcons() {
|
||||
super.acquireIcons();
|
||||
if (menuController != null) {
|
||||
favActionIconId = menuController.getFavActionIconId();
|
||||
waypointActionIconId = menuController.getWaypointActionIconId();
|
||||
} else {
|
||||
favActionIconId = R.drawable.map_action_fav_dark;
|
||||
waypointActionIconId = settings.USE_MAP_MARKERS.get()
|
||||
? R.drawable.map_action_flag_dark : R.drawable.map_action_waypoint;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,20 +762,25 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
}
|
||||
|
||||
public void buttonWaypointPressed() {
|
||||
if (pointDescription.isDestination()) {
|
||||
mapActivity.getMapActions().editWaypoints();
|
||||
} else if (settings.USE_MAP_MARKERS.get()) {
|
||||
if (pointDescription.isMapMarker()) {
|
||||
hide();
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
} else {
|
||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForMarker());
|
||||
}
|
||||
if (object != null && object instanceof MapMarker) {
|
||||
RenameMarkerBottomSheetDialogFragment
|
||||
.showInstance(mapActivity.getSupportFragmentManager(), (MapMarker) object);
|
||||
} else {
|
||||
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForTarget());
|
||||
if (pointDescription.isDestination()) {
|
||||
mapActivity.getMapActions().editWaypoints();
|
||||
} else if (settings.USE_MAP_MARKERS.get()) {
|
||||
if (pointDescription.isMapMarker()) {
|
||||
hide();
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
} else {
|
||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForMarker());
|
||||
}
|
||||
} else {
|
||||
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForTarget());
|
||||
}
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -455,15 +455,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
});
|
||||
|
||||
final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button);
|
||||
if (getMyApplication().getSettings().USE_MAP_MARKERS.get()) {
|
||||
buttonWaypoint.setImageDrawable(getIcon(R.drawable.map_action_flag_dark,
|
||||
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
buttonWaypoint.setContentDescription(getString(R.string.shared_string_add_to_map_markers));
|
||||
} else {
|
||||
buttonWaypoint.setImageDrawable(getIcon(R.drawable.map_action_waypoint,
|
||||
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
buttonWaypoint.setContentDescription(getString(R.string.context_menu_item_destination_point));
|
||||
}
|
||||
buttonWaypoint.setImageDrawable(getIcon(menu.getWaypointActionIconId(),
|
||||
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
buttonWaypoint.setContentDescription(getString(menu.getWaypointActionStringId()));
|
||||
AndroidUtils.setDashButtonBackground(getMapActivity(), buttonWaypoint, nightMode);
|
||||
buttonWaypoint.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -411,6 +411,16 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return R.string.shared_string_add_to_favorites;
|
||||
}
|
||||
|
||||
public int getWaypointActionIconId() {
|
||||
return getMapActivity().getMyApplication().getSettings().USE_MAP_MARKERS.get()
|
||||
? R.drawable.map_action_flag_dark : R.drawable.map_action_waypoint;
|
||||
}
|
||||
|
||||
public int getWaypointActionStringId() {
|
||||
return getMapActivity().getMyApplication().getSettings().USE_MAP_MARKERS.get()
|
||||
? R.string.shared_string_add_to_map_markers : R.string.context_menu_item_destination_point;
|
||||
}
|
||||
|
||||
public String getTypeStr() {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -94,4 +94,14 @@ public class MapMarkerMenuController extends MenuController {
|
|||
public boolean needStreetName() {
|
||||
return !needTypeStr();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaypointActionIconId() {
|
||||
return R.drawable.map_action_edit_dark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaypointActionStringId() {
|
||||
return R.string.rename_marker;
|
||||
}
|
||||
}
|
|
@ -82,7 +82,6 @@ public class MarkerMenuOnMapFragment extends BaseOsmAndFragment implements OsmAn
|
|||
((ImageView) mainView.findViewById(R.id.marker_icon))
|
||||
.setImageDrawable(getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex)));
|
||||
((ImageView) mainView.findViewById(R.id.rename_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
|
||||
((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
|
||||
((TextView) mainView.findViewById(R.id.marker_title)).setText(marker.getName(getActivity()));
|
||||
|
||||
|
@ -135,33 +134,11 @@ public class MarkerMenuOnMapFragment extends BaseOsmAndFragment implements OsmAn
|
|||
public void onClick(View view) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
RenameMarkerBottomSheetDialogFragment fragment = new RenameMarkerBottomSheetDialogFragment();
|
||||
fragment.setMarker(marker);
|
||||
fragment.setRetainInstance(true);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), RenameMarkerBottomSheetDialogFragment.TAG);
|
||||
RenameMarkerBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), marker);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
app.getMapMarkersHelper().removeMarker(marker);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
Snackbar.make(mapActivity.findViewById(R.id.bottomFragmentContainer), R.string.item_removed, Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
app.getMapMarkersHelper().addMarker(marker);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.back_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
|
|
@ -162,4 +162,16 @@ public class RenameMarkerBottomSheetDialogFragment extends BottomSheetDialogFrag
|
|||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fm, MapMarker marker) {
|
||||
try {
|
||||
RenameMarkerBottomSheetDialogFragment fragment = new RenameMarkerBottomSheetDialogFragment();
|
||||
fragment.setMarker(marker);
|
||||
fragment.setRetainInstance(true);
|
||||
fragment.show(fm, RenameMarkerBottomSheetDialogFragment.TAG);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue