Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-10-02 18:20:48 +02:00
commit f3e3755eb5
27 changed files with 1081 additions and 614 deletions

View file

@ -143,7 +143,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
tools:src="@drawable/ic_sort_waypoint_dark"/>
tools:src="@drawable/ic_action_list_sort"/>
<net.osmand.plus.widgets.TextViewEx
android:layout_width="wrap_content"

View file

@ -530,7 +530,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:orientation="vertical">
<LinearLayout
@ -539,6 +538,7 @@
android:orientation="horizontal">
<LinearLayout
android:layout_marginTop="14dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -570,7 +570,6 @@
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="44dp"
android:layout_height="60dp"
android:layout_marginTop="-14dp"
android:contentDescription="@string/shared_string_cancel"
android:src="@drawable/ic_action_refresh_dark"
android:tint="@color/map_widget_blue"
@ -648,7 +647,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:orientation="vertical">
<LinearLayout
@ -657,6 +655,7 @@
android:orientation="horizontal">
<LinearLayout
android:layout_marginTop="14dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -688,7 +687,6 @@
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="44dp"
android:layout_height="60dp"
android:layout_marginTop="-14dp"
android:contentDescription="@string/shared_string_cancel"
android:src="@drawable/ic_action_refresh_dark"
android:tint="@color/map_widget_blue"

View file

@ -165,7 +165,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/build_route"
android:text="@string/plan_route"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
@ -194,7 +194,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/shared_string_save_as_gpx"
android:text="@string/marker_save_as_track"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>

View file

@ -17,7 +17,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
android:paddingBottom="@dimen/dialog_content_margin">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/save_as_track_title"

View file

@ -161,7 +161,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
tools:src="@drawable/ic_sort_waypoint_dark"/>
tools:src="@drawable/ic_action_list_sort"/>
<net.osmand.plus.widgets.TextViewEx
android:layout_width="wrap_content"

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
android:id="@+id/sort_by_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/sort_by"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout
android:id="@+id/door_to_door_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/door_to_door_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_sort_door_to_door"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/intermediate_items_sort_by_distance"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
<LinearLayout
android:id="@+id/reverse_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/reverse_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_sort_reverse_order"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/shared_string_reverse_order"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -1,17 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:background="?attr/bg_color"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/show_hide_history_title"
<FrameLayout
android:background="?attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="48dp">
<net.osmand.plus.widgets.TextViewEx
android:background="?attr/bg_color"
android:id="@+id/show_hide_history_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="56dp"
android:paddingStart="56dp"
@ -22,4 +26,12 @@
osmand:typeface="@string/font_roboto_medium"
android:textColor="@color/dashboard_blue"/>
</FrameLayout>
<include
android:id="@+id/bottom_shadow"
layout="@layout/card_bottom_divider"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout>

View file

@ -4,6 +4,7 @@
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="@+id/name_text_box"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"

View file

@ -4,7 +4,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
<net.osmand.plus.OsmandTextFieldBoxes
android:id="@+id/name_text_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
@ -18,6 +19,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
</net.osmand.plus.OsmandTextFieldBoxes>
</LinearLayout>

View file

@ -54,7 +54,6 @@
<!-- string name="widget">Widget</string if needed should be shared_string_widget -->
<!-- string name="top_bar">Top bar</string use shared_string_topbar -->
<string name="move_all_to_history">Move all to history</string>
<string name="build_route">Build route</string>
<string name="show_direction">Distance indication</string>
<string name="sort_by">Sort by</string>
<string name="do_not_use_animations">Do not use animations</string>

View file

