diff --git a/OsmAnd/res/layout/list_menu_item_native.xml b/OsmAnd/res/layout/list_menu_item_native.xml
index bf6182eda2..c4ab4f4296 100644
--- a/OsmAnd/res/layout/list_menu_item_native.xml
+++ b/OsmAnd/res/layout/list_menu_item_native.xml
@@ -1,32 +1,31 @@
-
+ android:orientation="horizontal">
+ android:visibility="gone"/>
+ android:textSize="@dimen/default_list_text_size"/>
+ android:visibility="gone"/>
+ android:layout_marginRight="24dp"
+ android:focusable="false"/>
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index a54367adb0..6790d5bd4f 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -2261,4 +2261,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
Recent places
Favourites
Successfully saved at: %1$s
+ POI will be deleted once you upload your changes
+ Show GPX
diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
index f00aab8541..9476551072 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
@@ -5,7 +5,6 @@ import android.app.Application;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
-import android.os.Build;
import android.support.v7.app.AlertDialog;
import android.util.TypedValue;
import android.view.View;
@@ -47,27 +46,26 @@ public class GpxUiHelper {
GPXTrackAnalysis analysis = result.getAnalysis(f == null ? 0 : f.lastModified());
return getDescription(app, analysis, html);
}
-
+
public static String getDescription(OsmandApplication app, TrkSegment t, boolean html) {
return getDescription(app, GPXTrackAnalysis.segment(0, t), html);
}
-
-
+
public static String getColorValue(String clr, String value, boolean html) {
- if(!html) {
+ if (!html) {
return value;
}
return "" + value + "";
}
-
+
public static String getColorValue(String clr, String value) {
return getColorValue(clr, value, true);
}
-
+
public static String getDescription(OsmandApplication app, GPXTrackAnalysis analysis, boolean html) {
StringBuilder description = new StringBuilder();
- String nl = html?"
":"\n";
+ String nl = html ? "
" : "\n";
String timeSpanClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_time_span_color));
String distanceClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_distance_color));
String speedClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_speed));
@@ -75,32 +73,32 @@ public class GpxUiHelper {
String descClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_altitude_desc));
// OUTPUT:
// 1. Total distance, Start time, End time
- description.append(app.getString(R.string.gpx_info_distance, getColorValue(distanceClr,
- OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app), html),
- getColorValue(distanceClr, analysis.points+"", html) ));
- if(analysis.totalTracks > 1) {
- description.append(nl).append(app.getString(R.string.gpx_info_subtracks, getColorValue(speedClr, analysis.totalTracks+"", html)));
+ description.append(app.getString(R.string.gpx_info_distance, getColorValue(distanceClr,
+ OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app), html),
+ getColorValue(distanceClr, analysis.points + "", html)));
+ if (analysis.totalTracks > 1) {
+ description.append(nl).append(app.getString(R.string.gpx_info_subtracks, getColorValue(speedClr, analysis.totalTracks + "", html)));
}
- if(analysis.wptPoints > 0) {
- description.append(nl).append(app.getString(R.string.gpx_info_waypoints, getColorValue(speedClr, analysis.wptPoints+"", html)));
+ if (analysis.wptPoints > 0) {
+ description.append(nl).append(app.getString(R.string.gpx_info_waypoints, getColorValue(speedClr, analysis.wptPoints + "", html)));
}
- if(analysis.isTimeSpecified()) {
- description.append(nl).append(app.getString(R.string.gpx_info_start_time, analysis.startTime));
- description.append(nl).append(app.getString(R.string.gpx_info_end_time, analysis.endTime));
+ if (analysis.isTimeSpecified()) {
+ description.append(nl).append(app.getString(R.string.gpx_info_start_time, analysis.startTime));
+ description.append(nl).append(app.getString(R.string.gpx_info_end_time, analysis.endTime));
}
// 2. Time span
- if(analysis.timeSpan > 0 && analysis.timeSpan / 1000 != analysis.timeMoving / 1000) {
- final String formatDuration = Algorithms.formatDuration((int) (analysis.timeSpan/1000)
- );
+ if (analysis.timeSpan > 0 && analysis.timeSpan / 1000 != analysis.timeMoving / 1000) {
+ final String formatDuration = Algorithms.formatDuration((int) (analysis.timeSpan / 1000)
+ );
description.append(nl).append(app.getString(R.string.gpx_timespan,
getColorValue(timeSpanClr, formatDuration, html)));
}
// 3. Time moving, if any
- if(analysis.isTimeMoving()){
- final String formatDuration = Algorithms.formatDuration((int) (analysis.timeMoving/1000)
- );
+ if (analysis.isTimeMoving()) {
+ final String formatDuration = Algorithms.formatDuration((int) (analysis.timeMoving / 1000)
+ );
description.append(nl).append(app.getString(R.string.gpx_timemoving,
getColorValue(timeSpanClr, formatDuration, html)));
}
@@ -115,32 +113,32 @@ public class GpxUiHelper {
String max = getColorValue(ascClr, OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app), html);
String asc = getColorValue(ascClr, OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app), html);
String desc = getColorValue(descClr, OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app), html);
- description.append(app.getString(R.string.gpx_info_diff_altitude,min +" - " + max ));
+ description.append(app.getString(R.string.gpx_info_diff_altitude, min + " - " + max));
description.append(nl);
- description.append(app.getString(R.string.gpx_info_asc_altitude,"\u2193 " + desc + " \u2191 " + asc + ""));
+ description.append(app.getString(R.string.gpx_info_asc_altitude, "\u2193 " + desc + " \u2191 " + asc + ""));
}
- if(analysis.isSpeedSpecified()){
+ if (analysis.isSpeedSpecified()) {
String avg = getColorValue(speedClr, OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app), html);
String max = getColorValue(ascClr, OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app), html);
- description.append(nl).append(app.getString(R.string.gpx_info_average_speed,avg));
- description.append(nl).append(app.getString(R.string.gpx_info_maximum_speed,max));
+ description.append(nl).append(app.getString(R.string.gpx_info_average_speed, avg));
+ description.append(nl).append(app.getString(R.string.gpx_info_maximum_speed, max));
}
return description.toString();
}
public static AlertDialog selectGPXFile(List selectedGpxList, final Activity activity,
- final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject callbackWithObject){
+ final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject callbackWithObject) {
OsmandApplication app = (OsmandApplication) activity.getApplication();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
final List allGpxList = getSortedGPXFilenames(dir, false);
- if(allGpxList.isEmpty()){
+ if (allGpxList.isEmpty()) {
AccessibleToast.makeText(activity, R.string.gpx_files_not_found, Toast.LENGTH_LONG).show();
}
- if(!allGpxList.isEmpty() || showCurrentGpx){
- if(showCurrentGpx){
+ if (!allGpxList.isEmpty() || showCurrentGpx) {
+ if (showCurrentGpx) {
allGpxList.add(0, activity.getString(R.string.show_current_gpx_title));
}
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, allGpxList, selectedGpxList, multipleChoice,
@@ -150,17 +148,17 @@ public class GpxUiHelper {
}
return null;
}
-
+
public static AlertDialog selectGPXFile(final Activity activity,
- final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject callbackWithObject) {
+ final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject callbackWithObject) {
OsmandApplication app = (OsmandApplication) activity.getApplication();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
final List list = getSortedGPXFilenames(dir, false);
- if(list.isEmpty()){
+ if (list.isEmpty()) {
AccessibleToast.makeText(activity, R.string.gpx_files_not_found, Toast.LENGTH_LONG).show();
}
- if(!list.isEmpty() || showCurrentGpx){
- if(showCurrentGpx){
+ if (!list.isEmpty() || showCurrentGpx) {
+ if (showCurrentGpx) {
list.add(0, activity.getString(R.string.show_current_gpx_title));
}
@@ -172,7 +170,7 @@ public class GpxUiHelper {
}
private static ContextMenuAdapter createGpxContextMenuAdapter(Activity activity, List allGpxList,
- List selectedGpxList, boolean multipleChoice,
+ List selectedGpxList, boolean multipleChoice,
boolean showCurrentTrack) {
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
//element position in adapter
@@ -197,9 +195,9 @@ public class GpxUiHelper {
}
protected static void updateSelection(List selectedGpxList, boolean showCurrentTrack,
- final ContextMenuAdapter adapter, int i, String fileName) {
- if(i == 0 && showCurrentTrack) {
- if(selectedGpxList.contains("")) {
+ final ContextMenuAdapter adapter, int i, String fileName) {
+ if (i == 0 && showCurrentTrack) {
+ if (selectedGpxList.contains("")) {
adapter.setSelection(i, 1);
}
} else {
@@ -211,13 +209,13 @@ public class GpxUiHelper {
}
}
}
-
+
private static void setDescripionInDialog(final ArrayAdapter> adapter, final ContextMenuAdapter cmAdapter, Activity activity,
- final File dir, String filename, final int position) {
+ final File dir, String filename, final int position) {
final Application app = activity.getApplication();
final File f = new File(dir, filename);
loadGPXFileInDifferentThread(activity, new CallbackWithObject() {
-
+
@Override
public boolean processResult(GPXFile[] result) {
cmAdapter.setItemName(position, cmAdapter.getItemName(position) + "\n" + getDescription((OsmandApplication) app, result[0], f, false));
@@ -228,19 +226,14 @@ public class GpxUiHelper {
}
private static AlertDialog createDialog(final Activity activity, final boolean showCurrentGpx,
- final boolean multipleChoice, final CallbackWithObject callbackWithObject,
- final List list, final ContextMenuAdapter adapter) {
+ final boolean multipleChoice, final CallbackWithObject callbackWithObject,
+ final List list, final ContextMenuAdapter adapter) {
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
- AlertDialog.Builder b = new AlertDialog.Builder(activity);
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
// final int padding = (int) (12 * activity.getResources().getDisplayMetrics().density + 0.5f);
final boolean light = app.getSettings().isLightContent();
- final int layout;
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
- layout = R.layout.list_menu_item;
- } else {
- layout = R.layout.list_menu_item_native;
- }
+ final int layout = R.layout.list_menu_item_native;
final ArrayAdapter listAdapter = new ArrayAdapter(activity, layout, R.id.title,
adapter.getItemNames()) {
@@ -258,7 +251,7 @@ public class GpxUiHelper {
return;
}
int nline = adapter.getItemName(position).indexOf('\n');
- if(nline == -1) {
+ if (nline == -1) {
setDescripionInDialog(arrayAdapter, adapter, activity, dir, list.get(position), position);
} else {
adapter.setItemName(position, adapter.getItemName(position).substring(0, nline));
@@ -267,7 +260,7 @@ public class GpxUiHelper {
}
});
- if(showCurrentGpx && position == 0) {
+ if (showCurrentGpx && position == 0) {
icon.setVisibility(View.INVISIBLE);
} else {
icon.setVisibility(View.VISIBLE);
@@ -303,35 +296,37 @@ public class GpxUiHelper {
public void onClick(DialogInterface dialog, int position) {
}
};
- b.setAdapter(listAdapter, onClickListener);
+ builder.setAdapter(listAdapter, onClickListener);
if (multipleChoice) {
- b.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
+ builder.setTitle(R.string.show_gpx)
+ .setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- GPXFile currentGPX = null;
- //clear all previously selected files before adding new one
- OsmandApplication app = (OsmandApplication) activity.getApplication();
- if(app != null && app.getSelectedGpxHelper() != null){
- app.getSelectedGpxHelper().clearAllGpxFileToShow();
- }
- if (showCurrentGpx && adapter.getSelection(0) > 0) {
- currentGPX = app.getSavingTrackHelper().getCurrentGpx();
- }
- List s = new ArrayList();
- for (int i = (showCurrentGpx ? 1 : 0); i < adapter.length(); i++) {
- if (adapter.getSelection(i) > 0) {
- s.add(list.get(i));
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ GPXFile currentGPX = null;
+ //clear all previously selected files before adding new one
+ OsmandApplication app = (OsmandApplication) activity.getApplication();
+ if (app != null && app.getSelectedGpxHelper() != null) {
+ app.getSelectedGpxHelper().clearAllGpxFileToShow();
+ }
+ if (showCurrentGpx && adapter.getSelection(0) > 0) {
+ currentGPX = app.getSavingTrackHelper().getCurrentGpx();
+ }
+ List s = new ArrayList<>();
+ for (int i = (showCurrentGpx ? 1 : 0); i < adapter.length(); i++) {
+ if (adapter.getSelection(i) > 0) {
+ s.add(list.get(i));
+ }
+ }
+ dialog.dismiss();
+ loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX,
+ s.toArray(new String[s.size()]));
}
- }
- dialog.dismiss();
- loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX,
- s.toArray(new String[s.size()]));
- }
- });
+ })
+ .setNegativeButton(R.string.shared_string_cancel, null);
}
- final AlertDialog dlg = b.create();
+ final AlertDialog dlg = builder.create();
dlg.setCanceledOnTouchOutside(true);
dlg.getListView().setOnItemClickListener(new OnItemClickListener() {
@Override
@@ -360,27 +355,27 @@ public class GpxUiHelper {
}
public static List getSortedGPXFilenamesByDate(File dir, boolean absolutePath) {
- final Map mp = new HashMap();
+ final Map mp = new HashMap<>();
readGpxDirectory(dir, mp, "", absolutePath);
- ArrayList list = new ArrayList(mp.keySet());
+ ArrayList list = new ArrayList<>(mp.keySet());
Collections.sort(list, new Comparator() {
@Override
public int compare(String object1, String object2) {
Long l1 = mp.get(object1);
Long l2 = mp.get(object2);
- long lhs = l1 == null ? 0 : l1.longValue();
- long rhs = l2 == null ? 0 : l2.longValue();
+ long lhs = l1 == null ? 0 : l1;
+ long rhs = l2 == null ? 0 : l2;
return lhs < rhs ? 1 : (lhs == rhs ? 0 : -1);
}
});
return list;
}
-
+
public static List getSortedGPXFilenames(File dir, boolean absolutePath) {
- final Map mp = new HashMap();
+ final Map mp = new HashMap<>();
readGpxDirectory(dir, mp, "", absolutePath);
- ArrayList list = new ArrayList(mp.keySet());
+ ArrayList list = new ArrayList<>(mp.keySet());
Collections.sort(list, new Comparator() {
@Override
public int compare(String object1, String object2) {
@@ -391,8 +386,8 @@ public class GpxUiHelper {
return list;
}
- private static void readGpxDirectory(File dir, final Map map, String parent,
- boolean absolutePath) {
+ private static void readGpxDirectory(File dir, final Map map, String parent,
+ boolean absolutePath) {
if (dir != null && dir.canRead()) {
File[] files = dir.listFiles();
if (files != null) {
@@ -407,9 +402,9 @@ public class GpxUiHelper {
}
}
}
-
+
private static void loadGPXFileInDifferentThread(final Activity activity, final CallbackWithObject callbackWithObject,
- final File dir, final GPXFile currentFile, final String... filename) {
+ final File dir, final GPXFile currentFile, final String... filename) {
final ProgressDialog dlg = ProgressDialog.show(activity, activity.getString(R.string.loading_smth, ""),
activity.getString(R.string.loading_data));
new Thread(new Runnable() {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java
index db441a8bff..a2b15ec7a5 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java
@@ -20,8 +20,6 @@ import net.osmand.plus.osmedit.OpenstreetmapUtil;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.osmedit.OsmPoint;
-import java.text.MessageFormat;
-
public class DeletePoiDialogFragment extends DialogFragment {
private static final String KEY_AMENITY_NODE = "amenity_node";
@@ -47,9 +45,8 @@ public class DeletePoiDialogFragment extends DialogFragment {
new Runnable() {
@Override
public void run() {
- AccessibleToast.makeText(activity, MessageFormat.format(
- getString(R.string.poi_action_succeded_template),
- getString(R.string.poi_action_delete)),
+ AccessibleToast.makeText(activity,
+ getString(R.string.poi_deleted_localy),
Toast.LENGTH_LONG).show();
if (activity instanceof MapActivity) {
((MapActivity) activity).getMapView().refreshMap(true);