Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-03-07 18:39:23 +01:00
commit 27385f2113
13 changed files with 82 additions and 31 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -2,6 +2,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
@ -38,6 +39,22 @@
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/text_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/shared_string_options"
android:visibility="gone"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"
tools:textColor="?attr/color_dialog_buttons"/>
<ImageButton <ImageButton
android:id="@+id/image_button" android:id="@+id/image_button"
android:contentDescription="@string/shared_string_more" android:contentDescription="@string/shared_string_more"

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 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="group_deleted">Group deleted</string>
<string name="rendering_attr_whiteWaterSports_name">Whitewater sports</string> <string name="rendering_attr_whiteWaterSports_name">Whitewater sports</string>
<string name="distance_farthest">Distance: farthest first</string> <string name="distance_farthest">Distance: farthest first</string>
<string name="distance_nearest">Distance: nearest first</string> <string name="distance_nearest">Distance: nearest first</string>

View file

@ -17,6 +17,7 @@ import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.TrkSegment; import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
import net.osmand.plus.MapMarkersHelper.OnGroupSyncedListener;
import net.osmand.plus.OsmandSettings.MetricsConstants; import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
@ -501,7 +502,7 @@ public class GpxSelectionHelper {
} }
} }
if (syncGroup) { if (syncGroup) {
syncGpx(gpx, true); syncGpx(gpx, true, null);
} }
return sf; return sf;
} }
@ -538,10 +539,10 @@ public class GpxSelectionHelper {
} }
private void syncGpx(GPXFile gpxFile) { private void syncGpx(GPXFile gpxFile) {
syncGpx(gpxFile, false); syncGpx(gpxFile, false, null);
} }
private void syncGpx(GPXFile gpxFile, boolean createOrDeleteGroup) { public void syncGpx(GPXFile gpxFile, boolean createOrDeleteGroup, @Nullable OnGroupSyncedListener callback) {
File gpx = new File(gpxFile.path); File gpx = new File(gpxFile.path);
if (gpx.exists()) { if (gpx.exists()) {
MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper(); MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper();
@ -556,7 +557,7 @@ public class GpxSelectionHelper {
mapMarkersHelper.removeMarkersSyncGroup(gpx.getAbsolutePath(), true); mapMarkersHelper.removeMarkersSyncGroup(gpx.getAbsolutePath(), true);
} }
} }
mapMarkersHelper.syncGroupAsync(syncGroup, enabled); mapMarkersHelper.syncGroupAsync(syncGroup, enabled, callback);
} }
} }

View file

@ -493,7 +493,7 @@ public class MapMarkersHelper {
syncGroupAsync(group, true, groupSyncedListener); syncGroupAsync(group, true, groupSyncedListener);
} }
private void syncGroupAsync(@NonNull final MarkersSyncGroup group, final boolean enabled, @Nullable final OnGroupSyncedListener groupSyncedListener) { public void syncGroupAsync(@NonNull final MarkersSyncGroup group, final boolean enabled, @Nullable final OnGroupSyncedListener groupSyncedListener) {
ctx.runInUIThread(new Runnable() { ctx.runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {

View file

@ -32,6 +32,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -106,7 +107,11 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f)); popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true); popup.setModal(true);
popup.setDropDownGravity(Gravity.END | Gravity.TOP); popup.setDropDownGravity(Gravity.END | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
popup.setVerticalOffset(AndroidUtils.dpToPx(app, 48f));
} else {
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
}
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(getActivity()); final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(getActivity());
popup.setAdapter(colorAdapter); popup.setAdapter(colorAdapter);

View file

@ -44,6 +44,7 @@ import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.views.controls.DynamicListView.DragIcon; import net.osmand.plus.views.controls.DynamicListView.DragIcon;
import net.osmand.plus.views.controls.ListDividerShape; import net.osmand.plus.views.controls.ListDividerShape;
import net.osmand.plus.views.controls.StableArrayAdapter; import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -611,11 +612,12 @@ public class WaypointDialogHelper {
}); });
final ImageButton moreBtn = (ImageButton) v.findViewById(R.id.image_button); final TextViewEx optionsButton = (TextViewEx) v.findViewById(R.id.text_button);
if (type == WaypointHelper.TARGETS) { if (type == WaypointHelper.TARGETS) {
moreBtn.setVisibility(View.VISIBLE); optionsButton.setVisibility(View.VISIBLE);
moreBtn.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_overflow_menu_white, !nightMode)); optionsButton.setTextColor(ContextCompat.getColor(ctx,
moreBtn.setOnClickListener(new View.OnClickListener() { nightMode ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light));
optionsButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
boolean hasActivePoints = false; boolean hasActivePoints = false;
@ -638,13 +640,13 @@ public class WaypointDialogHelper {
} }
} }
final PopupMenu optionsMenu = new PopupMenu(ctx, moreBtn); final PopupMenu optionsMenu = new PopupMenu(ctx, optionsButton);
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu); DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
MenuItem item; MenuItem item;
if (hasActivePoints) { if (hasActivePoints) {
item = optionsMenu.getMenu() item = optionsMenu.getMenu()
.add(R.string.intermediate_items_sort_by_distance) .add(R.string.intermediate_items_sort_by_distance)
.setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_sort_waypoint_dark)); .setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_sort_door_to_door));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
@ -673,7 +675,7 @@ public class WaypointDialogHelper {
} }
}); });
} else { } else {
moreBtn.setVisibility(View.GONE); optionsButton.setVisibility(View.GONE);
} }
TextView tv = (TextView) v.findViewById(R.id.header_text); TextView tv = (TextView) v.findViewById(R.id.header_text);