@ -1012,7 +1012,6 @@ public class GPXUtilities {
}
private void removeGeneralTrackIfExists() {
Track generalTrack = getGeneralTrack();
if (generalTrack != null) {
tracks.remove(generalTrack);
this.generalTrack = null;
@ -1202,6 +1201,7 @@ public class GPXUtilities {
"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
for (Track track : file.tracks) {
if (!track.generalTrack) {
serializer.startTag(null, "trk"); //$NON-NLS-1$
writeNotNullText(serializer, "name", track.name);
writeNotNullText(serializer, "desc", track.desc);
@ -1217,6 +1217,7 @@ public class GPXUtilities {
writeExtensions(serializer, track);
serializer.endTag(null, "trk"); //$NON-NLS-1$
}
}
for (Route track : file.routes) {
serializer.startTag(null, "rte"); //$NON-NLS-1$

View file

@ -255,7 +255,7 @@ public class MapMarkersHelper {
List<MapMarker> activeMarkers = markersDbHelper.getActiveMarkers();
mapMarkers.addAll(activeMarkers);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
List<MapMarker> markersHistory = markersDbHelper.getMarkersHistory();
sortMarkers(markersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
@ -266,7 +266,7 @@ public class MapMarkersHelper {
}
}
public void checkAndFixActiveMarkersOrderIfNeeded() {
public void reorderActiveMarkersIfNeeded() {
if (!mapMarkers.isEmpty()) {
if (mapMarkers.size() > 1) {
for (int i = 0; i < mapMarkers.size() - 1; i++) {
@ -322,7 +322,7 @@ public class MapMarkersHelper {
public void orderMarkers(OsmandSettings.MapMarkersOrderByMode orderByMode) {
sortMarkers(getMapMarkers(), false, orderByMode);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
}
private void lookupAddress(final MapMarker mapMarker) {
@ -445,7 +445,7 @@ public class MapMarkersHelper {
}
}
if (needRefresh) {
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
refresh();
}
}
@ -459,7 +459,7 @@ public class MapMarkersHelper {
marker.history = true;
marker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
mapMarkersHistory.add(marker);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
refresh();
}
@ -473,7 +473,7 @@ public class MapMarkersHelper {
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
} else {
mapMarkers.add(marker);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
}
addMarkerToGroup(marker);
refresh();
@ -488,7 +488,7 @@ public class MapMarkersHelper {
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
} else {
mapMarkers.add(position, marker);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
}
addMarkerToGroup(marker);
refresh();
@ -501,7 +501,7 @@ public class MapMarkersHelper {
mapMarkersHistory.remove(marker);
marker.history = false;
mapMarkers.add(position, marker);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
refresh();
}
@ -515,8 +515,9 @@ public class MapMarkersHelper {
marker.history = false;
mapMarkers.add(marker);
}
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
updateGroups();
refresh();
}
}
@ -579,6 +580,36 @@ public class MapMarkersHelper {
return list;
}
public int getSelectedMarkersCount() {
int res = 0;
for (MapMarker m : this.mapMarkers) {
if (m.selected) {
res++;
}
}
return res;
}
public void addSelectedMarkersToTop(@NonNull List<MapMarker> markers) {
List<MapMarker> markersToRemove = new LinkedList<>();
for (MapMarker m : mapMarkers) {
if (m.selected) {
if (!markers.contains(m)) {
return;
}
markersToRemove.add(m);
}
}
if (markersToRemove.size() != markers.size()) {
return;
}
mapMarkers.removeAll(markersToRemove);
mapMarkers.addAll(0, markers);
reorderActiveMarkersIfNeeded();
ctx.getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
}
public List<LatLon> getActiveMarkersLatLon() {
List<LatLon> list = new ArrayList<>();
for (MapMarker m : this.mapMarkers) {
@ -608,7 +639,8 @@ public class MapMarkersHelper {
public void reverseActiveMarkersOrder() {
cancelAddressRequests();
Collections.reverse(mapMarkers);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
ctx.getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
}
public void moveAllActiveMarkersToHistory() {
@ -623,6 +655,7 @@ public class MapMarkersHelper {
mapMarkersHistory.addAll(mapMarkers);
mapMarkers.clear();
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
updateGroups();
refresh();
}
@ -675,7 +708,7 @@ public class MapMarkersHelper {
iterator.remove();
}
}
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
refresh();
}
}
@ -727,7 +760,7 @@ public class MapMarkersHelper {
markersDbHelper.addMarker(marker);
mapMarkers.add(0, marker);
addMarkerToGroup(marker);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
}
}
}
@ -750,7 +783,7 @@ public class MapMarkersHelper {
}
marker.point = point;
markersDbHelper.updateMarker(marker);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
refresh();
lookupAddress(marker);
}
@ -761,7 +794,7 @@ public class MapMarkersHelper {
if (i != -1 && mapMarkers.size() > 1) {
mapMarkers.remove(i);
mapMarkers.add(0, marker);
checkAndFixActiveMarkersOrderIfNeeded();
reorderActiveMarkersIfNeeded();
refresh();
}
}
@ -897,6 +930,12 @@ public class MapMarkersHelper {
}
}
public void updateGroups() {
for (MapMarkersGroup group : mapMarkersGroups) {
updateGroup(group);
}
}
public void updateGroup(MapMarkersGroup mapMarkersGroup) {
if (mapMarkersGroup.getMarkers().size() == 0) {
mapMarkersGroups.remove(mapMarkersGroup);
@ -957,7 +996,7 @@ public class MapMarkersHelper {
GroupHeader header = new GroupHeader();
int type = group.getType();
if (type != -1) {
header.setIconRes(type == MapMarkersHelper.MarkersSyncGroup.FAVORITES_TYPE ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_track_16);
header.setIconRes(type == MapMarkersHelper.MarkersSyncGroup.FAVORITES_TYPE ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark);
}
header.setGroup(group);
group.setGroupHeader(header);

View file

@ -20,6 +20,8 @@ import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
@ -80,6 +82,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
return;
} else {
mainView.setVisibility(View.VISIBLE);
sortItemsDescending(notes);
}
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.items);
@ -115,6 +118,23 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
}
}
private void sortItemsDescending(List<AudioVideoNotesPlugin.Recording> items) {
Collections.sort(items, new Comparator<AudioVideoNotesPlugin.Recording>() {
@Override
public int compare(AudioVideoNotesPlugin.Recording first, AudioVideoNotesPlugin.Recording second) {
long firstTime = first.getLastModified();
long secondTime = second.getLastModified();
if (firstTime < secondTime) {
return 1;
} else if (firstTime == secondTime) {
return 0;
} else {
return -1;
}
}
});
}
public static Drawable getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
final OsmandApplication ctx) {
String name = recording.getName(ctx, true);

View file

@ -368,6 +368,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
fragmentRef.get().centerMarkerLocation();
}
}
updateWidgetsVisibility(false);
}
public void show(@NonNull LatLon latLon,
@ -388,6 +389,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
centerMarker = false;
autoHide = false;
updateWidgetsVisibility(false);
}
public void update(LatLon latLon, PointDescription pointDescription, Object object) {
@ -446,6 +448,15 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (fragmentRef != null) {
fragmentRef.get().dismissMenu();
}
updateWidgetsVisibility(true);
}
private void updateWidgetsVisibility(boolean visible) {
int visibility = visible ? View.VISIBLE : View.GONE;
mapActivity.findViewById(R.id.map_center_info).setVisibility(visibility);
mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(visibility);
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(visibility);
mapActivity.refreshMap();
}
// timeout in msec
@ -713,7 +724,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
public void buttonFavoritePressed() {
if (object != null && object instanceof FavouritePoint) {
getFavoritePointEditor().edit((FavouritePoint) object);
@ -815,7 +825,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public void addWptPt(LatLon latLon, String title, String categoryName, int categoryColor, boolean skipDialog){
public void addWptPt(LatLon latLon, String title, String categoryName, int categoryColor, boolean skipDialog) {
final List<SelectedGpxFile> list
= mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();

View file

@ -76,7 +76,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
toPosition = holder.getAdapterPosition();
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
hideSnackbar();
mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded();
mapActivity.getMyApplication().getMapMarkersHelper().reorderActiveMarkersIfNeeded();
adapter.notifyDataSetChanged();
mapActivity.getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
}

View file

@ -141,6 +141,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
case R.id.action_active:
activeFragment.startLocationUpdate();
if (viewPager.getCurrentItem() != 0) {
hideSnackbar();
activeFragment.updateAdapter();
historyFragment.hideSnackbar();
groupsFragment.hideSnackbar();
@ -151,6 +152,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
case R.id.action_groups:
activeFragment.stopLocationUpdate();
if (viewPager.getCurrentItem() != 1) {
hideSnackbar();
groupsFragment.updateAdapter();
activeFragment.hideSnackbar();
historyFragment.hideSnackbar();
@ -161,6 +163,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
case R.id.action_history:
activeFragment.stopLocationUpdate();
if (viewPager.getCurrentItem() != 2) {
hideSnackbar();
historyFragment.updateAdapter();
groupsFragment.hideSnackbar();
activeFragment.hideSnackbar();
@ -296,6 +299,12 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
}
}
private void hideSnackbar() {
if (snackbar != null && snackbar.isShown()) {
snackbar.dismiss();
}
}
private MapActivity getMapActivity() {
return (MapActivity) getActivity();
}

View file

@ -1,6 +1,8 @@
package net.osmand.plus.mapmarkers;
import android.app.ProgressDialog;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
@ -23,6 +25,7 @@ import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.TspAnt;
import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
@ -31,11 +34,13 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapmarkers.PlanRouteSortByBottomSheetDialogFragment.PlanRouteSortByFragmentListener;
import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback;
import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter;
import net.osmand.plus.measurementtool.RecyclerViewFragment;
@ -47,6 +52,7 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
@ -92,6 +98,10 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
if (snapToRoadFragment != null) {
((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener());
}
Fragment sortByFragment = fragmentManager.findFragmentByTag(PlanRouteSortByBottomSheetDialogFragment.TAG);
if (sortByFragment != null) {
((PlanRouteSortByBottomSheetDialogFragment) sortByFragment).setListener(createSortByFragmentListener());
}
// If rotate the screen from landscape to portrait when the list of markers is displayed then
// the RecyclerViewFragment will exist without view. This is necessary to remove it.
if (!portrait) {
@ -125,7 +135,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
upDownIconIv = (ImageView) mainView.findViewById(R.id.up_down_icon);
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
((ImageView) mainView.findViewById(R.id.sort_icon)).setImageDrawable(getContentIcon(R.drawable.ic_sort_waypoint_dark));
((ImageView) mainView.findViewById(R.id.sort_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_list_sort));
mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
@Override
@ -162,7 +172,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
mainView.findViewById(R.id.sort_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mapActivity, "Sort", Toast.LENGTH_SHORT).show();
PlanRouteSortByBottomSheetDialogFragment fragment = new PlanRouteSortByBottomSheetDialogFragment();
fragment.setListener(createSortByFragmentListener());
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteSortByBottomSheetDialogFragment.TAG);
}
});
@ -203,6 +215,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
@Override
public void onItemClick(View view) {
int pos = markersRv.getChildAdapterPosition(view);
if (pos == RecyclerView.NO_POSITION) {
return;
}
if (pos == 0) {
markersHelper.setStartFromMyLocation(!mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get());
} else {
@ -227,7 +242,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
public void onDragEnded(RecyclerView.ViewHolder holder) {
toPosition = holder.getAdapterPosition();
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded();
mapActivity.getMyApplication().getMapMarkersHelper().reorderActiveMarkersIfNeeded();
mapActivity.getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
mapActivity.refreshMap();
try {
@ -345,6 +360,33 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
};
}
private PlanRouteSortByFragmentListener createSortByFragmentListener() {
return new PlanRouteSortByFragmentListener() {
private MapActivity mapActivity = getMapActivity();
@Override
public void doorToDoorOnClick() {
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
Location myLoc = app.getLocationProvider().getLastStaleKnownLocation();
boolean startFromLocation = app.getMapMarkersHelper().isStartFromMyLocation() && myLoc != null;
if (selectedCount > (startFromLocation ? 0 : 1)) {
sortSelectedMarkersDoorToDoor(mapActivity, startFromLocation, myLoc);
}
}
}
@Override
public void reverseOrderOnClick() {
if (mapActivity != null) {
markersHelper.reverseActiveMarkersOrder();
adapter.notifyDataSetChanged();
}
}
};
}
private void enterPlanRouteMode() {
final MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer();
@ -377,6 +419,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
}
setupAppModesBtn();
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
showMarkersRouteOnMap();
mapActivity.refreshMap();
updateText();
@ -672,6 +715,68 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
}
}
private void sortSelectedMarkersDoorToDoor(final MapActivity mapActivity, final boolean startFromLoc, final Location myLoc) {
new AsyncTask<Void, Void, List<MapMarker>>() {
private ProgressDialog dialog;
private long startDialogTime;
@Override
protected void onPreExecute() {
startDialogTime = System.currentTimeMillis();
dialog = new ProgressDialog(mapActivity);
dialog.setTitle("");
dialog.setMessage(mapActivity.getString(R.string.intermediate_items_sort_by_distance));
dialog.setCancelable(false);
dialog.show();
}
@Override
protected List<MapMarker> doInBackground(Void... voids) {
MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
List<MapMarker> selectedMarkers = markersHelper.getSelectedMarkers();
List<LatLon> selectedLatLon = markersHelper.getSelectedMarkersLatLon();
LatLon start = startFromLoc ? new LatLon(myLoc.getLatitude(), myLoc.getLongitude()) : selectedLatLon.remove(0);
LatLon end = selectedLatLon.remove(selectedLatLon.size() - 1);
int[] sequence = new TspAnt().readGraph(selectedLatLon, start, end).solve();
List<MapMarker> res = new ArrayList<>();
for (int i = 0; i < sequence.length; i++) {
if (i == 0 && startFromLoc) {
continue;
}
int index = sequence[startFromLoc ? i - 1 : i];
res.add(selectedMarkers.get(index));
}
return res;
}
@Override
protected void onPostExecute(List<MapMarker> res) {
if (dialog != null) {
long t = System.currentTimeMillis();
if (t - startDialogTime < 500) {
mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override
public void run() {
dialog.dismiss();
}
}, 500 - (t - startDialogTime));
} else {
dialog.dismiss();
}
}
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
adapter.notifyDataSetChanged();
}
}.execute();
}
private class PlanRouteToolbarController extends TopToolbarController {
PlanRouteToolbarController() {

View file

@ -0,0 +1,142 @@
package net.osmand.plus.mapmarkers;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
public class PlanRouteSortByBottomSheetDialogFragment extends BottomSheetDialogFragment {
public final static String TAG = "PlanRouteSortByBottomSheetDialogFragment";
private boolean portrait;
private boolean night;
private PlanRouteSortByFragmentListener listener;
public void setListener(PlanRouteSortByFragmentListener listener) {
this.listener = listener;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_sort_by_bottom_sheet_dialog, container);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
if (night) {
((TextView) mainView.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
}
((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door));
((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order));
mainView.findViewById(R.id.door_to_door_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.doorToDoorOnClick();
dismiss();
}
}
});
mainView.findViewById(R.id.reverse_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.reverseOrderOnClick();
dismiss();
}
}
});
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final View scrollView = mainView.findViewById(R.id.sort_by_scroll_view);
int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView;
scrollView.requestLayout();
}
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(getActivity(), 8)) {
AndroidUtils.setBackground(getActivity(), mainView, false,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
AndroidUtils.setBackground(getActivity(), mainView, false,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
ViewTreeObserver obs = mainView.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
return mainView;
}
@Override
public void onStart() {
super.onStart();
if (!portrait) {
final Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
window.setAttributes(params);
}
}
@Override
protected Drawable getContentIcon(@DrawableRes int id) {
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
}
interface PlanRouteSortByFragmentListener {
void doorToDoorOnClick();
void reverseOrderOnClick();
}
}

View file

@ -18,6 +18,7 @@ import android.widget.LinearLayout;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.plus.OsmandTextFieldBoxes;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BottomSheetDialogFragment;
@ -79,7 +80,10 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
}
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text);
nameEditText.setText(displayedName);
nameEditText.requestFocus();
View textBox = mainView.findViewById(R.id.name_text_box);
if (textBox instanceof OsmandTextFieldBoxes) {
((OsmandTextFieldBoxes) textBox).activate(true);
}
mainView.findViewById(R.id.save_button).setOnClickListener(new View.OnClickListener() {
@Override

View file

@ -394,6 +394,11 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
final MapMarkersShowHideHistoryViewHolder showHideHistoryViewHolder = (MapMarkersShowHideHistoryViewHolder) holder;
final ShowHideHistoryButton showHideHistoryButton = (ShowHideHistoryButton) getItem(position);
final boolean showHistory = showHideHistoryButton.isShowHistory();
if (position == getItemCount() - 1) {
showHideHistoryViewHolder.bottomShadow.setVisibility(View.VISIBLE);
} else {
showHideHistoryViewHolder.bottomShadow.setVisibility(View.GONE);
}
showHideHistoryViewHolder.title.setText(app.getString(showHistory ? R.string.hide_passed : R.string.show_passed));
showHideHistoryViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override

View file

@ -7,10 +7,13 @@ import android.widget.TextView;
import net.osmand.plus.R;
public class MapMarkersShowHideHistoryViewHolder extends RecyclerView.ViewHolder {
final TextView title;
final View bottomShadow;
public MapMarkersShowHideHistoryViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.show_hide_history_title);
bottomShadow = itemView.findViewById(R.id.bottom_shadow);
}
}