View file

@ -406,9 +406,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
void updateAdapter() { void updateAdapter() {
if (adapter != null) { if (adapter != null) {
adapter.createDisplayGroups(); adapter.updateDisplayedData();
adapter.updateShowDirectionMarkers();
adapter.notifyDataSetChanged();
} }
} }

View file

@ -903,9 +903,8 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
List<LatLon> selectedLatLon = markersHelper.getSelectedMarkersLatLon(); List<LatLon> selectedLatLon = markersHelper.getSelectedMarkersLatLon();
LatLon start = startFromLoc ? new LatLon(myLoc.getLatitude(), myLoc.getLongitude()) : selectedLatLon.remove(0); 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(); int[] sequence = new TspAnt().readGraph(selectedLatLon, start, null).solve();
List<MapMarker> res = new ArrayList<>(); List<MapMarker> res = new ArrayList<>();
for (int i = 0; i < sequence.length; i++) { for (int i = 0; i < sequence.length; i++) {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapmarkers.adapters; package net.osmand.plus.mapmarkers.adapters;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@ -11,10 +12,14 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper.GroupHeader; import net.osmand.plus.MapMarkersHelper.GroupHeader;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.MapMarkersHelper.OnGroupSyncedListener;
import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton; import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -65,7 +70,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
createDisplayGroups(); createDisplayGroups();
} }
public void updateShowDirectionMarkers() { private void updateShowDirectionMarkers() {
showDirectionEnabled = app.getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get(); showDirectionEnabled = app.getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get();
List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkers(); List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkers();
int markersCount = mapMarkers.size(); int markersCount = mapMarkers.size();
@ -82,7 +87,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
return 0; return 0;
} }
public void createDisplayGroups() { private void createDisplayGroups() {
items = new ArrayList<>(); items = new ArrayList<>();
app.getMapMarkersHelper().updateGroups(); app.getMapMarkersHelper().updateGroups();
List<MapMarkersGroup> groups = app.getMapMarkersHelper().getMapMarkersGroups(); List<MapMarkersGroup> groups = app.getMapMarkersHelper().getMapMarkersGroups();
@ -186,6 +191,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
this.screenOrientation = screenOrientation; this.screenOrientation = screenOrientation;
} }
public void updateDisplayedData() {
createDisplayGroups();
updateShowDirectionMarkers();
notifyDataSetChanged();
}
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
if (viewType == MARKER_TYPE) { if (viewType == MARKER_TYPE) {
@ -302,18 +313,14 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
} else { } else {
app.getMapMarkersHelper().moveMapMarkerToHistory(marker); app.getMapMarkersHelper().moveMapMarkerToHistory(marker);
} }
createDisplayGroups(); updateDisplayedData();
updateShowDirectionMarkers();
notifyDataSetChanged();
if (!markerInHistory) { if (!markerInHistory) {
snackbar = Snackbar.make(itemViewHolder.itemView, R.string.marker_moved_to_history, Snackbar.LENGTH_LONG) snackbar = Snackbar.make(itemViewHolder.itemView, R.string.marker_moved_to_history, Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() { .setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, 0); mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
createDisplayGroups(); updateDisplayedData();
updateShowDirectionMarkers();
notifyDataSetChanged();
} }
}); });
View snackBarView = snackbar.getView(); View snackBarView = snackbar.getView();
@ -380,15 +387,25 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
public void onCheckedChanged(CompoundButton compoundButton, boolean enabled) { public void onCheckedChanged(CompoundButton compoundButton, boolean enabled) {
group.setDisabled(!enabled); group.setDisabled(!enabled);
app.getMapMarkersHelper().updateGroupDisabled(group, !enabled); app.getMapMarkersHelper().updateGroupDisabled(group, !enabled);
createDisplayGroups(); updateDisplayedData();
updateShowDirectionMarkers();
notifyDataSetChanged();
if (!enabled) { if (!enabled) {
snackbar = Snackbar.make(holder.itemView, app.getString(R.string.group_will_be_removed_after_restart), Snackbar.LENGTH_LONG) final GPXFile[] gpxFile = new GPXFile[1];
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(group.getGroupKey());
if (selectedGpxFile != null) {
gpxFile[0] = selectedGpxFile.getGpxFile();
if (gpxFile[0] != null) {
switchGpxVisibility(gpxFile[0], false);
}
}
snackbar = Snackbar.make(holder.itemView, app.getString(R.string.group_deleted), Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() { .setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
headerViewHolder.disableGroupSwitch.setChecked(true); if (gpxFile[0] != null) {
switchGpxVisibility(gpxFile[0], true);
} else {
headerViewHolder.disableGroupSwitch.setChecked(true);
}
} }
}); });
View snackBarView = snackbar.getView(); View snackBarView = snackbar.getView();
@ -427,6 +444,17 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
} }
} }
private void switchGpxVisibility(@NonNull GPXFile gpxFile, boolean visible) {
GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper();
gpxHelper.selectGpxFile(gpxFile, visible, false, false);
gpxHelper.syncGpx(gpxFile, true, new OnGroupSyncedListener() {
@Override
public void onSyncDone() {
updateDisplayedData();
}
});
}
public void hideSnackbar() { public void hideSnackbar() {
if (snackbar != null && snackbar.isShown()) { if (snackbar != null && snackbar.isShown()) {
snackbar.dismiss(); snackbar.dismiss();