View file

@ -708,11 +708,12 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean routeDialogOpened = MapRouteInfoMenu.isVisible();
boolean trackDialogOpened = TrackDetailsMenu.isVisible();
boolean contextMenuOpened = mapActivity.getContextMenu().isVisible();
boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
updateMyLocation(rh, routeDialogOpened || trackDialogOpened);
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || contextMenuOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode();
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened;
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (rh.isFollowingMode()) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
@ -727,16 +728,16 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningBtn.updateVisibility(showButtons);
menuControl.updateVisibility(showButtons);
mapZoomIn.updateVisibility(!routeDialogOpened);
mapZoomOut.updateVisibility(!routeDialogOpened);
mapZoomIn.updateVisibility(!routeDialogOpened && !contextMenuOpened);
mapZoomOut.updateVisibility(!routeDialogOpened && !contextMenuOpened);
compassHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && shouldShowCompass()
&& !isInMeasurementToolMode() && !isInPlanRouteMode());
&& !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened);
if (layersHud.setIconResId(settings.getApplicationMode().getMapIconId())) {
layersHud.update(app, isNight);
}
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode());
quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode());
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened);
quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened);
if (!routePlanningMode && !routeFollowingMode) {
if (mapView.isZooming()) {

View file

@ -210,7 +210,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
OsmandSettings settings = map.getMyApplication().getSettings();
Location myLoc = map.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
List<MapMarker> activeMapMarkers = markersHelper.getMapMarkers();
@ -237,7 +236,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
canvas.drawPath(path, paint);
}
if (settings.SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) {
if (markersHelper.isStartFromMyLocation() && myLoc != null) {
lineAttrs.updatePaints(view, nightMode, tileBox);
textAttrs.updatePaints(view, nightMode, tileBox);
textAttrs.paint.setStyle(Paint.Style.FILL);

View file

@ -577,7 +577,7 @@ public class MapInfoWidgetsFactory {
initToolbar(defaultController);
defaultController.updateToolbar(this);
}
updateVisibility(controller != null);
updateVisibility(controller != null && (!map.getContextMenu().isVisible() || controller.getType() == TopToolbarControllerType.CONTEXT_MENU));
}
public void updateColors(TopToolbarController controller) {
@ -801,7 +801,7 @@ public class MapInfoWidgetsFactory {
}
}
}
if (map.isTopToolbarActive()) {
if (map.isTopToolbarActive() || map.getContextMenu().isVisible()) {
updateVisibility(false);
} else if (!showNextTurn && updateWaypoint()) {
updateVisibility(true);

View file

@ -197,7 +197,8 @@ public class MapMarkersWidgetsFactory {
|| map.getMyApplication().getRoutingHelper().isRoutePlanningMode()
|| MapRouteInfoMenu.isVisible()
|| addressTopBar.getVisibility() == View.VISIBLE
|| map.isTopToolbarActive()) {
|| map.isTopToolbarActive()
|| map.getContextMenu().isVisible()) {
updateVisibility(false);
return;
}